azure: Use a login shell everywhere for MSYS2 build
[platform/kernel/u-boot.git] / .azure-pipelines.yml
1 variables:
2   windows_vm: vs2017-win2016
3   ubuntu_vm: ubuntu-18.04
4   macos_vm: macOS-10.15
5   ci_runner_image: trini/u-boot-gitlab-ci-runner:bionic-20200526-18Jun2020
6   # Add '-u 0' options for Azure pipelines, otherwise we get "permission
7   # denied" error when it tries to "useradd -m -u 1001 vsts_azpcontainer",
8   # since our $(ci_runner_image) user is not root.
9   container_option: -u 0
10   work_dir: /u
11
12 jobs:
13   - job: tools_only_windows
14     displayName: 'Ensure host tools build for Windows'
15     pool:
16       vmImage: $(windows_vm)
17     strategy:
18       matrix:
19         i686:
20           MSYS_DIR: msys32
21           BASE_REPO: msys2-ci-base-i686
22         x86_64:
23           MSYS_DIR: msys64
24           BASE_REPO: msys2-ci-base
25     steps:
26       - script: |
27           git clone https://github.com/msys2/$(BASE_REPO).git %CD:~0,2%\$(MSYS_DIR)
28         displayName: 'Install MSYS2'
29       - script: |
30           %CD:~0,2%\$(MSYS_DIR)\usr\bin\bash -lc "pacman --noconfirm -Syyuu"
31         displayName: 'Update MSYS2'
32       - script: |
33           %CD:~0,2%\$(MSYS_DIR)\usr\bin\bash -lc "pacman --noconfirm --needed -S make gcc bison diffutils openssl-devel"
34         displayName: 'Install Toolchain'
35       - script: |
36           echo make tools-only_defconfig tools-only NO_SDL=1 > build-tools.sh
37           %CD:~0,2%\$(MSYS_DIR)\usr\bin\bash -lc "bash build-tools.sh"
38         displayName: 'Build Host Tools'
39         env:
40           # Tell MSYS2 we need a POSIX emulation layer
41           MSYSTEM: MSYS
42           # Tell MSYS2 not to ‘cd’ our startup directory to HOME
43           CHERE_INVOKING: yes
44
45   - job: tools_only_macOS
46     displayName: 'Ensure host tools build for macOS X'
47     pool:
48       vmImage: $(macos_vm)
49     steps:
50       - script: brew install make
51         displayName: Brew install dependencies
52       - script: |
53           gmake tools-only_config tools-only NO_SDL=1 \
54             HOSTCFLAGS="-I/usr/local/opt/openssl@1.1/include" \
55             HOSTLDFLAGS="-L/usr/local/opt/openssl@1.1/lib" \
56             -j$(sysctl -n hw.logicalcpu)
57         displayName: 'Perform tools-only build'
58
59   - job: cppcheck
60     displayName: 'Static code analysis with cppcheck'
61     pool:
62       vmImage: $(ubuntu_vm)
63     container:
64       image: $(ci_runner_image)
65       options: $(container_option)
66     steps:
67       - script: cppcheck -j$(nproc) --force --quiet --inline-suppr .
68
69   - job: htmldocs
70     displayName: 'Build HTML documentation'
71     pool:
72       vmImage: $(ubuntu_vm)
73     container:
74       image: $(ci_runner_image)
75       options: $(container_option)
76     steps:
77       - script: make htmldocs
78
79   - job: todo
80     displayName: 'Search for TODO within source tree'
81     pool:
82       vmImage: $(ubuntu_vm)
83     container:
84       image: $(ci_runner_image)
85       options: $(container_option)
86     steps:
87       - script: grep -r TODO .
88       - script: grep -r FIXME .
89       - script: grep -r HACK . | grep -v HACKKIT
90
91   - job: sloccount
92     displayName: 'Some statistics about the code base'
93     pool:
94       vmImage: $(ubuntu_vm)
95     container:
96       image: $(ci_runner_image)
97       options: $(container_option)
98     steps:
99       - script: sloccount .
100
101   - job: maintainers
102     displayName: 'Ensure all configs have MAINTAINERS entries'
103     pool:
104       vmImage: $(ubuntu_vm)
105     container:
106       image: $(ci_runner_image)
107       options: $(container_option)
108     steps:
109       - script: |
110           if [ `./tools/genboardscfg.py -f 2>&1 | wc -l` -ne 0 ]; then exit 1; fi
111
112   - job: tools_only
113     displayName: 'Ensure host tools build'
114     pool:
115       vmImage: $(ubuntu_vm)
116     container:
117       image: $(ci_runner_image)
118       options: $(container_option)
119     steps:
120       - script: |
121           make tools-only_config tools-only -j$(nproc)
122
123   - job: envtools
124     displayName: 'Ensure env tools build'
125     pool:
126       vmImage: $(ubuntu_vm)
127     container:
128       image: $(ci_runner_image)
129       options: $(container_option)
130     steps:
131       - script: |
132           make tools-only_config envtools -j$(nproc)
133
134   - job: utils
135     displayName: 'Run binman, buildman, dtoc, Kconfig and patman testsuites'
136     pool:
137       vmImage: $(ubuntu_vm)
138     steps:
139       - script: |
140           cat << EOF > build.sh
141           set -ex
142           cd ${WORK_DIR}
143           EOF
144           cat << "EOF" >> build.sh
145           git config --global user.name "Azure Pipelines"
146           git config --global user.email bmeng.cn@gmail.com
147           export USER=azure
148           virtualenv -p /usr/bin/python3 /tmp/venv
149           . /tmp/venv/bin/activate
150           pip install pyelftools pytest
151           export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl
152           export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
153           export PATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}
154           ./tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w sandbox_spl
155           ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test
156           ./tools/buildman/buildman -t
157           ./tools/dtoc/dtoc -t
158           ./tools/patman/patman test
159           make O=${UBOOT_TRAVIS_BUILD_DIR} testconfig
160           EOF
161           cat build.sh
162           # We cannot use "container" like other jobs above, as buildman
163           # seems to hang forever with pre-configured "container" environment
164           docker run -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash $(work_dir)/build.sh
165
166   - job: nokia_rx51_test
167     displayName: 'Run tests for Nokia RX-51 (aka N900)'
168     pool:
169       vmImage: $(ubuntu_vm)
170     container:
171       image: $(ci_runner_image)
172       options: $(container_option)
173     steps:
174       - script: |
175           ./tools/buildman/buildman --fetch-arch arm
176           export PATH=~/.buildman-toolchains/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/:$PATH
177           test/nokia_rx51_test.sh
178
179   - job: test_py
180     displayName: 'test.py'
181     pool:
182       vmImage: $(ubuntu_vm)
183     strategy:
184       matrix:
185         sandbox:
186           TEST_PY_BD: "sandbox"
187         sandbox_clang:
188           TEST_PY_BD: "sandbox"
189           OVERRIDE: "-O clang-10"
190         sandbox_spl:
191           TEST_PY_BD: "sandbox_spl"
192           TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff"
193         sandbox_flattree:
194           TEST_PY_BD: "sandbox_flattree"
195         evb_ast2500:
196           TEST_PY_BD: "evb-ast2500"
197           TEST_PY_ID: "--id qemu"
198         vexpress_ca15_tc2:
199           TEST_PY_BD: "vexpress_ca15_tc2"
200           TEST_PY_ID: "--id qemu"
201         vexpress_ca9x4:
202           TEST_PY_BD: "vexpress_ca9x4"
203           TEST_PY_ID: "--id qemu"
204         integratorcp_cm926ejs:
205           TEST_PY_BD: "integratorcp_cm926ejs"
206           TEST_PY_ID: "--id qemu"
207           TEST_PY_TEST_SPEC: "not sleep"
208         qemu_arm:
209           TEST_PY_BD: "qemu_arm"
210           TEST_PY_TEST_SPEC: "not sleep"
211         qemu_arm64:
212           TEST_PY_BD: "qemu_arm64"
213           TEST_PY_TEST_SPEC: "not sleep"
214         qemu_mips:
215           TEST_PY_BD: "qemu_mips"
216           TEST_PY_TEST_SPEC: "not sleep"
217         qemu_mipsel:
218           TEST_PY_BD: "qemu_mipsel"
219           TEST_PY_TEST_SPEC: "not sleep"
220         qemu_mips64:
221           TEST_PY_BD: "qemu_mips64"
222           TEST_PY_TEST_SPEC: "not sleep"
223         qemu_mips64el:
224           TEST_PY_BD: "qemu_mips64el"
225           TEST_PY_TEST_SPEC: "not sleep"
226         qemu_malta:
227           TEST_PY_BD: "malta"
228           TEST_PY_ID: "--id qemu"
229           TEST_PY_TEST_SPEC: "not sleep and not efi"
230         qemu_maltael:
231           TEST_PY_BD: "maltael"
232           TEST_PY_ID: "--id qemu"
233           TEST_PY_TEST_SPEC: "not sleep and not efi"
234         qemu_malta64:
235           TEST_PY_BD: "malta64"
236           TEST_PY_ID: "--id qemu"
237           TEST_PY_TEST_SPEC: "not sleep and not efi"
238         qemu_malta64el:
239           TEST_PY_BD: "malta64el"
240           TEST_PY_ID: "--id qemu"
241           TEST_PY_TEST_SPEC: "not sleep and not efi"
242         qemu_ppce500:
243           TEST_PY_BD: "qemu-ppce500"
244           TEST_PY_TEST_SPEC: "not sleep"
245         qemu_riscv32:
246           TEST_PY_BD: "qemu-riscv32"
247           TEST_PY_TEST_SPEC: "not sleep"
248         qemu_riscv64:
249           TEST_PY_BD: "qemu-riscv64"
250           TEST_PY_TEST_SPEC: "not sleep"
251         qemu_riscv32_spl:
252           TEST_PY_BD: "qemu-riscv32_spl"
253           TEST_PY_TEST_SPEC: "not sleep"
254         qemu_riscv64_spl:
255           TEST_PY_BD: "qemu-riscv64_spl"
256           TEST_PY_TEST_SPEC: "not sleep"
257         qemu_x86:
258           TEST_PY_BD: "qemu-x86"
259           TEST_PY_TEST_SPEC: "not sleep"
260         qemu_x86_64:
261           TEST_PY_BD: "qemu-x86_64"
262           TEST_PY_TEST_SPEC: "not sleep"
263         xilinx_zynq_virt:
264           TEST_PY_BD: "xilinx_zynq_virt"
265           TEST_PY_ID: "--id qemu"
266           TEST_PY_TEST_SPEC: "not sleep"
267         xilinx_versal_virt:
268           TEST_PY_BD: "xilinx_versal_virt"
269           TEST_PY_ID: "--id qemu"
270           TEST_PY_TEST_SPEC: "not sleep"
271         xtfpga:
272           TEST_PY_BD: "xtfpga"
273           TEST_PY_ID: "--id qemu"
274           TEST_PY_TEST_SPEC: "not sleep"
275     steps:
276       - script: |
277           cat << EOF > test.sh
278           set -ex
279           # make environment variables available as tests are running inside a container
280           export WORK_DIR="${WORK_DIR}"
281           export TEST_PY_BD="${TEST_PY_BD}"
282           export TEST_PY_ID="${TEST_PY_ID}"
283           export TEST_PY_TEST_SPEC="${TEST_PY_TEST_SPEC}"
284           export OVERRIDE="${OVERRIDE}"
285           EOF
286           cat << "EOF" >> test.sh
287           # the below corresponds to .gitlab-ci.yml "before_script"
288           cd ${WORK_DIR}
289           git clone --depth=1 git://github.com/swarren/uboot-test-hooks.git /tmp/uboot-test-hooks
290           ln -s travis-ci /tmp/uboot-test-hooks/bin/`hostname`
291           ln -s travis-ci /tmp/uboot-test-hooks/py/`hostname`
292           grub-mkimage --prefix=\"\" -o ~/grub_x86.efi -O i386-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
293           grub-mkimage --prefix=\"\" -o ~/grub_x64.efi -O x86_64-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
294           if [[ "${TEST_PY_BD}" == "qemu-riscv32_spl" ]]; then
295               wget -O - https://github.com/riscv/opensbi/releases/download/v0.8/opensbi-0.8-rv-bin.tar.xz | tar -C /tmp -xJ;
296               export OPENSBI=/tmp/opensbi-0.8-rv-bin/share/opensbi/ilp32/generic/firmware/fw_dynamic.bin;
297           fi
298           if [[ "${TEST_PY_BD}" == "qemu-riscv64_spl" ]]; then
299               wget -O - https://github.com/riscv/opensbi/releases/download/v0.8/opensbi-0.8-rv-bin.tar.xz | tar -C /tmp -xJ;
300               export OPENSBI=/tmp/opensbi-0.8-rv-bin/share/opensbi/lp64/generic/firmware/fw_dynamic.bin;
301           fi
302           # the below corresponds to .gitlab-ci.yml "script"
303           cd ${WORK_DIR}
304           export UBOOT_TRAVIS_BUILD_DIR=/tmp/${TEST_PY_BD};
305           tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W -e --board ${TEST_PY_BD} ${OVERRIDE}
306           cp ~/grub_x86.efi ${UBOOT_TRAVIS_BUILD_DIR}/
307           cp ~/grub_x64.efi ${UBOOT_TRAVIS_BUILD_DIR}/
308           cp /opt/grub/grubriscv64.efi ${UBOOT_TRAVIS_BUILD_DIR}/grub_riscv64.efi
309           cp /opt/grub/grubriscv32.efi ${UBOOT_TRAVIS_BUILD_DIR}/grub_riscv32.efi
310           cp /opt/grub/grubaa64.efi ${UBOOT_TRAVIS_BUILD_DIR}/grub_arm64.efi
311           cp /opt/grub/grubarm.efi ${UBOOT_TRAVIS_BUILD_DIR}/grub_arm.efi
312           virtualenv -p /usr/bin/python3 /tmp/venv
313           . /tmp/venv/bin/activate
314           pip install -r test/py/requirements.txt
315           export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH};
316           export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
317           # "${var:+"-k $var"}" expands to "" if $var is empty, "-k $var" if not
318           ./test/py/test.py -ra --bd ${TEST_PY_BD} ${TEST_PY_ID} ${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"} --build-dir "$UBOOT_TRAVIS_BUILD_DIR";
319           # the below corresponds to .gitlab-ci.yml "after_script"
320           rm -rf /tmp/uboot-test-hooks /tmp/venv
321           EOF
322           cat test.sh
323           # make current directory writeable to uboot user inside the container
324           # as sandbox testing need create files like spi flash images, etc.
325           # (TODO: clean up this in the future)
326           chmod 777 .
327           docker run -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash $(work_dir)/test.sh
328
329   - job: build_the_world
330     displayName: 'Build the World'
331     pool:
332       vmImage: $(ubuntu_vm)
333     strategy:
334       # Use almost the same target division in .travis.yml, only merged
335       # 4 small build jobs (arc/microblaze/nds32/xtensa) into one.
336       matrix:
337         arc_microblaze_nds32_xtensa:
338           BUILDMAN: "arc microblaze nds32 xtensa"
339         arm11_arm7_arm920t_arm946es:
340           BUILDMAN: "arm11 arm7 arm920t arm946es"
341         arm926ejs:
342           BUILDMAN: "arm926ejs -x freescale,siemens,at91,kirkwood,spear,omap"
343         at91_non_armv7:
344           BUILDMAN: "at91 -x armv7"
345         at91_non_arm926ejs:
346           BUILDMAN: "at91 -x arm926ejs"
347         boundary_engicam_toradex:
348           BUILDMAN: "boundary engicam toradex"
349         arm_bcm:
350           BUILDMAN: "bcm -x mips"
351         nxp_arm32:
352           BUILDMAN: "freescale -x powerpc,m68k,aarch64,ls101,ls102,ls104,ls108,ls20,lx216"
353         nxp_ls101x:
354           BUILDMAN: "freescale&ls101"
355         nxp_ls102x:
356           BUILDMAN: "freescale&ls102"
357         nxp_ls104x:
358           BUILDMAN: "freescale&ls104"
359         nxp_ls108x:
360           BUILDMAN: "freescale&ls108"
361         nxp_ls20xx:
362           BUILDMAN: "freescale&ls20"
363         nxp_lx216x:
364           BUILDMAN: "freescale&lx216"
365         imx6:
366           BUILDMAN: "mx6 -x boundary,engicam,freescale,technexion,toradex"
367         imx:
368           BUILDMAN: "mx -x mx6,freescale,technexion,toradex"
369         keystone2_keystone3:
370           BUILDMAN: "k2 k3"
371         samsung_socfpga:
372           BUILDMAN: "samsung socfpga"
373         spear:
374           BUILDMAN: "spear"
375         sun4i:
376           BUILDMAN: "sun4i"
377         sun5i:
378           BUILDMAN: "sun5i"
379         sun6i:
380           BUILDMAN: "sun6i"
381         sun7i:
382           BUILDMAN: "sun7i"
383         sun8i_32bit:
384           BUILDMAN: "sun8i&armv7"
385         sun8i_64bit:
386           BUILDMAN: "sun8i&aarch64"
387         sun9i:
388           BUILDMAN: "sun9i"
389         sun50i:
390           BUILDMAN: "sun50i"
391         arm_catch_all:
392           BUILDMAN: "arm -x arm11,arm7,arm9,aarch64,at91,bcm,freescale,kirkwood,mvebu,siemens,tegra,uniphier,mx,samsung,sunxi,am33xx,omap,rk,toradex,socfpga,k2,k3,zynq"
393         sandbox_x86:
394           BUILDMAN: "sandbox x86"
395         technexion:
396           BUILDMAN: "technexion"
397         kirkwood:
398           BUILDMAN: "kirkwood"
399         mvebu:
400           BUILDMAN: "mvebu"
401         m68k:
402           BUILDMAN: "m68k"
403         mips:
404           BUILDMAN: "mips"
405         non_fsl_ppc:
406           BUILDMAN: "powerpc -x freescale"
407         mpc85xx_freescale:
408           BUILDMAN: "mpc85xx&freescale -x t208xrdb -x t4qds -x t102* -x p1_p2_rdb_pc -x p1010rdb -x corenet_ds -x b4860qds -x bsc91*"
409         t208xrdb_corenet_ds:
410           BUILDMAN: "t208xrdb corenet_ds"
411         fsl_ppc:
412           BUILDMAN: "t4qds b4860qds mpc83xx&freescale mpc86xx&freescale"
413         t102x:
414           BUILDMAN: "t102*"
415         p1_p2_rdb_pc:
416           BUILDMAN: "p1_p2_rdb_pc"
417         p1010rdb_bsc91:
418           BUILDMAN: "p1010rdb bsc91"
419         siemens:
420           BUILDMAN: "siemens"
421         tegra:
422           BUILDMAN: "tegra -x toradex"
423         am33xx_no_siemens:
424           BUILDMAN: "am33xx -x siemens"
425         omap:
426           BUILDMAN: "omap"
427         uniphier:
428           BUILDMAN: "uniphier"
429         aarch64_catch_all:
430           BUILDMAN: "aarch64 -x bcm,k3,tegra,ls1,ls2,lx216,mvebu,uniphier,sunxi,samsung,socfpga,rk,versal,zynq"
431         rockchip:
432           BUILDMAN: "rk"
433         sh:
434           BUILDMAN: "sh -x arm"
435         zynq:
436           BUILDMAN: "zynq&armv7"
437         zynqmp_versal:
438           BUILDMAN: "versal|zynqmp&aarch64"
439         riscv:
440           BUILDMAN: "riscv"
441     steps:
442       - script: |
443           cat << EOF > build.sh
444           set -ex
445           cd ${WORK_DIR}
446           # make environment variables available as tests are running inside a container
447           export BUILDMAN="${BUILDMAN}"
448           EOF
449           cat << "EOF" >> build.sh
450           if [[ "${BUILDMAN}" != "" ]]; then
451               ret=0;
452               tools/buildman/buildman -o /tmp -P -W ${BUILDMAN} ${OVERRIDE} || ret=$?;
453               if [[ $ret -ne 0 ]]; then
454                   tools/buildman/buildman -o /tmp -seP ${BUILDMAN};
455                   exit $ret;
456               fi;
457           fi
458           EOF
459           cat build.sh
460           docker run -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash $(work_dir)/build.sh