blob: 42e630e373bc6e6d4badd34215d4a270a701bbc2 [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:
Pirmin Vogeleaf8b4b2020-03-03 14:51:03 +01005 VERILATOR_VERSION: 4.028
lowRISC Contributors802543a2019-08-31 12:12:56 +01006 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
Sam Elliott00881552020-05-04 16:46:55 +01009 # if you update this, update the definition in util/container/Dockerfile
Philipp Wagner018e3a22019-10-10 15:55:56 +010010 TOOLCHAIN_VERSION: 20191010-1
Miguel Young de la Sotab5be8c62019-11-20 10:01:09 -060011 # This controls where builds happen, and gets picked up by build_consts.sh.
12 BUILD_ROOT: $(Build.ArtifactStagingDirectory)
lowRISC Contributors802543a2019-08-31 12:12:56 +010013
14trigger:
lowRISC Contributors802543a2019-08-31 12:12:56 +010015 batch: true
16 branches:
17 include:
Philipp Wagnerdd1706e2020-03-15 14:39:59 +000018 - '*'
19 tags:
20 include:
21 - "*"
22pr:
23 branches:
24 include:
25 - '*'
lowRISC Contributors802543a2019-08-31 12:12:56 +010026
Philipp Wagnerbd9ae432019-11-01 14:33:30 +000027jobs:
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060028- job: lint
29 displayName: Run code quality checks (lint)
Philipp Wagnerbd9ae432019-11-01 14:33:30 +000030 pool:
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060031 vmImage: ubuntu-16.04
Philipp Wagnerbd9ae432019-11-01 14:33:30 +000032 steps:
33 - bash: |
Garret Kellyf5608d02019-11-01 16:28:11 -040034 sudo apt-get remove -y clang-6.0 libclang-common-6.0-dev libclang1-6.0 libllvm6.0
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060035 displayName: Remove existing Clang installation
36 - template: ci/install-package-dependencies.yml
Philipp Wagnerbd9ae432019-11-01 14:33:30 +000037 - bash: |
38 python3 --version
39 yapf --version
40 isort --version
41 clang-format -version
Rupert Swarbrick2d70c752020-03-24 17:23:40 +000042 flake8 --version
Philipp Wagnerb52cee62020-03-30 15:40:43 +010043 ninja --version
44 meson --version
Greg Chadwickfe07c7c2020-02-11 11:24:09 +000045 echo "PATH=$PATH"
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060046 displayName: Display tool versions
47 - bash: |
Rupert Swarbrick2d70c752020-03-24 17:23:40 +000048 fork_origin="$(git merge-base --fork-point origin/master)"
49 git diff --name-only "$fork_origin" "*.py" \
50 | xargs -r util/lintpy.py --tools flake8 -f
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060051 displayName: Run Python lint
Rupert Swarbrick2d70c752020-03-24 17:23:40 +000052 continueOnError: true
Philipp Wagnerbd9ae432019-11-01 14:33:30 +000053 - bash: |
54 make -C hw regs && git diff --exit-code
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060055 if [[ $? != 0 ]]; then
Philipp Wagnerbd9ae432019-11-01 14:33:30 +000056 echo -n "##vso[task.logissue type=error]"
57 echo "Register headers not up-to-date. Regenerate them with 'make -C hw regs'."
58 exit 1
59 fi
60 condition: always()
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060061 displayName: Ensure all generated files are clean and up-to-date
Philipp Wagnerbd9ae432019-11-01 14:33:30 +000062 - bash: |
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060063 util/build_docs.py
Garret Kelly889bf6a2019-11-03 13:02:27 -050064 condition: always()
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060065 displayName: Render documentation
Garret Kelly889bf6a2019-11-03 13:02:27 -050066 - bash: |
Garret Kelly8d7da7c2019-11-08 14:09:34 -050067 cd site/landing
68 ../../build/docs-hugo/hugo
69 condition: always()
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060070 displayName: Render landing site
Garret Kelly8d7da7c2019-11-08 14:09:34 -050071 - bash: |
Philipp Wagnerbd9ae432019-11-01 14:33:30 +000072 # XXX: As of today, task.logissue comments with 'sourcepath' set don't
73 # get reported to GitHub Checks annotations. Upstream bug report:
74 # https://developercommunity.visualstudio.com/content/problem/689794/pipelines-logging-command-logissue-does-not-report.html
75 #echo "##vso[task.issue type=error;sourcepath=/azure-pipelines.yml;linenumber=45;columnnumber=1;code=100;]Found something that could be a problem."
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060076 fork_origin="$(git merge-base --fork-point origin/master)"
77 changed_files="$(git diff --name-only "$fork_origin" | grep -v /vendor/ | grep -E '\.(cpp|cc|c|h)$')"
Greg Chadwickffa126f2020-04-07 11:36:31 +010078 if [[ -n "$changed_files" ]]; then
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060079 xargs git diff -U0 "$fork_origin" <<< "$changed_files" \
80 | clang-format-diff -p1 \
81 | tee clang-format-output
82 if [[ -s clang-format-output ]]; then
83 echo -n "##vso[task.logissue type=error]"
84 echo "C/C++ lint failed. Use 'git clang-format' with appropriate options to reformat the changed code."
85 exit 1
86 fi
Philipp Wagnerbd9ae432019-11-01 14:33:30 +000087 fi
88 # This check is not idempotent, but checks changes to a base branch.
89 # Run it only on pull requests.
90 condition: eq(variables['Build.Reason'], 'PullRequest')
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -060091 displayName: Use clang-format to check C/C++ coding style
Philipp Wagnerbd9ae432019-11-01 14:33:30 +000092 - bash: |
Miguel Young de la Sotab23dc8c2020-01-14 13:52:33 -050093 fork_origin="$(git merge-base --fork-point origin/master)"
94 changed_files="$(git diff --name-only "$fork_origin")"
Greg Chadwickffa126f2020-04-07 11:36:31 +010095 if [[ -n "$changed_files" ]]; then
Miguel Young de la Sotab23dc8c2020-01-14 13:52:33 -050096 xargs util/fix_include_guard.py --dry-run <<< "$changed_files" | tee fix-include-guard-output
97 if [[ -s fix-include-guard-output ]]; then
98 echo -n "##vso[task.logissue type=error]"
99 echo "Include guard check failed. Please run util/fix_include_guard.py on the above files."
100 exit 1
101 fi
102 fi
103 condition: eq(variables['Build.Reason'], 'PullRequest')
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600104 displayName: Check formatting on header guards
Miguel Young de la Sotab23dc8c2020-01-14 13:52:33 -0500105 - bash: |
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600106 commit_range="$(git merge-base --fork-point origin/master)..HEAD"
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000107 # Notes:
108 # * Merge commits are not checked. We always use rebases instead of
109 # merges to keep a linear history, which makes merge commits disappear
110 # ultimately, making them only a CI artifact which should not be
111 # checked.
112 # * 'type=error' is used even for warnings. Only "errors" are shown in
113 # the GitHub checks API. However, warnings don't return a non-zero
114 # error code and don't fail the build step.
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600115 util/lint_commits.py \
116 --no-merges \
117 --error-msg-prefix="##vso[task.logissue type=error]" \
118 --warning-msg-prefix="##vso[task.logissue type=error]" \
119 "$commit_range"
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000120 # Only run on pull requests to check new commits only
121 condition: eq(variables['Build.Reason'], 'PullRequest')
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600122 displayName: Check commit metadata
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000123 - bash: |
124 only_doc_changes=0
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600125 if [[ "$(Build.Reason)" = "PullRequest" ]]; then
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000126 # Conservative way of checking for documentation-only changes.
127 # Only relevant for pipelines triggered from pull requests
128 echo "Checking for doc-only changes in this pull request"
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600129 fork_origin="$(git merge-base --fork-point origin/master)"
130 only_doc_changes="$(git diff --name-only "$fork_origin" | grep -v '\.md$' -q; echo $?)"
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000131 fi
132 echo "##vso[task.setvariable variable=onlyDocChanges;isOutput=true]${only_doc_changes}"
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600133 displayName: Check if the commit only contains documentation changes
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000134 name: DetermineBuildType
Philipp Wagner1e643552019-09-04 15:39:14 +0100135
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600136- job: sw_build
137 displayName: Build Software
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000138 dependsOn: lint
Philipp Wagner9d20ee62019-11-29 14:27:28 +0000139 condition: and(succeeded(), eq(dependencies.lint.outputs['DetermineBuildType.onlyDocChanges'], '0'))
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000140 pool:
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600141 vmImage: ubuntu-16.04
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000142 steps:
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600143 - template: ci/install-package-dependencies.yml
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000144 - bash: |
145 set -x
146 sudo util/get-toolchain.py \
147 --target-dir="${TOOLCHAIN_PATH}" \
148 --release-version="${TOOLCHAIN_VERSION}" \
Philipp Wagner1c514412019-11-27 14:48:47 +0000149 --update
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600150 displayName: Install toolchain
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000151 - bash: |
Miguel Young de la Sota63793572019-11-13 14:18:51 -0600152 . util/build_consts.sh
Miguel Young de la Sota4a4946d2019-11-21 10:44:18 -0600153 ./meson_init.sh -A
Miguel Young de la Sota76526c32020-01-28 10:24:41 -0500154 ninja -C "$OBJ_DIR" all
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600155 displayName: Build embedded targets
156 - template: ci/upload-artifacts-template.yml
Miguel Young de la Sota9d20b3d2020-02-03 16:35:31 -0500157 - bash: |
158 . util/build_consts.sh
159 ninja -C "$OBJ_DIR" test
160 displayName: 'Run unit tests'
161 - template: 'ci/upload-artifacts-template.yml'
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -0600162 parameters:
163 artifact: sw_build
lowRISC Contributors802543a2019-08-31 12:12:56 +0100164
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600165- job: top_earlgrey_verilator
166 displayName: Build Verilator simulation of the Earl Grey toplevel design
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000167 dependsOn: lint
Philipp Wagner9d20ee62019-11-29 14:27:28 +0000168 condition: and(succeeded(), eq(dependencies.lint.outputs['DetermineBuildType.onlyDocChanges'], '0'))
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000169 pool: Default
170 steps:
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600171 - template: ci/install-package-dependencies.yml
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000172 - bash: |
173 set -e
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600174 if [[ ! -d "$(VERILATOR_PATH)" ]]; then
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000175 echo "Building verilator (no cached build found)"
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600176
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000177 mkdir -p build/verilator
178 cd build/verilator
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600179 curl -Ls -o verilator.tgz \
180 "https://www.veripool.org/ftp/verilator-$(VERILATOR_VERSION).tgz"
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000181 tar -xf verilator.tgz
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600182
183 cd "verilator-$(VERILATOR_VERSION)"
184 ./configure --prefix="$(VERILATOR_PATH)"
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000185 make -j$(nproc)
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600186 mkdir -p "$VERILATOR_PATH"
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000187 make install
188 else
189 echo "Re-using cached verilator build"
190 fi
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600191 displayName: Build and install Verilator
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000192 - bash: |
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600193 export PATH="$VERILATOR_PATH/bin:$PATH"
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000194 python3 --version
195 fusesoc --version
196 verilator --version
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600197 displayName: Display environment
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000198 - bash: |
Miguel Young de la Sotab5be8c62019-11-20 10:01:09 -0600199 . util/build_consts.sh
200 mkdir -p "$OBJ_DIR/hw"
201 mkdir -p "$BIN_DIR/hw/top_earlgrey"
202
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600203 export PATH="$VERILATOR_PATH/bin:$PATH"
Miguel Young de la Sotab5be8c62019-11-20 10:01:09 -0600204 fusesoc --cores-root=. \
205 run --target=sim --setup --build \
206 --build-root="$OBJ_DIR/hw" \
207 lowrisc:systems:top_earlgrey_verilator
208
209 cp "$OBJ_DIR/hw/sim-verilator/Vtop_earlgrey_verilator" \
210 "$BIN_DIR/hw/top_earlgrey"
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600211 displayName: Build simulation with Verilator
212 - template: ci/upload-artifacts-template.yml
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -0600213 parameters:
214 artifact: top_earlgrey_verilator
Philipp Wagnerf4655a12019-10-30 11:59:15 +0000215
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600216- job: execute_verilated_tests
217 displayName: Execute tests on the Verilated system
Timothy Chenf7e85cb2019-12-10 16:24:39 -0800218 pool:
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600219 vmImage: ubuntu-16.04
Timothy Chen7d1436d2019-12-04 17:26:14 -0800220 dependsOn:
221 - top_earlgrey_verilator
222 - sw_build
223 steps:
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600224 - template: ci/install-package-dependencies.yml
225 - template: ci/download-artifacts-template.yml
Timothy Chen7d1436d2019-12-04 17:26:14 -0800226 - bash: |
227 . util/build_consts.sh
228 export VERILATED_SYSTEM_PATH="$BIN_DIR/hw/top_earlgrey/Vtop_earlgrey_verilator"
Philipp Wagner57418e72019-12-02 21:25:27 +0000229 pytest --version
Timothy Chen7d1436d2019-12-04 17:26:14 -0800230 ci/run_verilator_pytest.sh
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600231 displayName: Execute tests
Timothy Chen7d1436d2019-12-04 17:26:14 -0800232
Greg Chadwickbf9dc382020-04-17 09:30:40 +0100233- template: ci/run-riscv-compliance.yml
234 parameters:
235 rvc_test_suites:
236 - rv32i
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600237
Greg Chadwickbf9dc382020-04-17 09:30:40 +0100238- template: ci/run-riscv-compliance.yml
239 parameters:
240 rvc_test_suites:
241 - rv32im
242 - rv32imc
243 - rv32Zicsr
Timothy Chen7d1436d2019-12-04 17:26:14 -0800244
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600245- job: top_earlgrey_nexysvideo
246 displayName: Build NexysVideo variant of the Earl Grey toplevel design using Vivado
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000247 dependsOn:
248 - lint
249 # The bootrom is built into the FPGA image at synthesis time.
Miguel Young de la Sotab5be8c62019-11-20 10:01:09 -0600250 - sw_build
Philipp Wagner9d20ee62019-11-29 14:27:28 +0000251 condition: and(succeeded(), eq(dependencies.lint.outputs['DetermineBuildType.onlyDocChanges'], '0'))
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000252 pool: Default
253 timeoutInMinutes: 120 # 2 hours
254 steps:
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600255 - template: ci/install-package-dependencies.yml
256 - template: ci/download-artifacts-template.yml
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000257 - bash: |
258 set -e
Miguel Young de la Sotab5be8c62019-11-20 10:01:09 -0600259 . util/build_consts.sh
260 mkdir -p "$OBJ_DIR/hw"
261 mkdir -p "$BIN_DIR/hw/top_earlgrey"
262
Greg Chadwick12871042020-04-20 13:42:56 +0100263 BOOTROM_VMEM="$BIN_DIR/sw/device/boot_rom/boot_rom_fpga_nexysvideo.32.vmem"
Miguel Young de la Sotab5be8c62019-11-20 10:01:09 -0600264 test -f "$BOOTROM_VMEM"
265
266 . /opt/xilinx/Vivado/2018.3/settings64.sh
267 fusesoc --cores-root=. \
268 run --target=synth --setup --build \
269 --build-root="$OBJ_DIR/hw" \
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000270 lowrisc:systems:top_earlgrey_nexysvideo \
Miguel Young de la Sotab5be8c62019-11-20 10:01:09 -0600271 --ROM_INIT_FILE="$BOOTROM_VMEM"
272
273 cp "$OBJ_DIR/hw/synth-vivado/lowrisc_systems_top_earlgrey_nexysvideo_0.1.bit" \
274 "$BIN_DIR/hw/top_earlgrey"
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600275 displayName: Build bitstream with Vivado
276 - template: ci/upload-artifacts-template.yml
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -0600277 parameters:
278 artifact: top_earlgrey_nexysvideo
lowRISC Contributors802543a2019-08-31 12:12:56 +0100279
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600280- job: deploy_release_artifacts
281 displayName: Package and deploy release distribution
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000282 pool:
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600283 vmImage: ubuntu-16.04
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000284 dependsOn:
285 - lint
Miguel Young de la Sotab5be8c62019-11-20 10:01:09 -0600286 - sw_build
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000287 - top_earlgrey_verilator
288 - top_earlgrey_nexysvideo
289 condition: eq(dependencies.lint.outputs['DetermineBuildType.onlyDocChanges'], '0')
290 steps:
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600291 - template: ci/install-package-dependencies.yml
292 - template: ci/download-artifacts-template.yml
Miguel Young de la Sotad42948c2019-11-18 13:56:55 -0600293 - bash: |
Miguel Young de la Sotad42948c2019-11-18 13:56:55 -0600294 . util/build_consts.sh
Miguel Young de la Sotab5be8c62019-11-20 10:01:09 -0600295
Miguel Young de la Sotad42948c2019-11-18 13:56:55 -0600296 util/make_distribution.sh
Philipp Wagner542e2202019-10-30 13:10:16 +0000297
Miguel Young de la Sotad42948c2019-11-18 13:56:55 -0600298 tar --list -f $BIN_DIR/opentitan-*.tar.xz
299 # Put the resulting tar file into a directory the |publish| step below can reference.
300 mkdir "$BUILD_ROOT/dist-final"
301 mv $BIN_DIR/opentitan-*.tar.xz "$BUILD_ROOT/dist-final"
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600302 displayName: Create final dist directory out of partial ones
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000303 - publish: $(Build.ArtifactStagingDirectory)/dist-final
304 artifact: opentitan-dist
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600305 displayName: Upload release artifacts as Azure artifact
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000306 - task: GithubRelease@0
Miguel Young de la Sotaa68e3072020-01-02 13:59:54 -0600307 displayName: Upload to GitHub releases (only tags)
Philipp Wagner0b20f5d2019-11-01 16:24:52 +0000308 condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
Philipp Wagnerbd9ae432019-11-01 14:33:30 +0000309 inputs:
310 gitHubConnection: opentitan-release-upload
311 repositoryName: lowrisc/opentitan
312 addChangeLog: false
313 assets: |
314 $(Build.ArtifactStagingDirectory)/dist-final/*