blob: 1fa3c41da977c66bac48b6ead8a1b166fd214741 [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001# Azure Pipelines CI build configuration
2# Documentation at https://aka.ms/yaml
3
4variables:
5 VERILATOR_VERSION: 4.010
6 VERILATOR_PATH: /opt/buildcache/verilator/$(VERILATOR_VERSION)
Miguel Osorio88179fc2019-09-19 23:37:48 -07007 TOOLCHAIN_PATH: /opt/buildcache/riscv
8 # Release tag from https://github.com/lowRISC/lowrisc-toolchains/releases
9 TOOLCHAIN_VERSION: 20190827-2
lowRISC Contributors802543a2019-08-31 12:12:56 +010010
11trigger:
12 # Combine builds on master as long as another build is running
13 batch: true
14 branches:
15 include:
16 - master
17
18stages:
19# Stage 1 are fast checks for tools which provide fast turnaround time
20# (< 5 minutes)
21- stage: quick_sanity
22 displayName: Quick sanity checks
23 jobs:
24 - job: "lint"
25 displayName: "Run code quality checks (lint)"
26 pool: "Default"
27 steps:
28 - bash: |
29 sudo apt-get install -y python3 python3-pip build-essential srecord python3-setuptools zlib1g-dev libusb-1.0 clang-format
Philipp Wagner5b8d36b2019-09-04 14:53:03 +010030 sudo pip3 install -r python-requirements.txt
lowRISC Contributors802543a2019-08-31 12:12:56 +010031 displayName: 'Install dependencies'
32
33 - bash: |
34 python3 --version
35 yapf --version
36 isort --version
37 clang-format -version
38 displayName: 'Display tool versions'
39
40# XXX: Python lint checks are until Issue #313 is resolved
41# - bash: find ./util -iname '*.py' -print0 | xargs -0 -n1 $PWD/util/lintpy.py -f
42# displayName: 'Run Python lint'
43
44 - bash: |
45 make -C hw regs && git diff --exit-code
46 if [ $? != 0 ]; then
47 echo -n "##vso[task.logissue type=error]"
48 echo "Register headers not up-to-date. Regenerate them with 'make -C hw regs'."
49 exit 1
50 fi
51 condition: always()
52 displayName: 'Ensure all generated files are clean and up-to-date'
53
54 - bash: |
55 # XXX: As of today, task.logissue comments with 'sourcepath' set don't
56 # get reported to GitHub Checks annotations. Upstream bug report:
57 # https://developercommunity.visualstudio.com/content/problem/689794/pipelines-logging-command-logissue-does-not-report.html
58 #echo "##vso[task.issue type=error;sourcepath=/azure-pipelines.yml;linenumber=45;columnnumber=1;code=100;]Found something that could be a problem."
Tobias Wölfele2a3fb72019-09-24 12:52:36 +020059 fork_origin=$(git merge-base --fork-point origin/master)
60 changed_files=$(git diff --name-only $fork_origin | grep -v /vendor/)
Philipp Wagner78139cc2019-10-03 11:34:30 +010061 test -z $changed_files || git diff -U0 $fork_origin $changed_files | clang-format-diff -p1 | tee clang-format-output
lowRISC Contributors802543a2019-08-31 12:12:56 +010062 if [ -s clang-format-output ]; then
63 echo -n "##vso[task.logissue type=error]"
64 echo "C/C++ lint failed. Use 'util/run-clang-format.sh' or 'git clang-format' to format the code."
65 exit 1
66 fi
67 # This check is not idempotent, but checks changes to a base branch.
68 # Run it only on pull requests.
69 condition: eq(variables['Build.Reason'], 'PullRequest')
70 displayName: 'Use clang-format to check C/C++ coding style'
Philipp Wagner1e643552019-09-04 15:39:14 +010071
lowRISC Contributors802543a2019-08-31 12:12:56 +010072 - bash: |
73 commit_range=$(git merge-base --fork-point origin/master)..HEAD
Philipp Wagner1e643552019-09-04 15:39:14 +010074 # Notes:
75 # * Merge commits are not checked. We always use rebases instead of
76 # merges to keep a linear history, which makes merge commits disappear
77 # ultimately, making them only a CI artifact which should not be
78 # checked.
79 # * 'type=error' is used even for warnings. Only "errors" are shown in
80 # the GitHub checks API. However, warnings don't return a non-zero
81 # error code and don't fail the build step.
82 ./util/lint_commits.py \
83 --no-merges \
84 --error-msg-prefix='##vso[task.logissue type=error]' \
85 --warning-msg-prefix='##vso[task.logissue type=error]' \
86 $commit_range
lowRISC Contributors802543a2019-08-31 12:12:56 +010087 # Only run on pull requests to check new commits only
88 condition: eq(variables['Build.Reason'], 'PullRequest')
89 displayName: "Check commit metadata"
90
91# Stage 2 for longer builds and tests. Jobs run in parallel by default, and
92# dependencies should be used for build -> test dependencies.
93- stage: build_test
94 displayName: Build and test
95 jobs:
Miguel Osorio88179fc2019-09-19 23:37:48 -070096 - job: "sw_build"
97 displayName: "Build Software"
98 pool: "Default"
99 steps:
100 - bash: |
101 sudo apt-get install -y python3 python3-pip build-essential srecord python3-setuptools zlib1g-dev libusb-1.0 \
Alex Bradbury72f8a8d2019-10-02 08:24:32 +0100102 && sudo pip3 install -r python-requirements.txt
Miguel Osorio88179fc2019-09-19 23:37:48 -0700103 displayName: 'Install dependencies'
104 - bash: |
105 export TOOLCHAIN_PATH="${TOOLCHAIN_PATH}"
106 export TOOLCHAIN_VERSION="${TOOLCHAIN_VERSION}"
107 REQUEST_UPDATE=true ci/run_sw_build.sh
108 displayName: 'Build embedded targets'
lowRISC Contributors802543a2019-08-31 12:12:56 +0100109 - job: "top_earlgrey_verilator"
110 displayName: "Build Verilator simulation of the Earl Grey toplevel design"
111 pool: "Default"
112 steps:
113 - bash: |
114 sudo apt-get install -y python3 python3-pip build-essential srecord python3-setuptools zlib1g-dev libusb-1.0 \
Philipp Wagner5b8d36b2019-09-04 14:53:03 +0100115 && sudo pip3 install -r python-requirements.txt \
lowRISC Contributors802543a2019-08-31 12:12:56 +0100116 && sudo apt-get install git make autoconf g++ flex bison curl
117 displayName: 'Install dependencies'
118 - bash: |
119 set -e
120 if [ ! -d $(VERILATOR_PATH) ]; then
121 echo "Building verilator (no cached build found)"
122 mkdir -p build/verilator
123 cd build/verilator
124 curl -Ls -o verilator.tgz https://www.veripool.org/ftp/verilator-$(VERILATOR_VERSION).tgz
125 tar -xf verilator.tgz
126 cd verilator-$(VERILATOR_VERSION)
127 ./configure --prefix=$(VERILATOR_PATH)
128 make -j$(nproc)
129 mkdir -p $VERILATOR_PATH
130 make install
131 else
132 echo "Re-using cached verilator build"
133 fi
134 displayName: 'Build and install Verilator'
135 - bash: |
136 export PATH=$VERILATOR_PATH/bin:$PATH
137 python3 --version
138 fusesoc --version
139 verilator --version
140 displayName: 'Display environment'
141 - bash: |
142 export PATH=$VERILATOR_PATH/bin:$PATH
143 fusesoc --cores-root=. sim --build-only lowrisc:systems:top_earlgrey_verilator
144 displayName: 'Build simulation with Verilator'
145
146 - job: "top_earlgrey_nexysvideo"
147 displayName: "Build NexysVideo variant of the Earl Grey toplevel design using Vivado"
148 pool: "Default"
149 timeoutInMinutes: 120 # 2 hours
150 steps:
151 - bash: |
152 sudo apt-get install -y python3 python3-pip build-essential srecord python3-setuptools zlib1g-dev libusb-1.0 \
Alex Bradbury72f8a8d2019-10-02 08:24:32 +0100153 && sudo pip3 install -r python-requirements.txt
lowRISC Contributors802543a2019-08-31 12:12:56 +0100154 displayName: 'Install dependencies'
155 - bash: |
156 set -e
157 source /opt/xilinx/Vivado/2018.3/settings64.sh
158 fusesoc --cores-root . build lowrisc:systems:top_earlgrey_nexysvideo
159 displayName: 'Build bitstream with Vivado'