gitlab-ci: Add pyelftools when needed
[oweals/u-boot.git] / .gitlab-ci.yml
1 # SPDX-License-Identifier: GPL-2.0+
2
3 # Grab our configured image.  The source for this is found at:
4 # https://gitlab.denx.de/u-boot/gitlab-ci-runner
5 image: trini/u-boot-gitlab-ci-runner:xenial-20190222-24April2019
6
7 # We run some tests in different order, to catch some failures quicker.
8 stages:
9   - test.py
10   - testsuites
11   - world build
12
13 .buildman_and_testpy_template: &buildman_and_testpy_dfn
14   tags: [ 'all' ]
15   stage: test.py
16   before_script:
17     # Clone uboot-test-hooks
18     - git clone --depth=1 git://github.com/swarren/uboot-test-hooks.git /tmp/uboot-test-hooks
19     - ln -s travis-ci /tmp/uboot-test-hooks/bin/`hostname`
20     - ln -s travis-ci /tmp/uboot-test-hooks/py/`hostname`
21     - virtualenv /tmp/venv
22     - . /tmp/venv/bin/activate
23     - pip install pytest==2.8.7
24     - pip install python-subunit
25     - pip install pyelftools
26     - grub-mkimage -o ~/grub_x86.efi -O i386-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
27     - grub-mkimage -o ~/grub_x64.efi -O x86_64-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
28     - mkdir ~/grub2-arm
29     - ( cd ~/grub2-arm; wget -O - http://download.opensuse.org/ports/armv7hl/distribution/leap/42.2/repo/oss/suse/armv7hl/grub2-arm-efi-2.02~beta2-87.1.armv7hl.rpm | rpm2cpio | cpio -di )
30     - mkdir ~/grub2-arm64
31     - ( cd ~/grub2-arm64; wget -O - http://download.opensuse.org/ports/aarch64/distribution/leap/42.2/repo/oss/suse/aarch64/grub2-arm64-efi-2.02~beta2-87.1.aarch64.rpm | rpm2cpio | cpio -di )
32     - if [[ "${QEMU_TARGET}" != "" ]]; then
33         git clone git://git.qemu.org/qemu.git /tmp/qemu;
34         pushd /tmp/qemu;
35         git submodule update --init dtc &&
36         git checkout ${QEMU_VERSION} &&
37         ./configure --prefix=/tmp/qemu-install --target-list=${QEMU_TARGET} &&
38         make -j$(nproc) all install;
39         popd;
40       fi
41   after_script:
42     - rm -rf ~/grub2* /tmp/uboot-test-hooks /tmp/qemu /tmp/venv
43   script:
44     # From buildman, exit code 129 means warnings only.  If we've been asked to
45     # use clang only do one configuration.
46     - if [[ "${BUILDMAN}" != "" ]]; then
47         ret=0;
48         tools/buildman/buildman -P -E ${BUILDMAN} ${OVERRIDE}|| ret=$?;
49         if [[ $ret -ne 0 && $ret -ne 129 ]]; then
50           tools/buildman/buildman -sdeP ${BUILDMAN};
51           exit $ret;
52         fi;
53       fi
54     # "not a_test_which_does_not_exist" is a dummy -k parameter which will
55     # never prevent any test from running. That way, we can always pass
56     # "-k something" even when $TEST_PY_TEST_SPEC doesnt need a custom
57     # value.
58     - export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/.bm-work/${TEST_PY_BD};
59       export PATH=/tmp/qemu-install/bin:/tmp/uboot-test-hooks/bin:/usr/bin:/bin;
60       export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
61       if [[ "${TEST_PY_BD}" != "" ]]; then
62         ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID}
63           -k "${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}"
64           --build-dir "$UBOOT_TRAVIS_BUILD_DIR";
65         ret=$?;
66         if [[ $ret -ne 0 ]]; then
67           exit $ret;
68         fi;
69       fi;
70
71 build all plaforms:
72   tags: [ 'all' ]
73   stage: world build
74   script:
75     - ret=0;
76      ./tools/buildman/buildman -P -E || ret=$?;
77      if [[ $ret -ne 0 && $ret -ne 129 ]]; then
78        ./tools/buildman/buildman -sdeP;
79        exit $ret;
80      fi;
81
82 # QA jobs for code analytics
83 # static code analysis with cppcheck (we can add --enable=all later)
84 cppcheck:
85   tags: [ 'all' ]
86   stage: testsuites
87   script:
88     - cppcheck --force --quiet --inline-suppr .
89
90 # search for TODO within source tree
91 grep TODO/FIXME/HACK:
92   tags: [ 'all' ]
93   stage: testsuites
94   script:
95     - grep -r TODO .
96     - grep -r FIXME .
97     # search for HACK within source tree and ignore HACKKIT board
98     - grep -r HACK . | grep -v HACKKIT
99
100 # some statistics about the code base
101 sloccount:
102   tags: [ 'all' ]
103   stage: testsuites
104   script:
105     - sloccount .
106
107 # ensure all configs have MAINTAINERS entries
108 Check for configs without MAINTAINERS entry:
109   tags: [ 'all' ]
110   stage: testsuites
111   script:
112     - if [ `./tools/genboardscfg.py -f 2>&1 | wc -l` -ne 0 ]; then exit 1; fi
113
114 # Ensure host tools build
115 Build tools-only:
116   tags: [ 'all' ]
117   stage: testsuites
118   script:
119     - make tools-only_config tools-only -j$(nproc)
120
121 # Run various tool tests
122 Run patman testsuite:
123   tags: [ 'all' ]
124   stage: testsuites
125   script:
126     - git config --global user.name "GitLab CI Runner"
127     - git config --global user.email trini@konsulko.com
128     - ./tools/patman/patman --test
129
130 Run buildman testsuite:
131   tags: [ 'all' ]
132   stage: testsuites
133   script:
134     - ./tools/buildman/buildman -t
135
136 Run binman and dtoc testsuite:
137   tags: [ 'all' ]
138   stage: testsuites
139   script:
140     - export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/.bm-work/sandbox_spl;
141       ./tools/buildman/buildman -P sandbox_spl && 
142      export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
143      export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
144      ./tools/binman/binman -t &&
145      ./tools/dtoc/dtoc -t
146
147 # Test sandbox with test.py
148 sandbox test.py:
149   tags: [ 'all' ]
150   variables:
151     TEST_PY_BD: "sandbox"
152     BUILDMAN: "^sandbox$"
153   <<: *buildman_and_testpy_dfn
154
155 sandbox_spl test.py:
156   tags: [ 'all' ]
157   variables:
158     TEST_PY_BD: "sandbox_spl"
159     BUILDMAN: "^sandbox_spl$"
160     TEST_PY_TEST_SPEC: "test_ofplatdata"
161   <<: *buildman_and_testpy_dfn
162
163 evb-ast2500 test.py:
164   tags: [ 'all' ]
165   variables:
166     TEST_PY_BD: "evb-ast2500"
167     TEST_PY_ID: "--id qemu"
168     QEMU_TARGET: "arm-softmmu"
169     QEMU_VERSION: "506179e42112be77bfd071f050b15762d3b2cd43"
170     BUILDMAN: "^evb-ast2500$"
171   <<: *buildman_and_testpy_dfn
172
173 sandbox_flattree test.py:
174   tags: [ 'all' ]
175   variables:
176     TEST_PY_BD: "sandbox_flattree"
177     BUILDMAN: "^sandbox_flattree$"
178   <<: *buildman_and_testpy_dfn
179
180 vexpress_ca15_tc2 test.py:
181   tags: [ 'all' ]
182   variables:
183     TEST_PY_BD: "vexpress_ca15_tc2"
184     TEST_PY_ID: "--id qemu"
185     QEMU_TARGET: "arm-softmmu"
186     QEMU_VERSION: "v3.0.0"
187     BUILDMAN: "^vexpress_ca15_tc2$"
188   <<: *buildman_and_testpy_dfn
189
190 vexpress_ca9x4 test.py:
191   tags: [ 'all' ]
192   variables:
193     TEST_PY_BD: "vexpress_ca9x4"
194     TEST_PY_ID: "--id qemu"
195     QEMU_TARGET: "arm-softmmu"
196     BUILDMAN: "^vexpress_ca9x4$"
197   <<: *buildman_and_testpy_dfn
198
199 integratorcp_cm926ejs test.py:
200   tags: [ 'all' ]
201   variables:
202     TEST_PY_BD: "integratorcp_cm926ejs"
203     TEST_PY_TEST_SPEC: "not sleep"
204     TEST_PY_ID: "--id qemu"
205     QEMU_TARGET: "arm-softmmu"
206     BUILDMAN: "^integratorcp_cm926ejs$"
207   <<: *buildman_and_testpy_dfn
208
209 qemu_arm test.py:
210   tags: [ 'all' ]
211   variables:
212     TEST_PY_BD: "qemu_arm"
213     TEST_PY_TEST_SPEC: "not sleep"
214     QEMU_TARGET: "arm-softmmu"
215     BUILDMAN: "^qemu_arm$"
216   <<: *buildman_and_testpy_dfn
217
218 qemu_arm64 test.py:
219   tags: [ 'all' ]
220   variables:
221     TEST_PY_BD: "qemu_arm64"
222     TEST_PY_TEST_SPEC: "not sleep"
223     QEMU_TARGET: "aarch64-softmmu"
224     BUILDMAN: "^qemu_arm64$"
225   <<: *buildman_and_testpy_dfn
226
227 qemu_mips test.py:
228   tags: [ 'all' ]
229   variables:
230     TEST_PY_BD: "qemu_mips"
231     TEST_PY_TEST_SPEC: "not sleep"
232     QEMU_TARGET: "mips-softmmu"
233     BUILDMAN: "^qemu_mips$"
234     TOOLCHAIN: "mips"
235   <<: *buildman_and_testpy_dfn
236
237 qemu_mipsel test.py:
238   tags: [ 'all' ]
239   variables:
240     TEST_PY_BD: "qemu_mipsel"
241     TEST_PY_TEST_SPEC: "not sleep"
242     QEMU_TARGET: "mipsel-softmmu"
243     BUILDMAN: "^qemu_mipsel$"
244     TOOLCHAIN: "mips"
245   <<: *buildman_and_testpy_dfn
246
247 qemu_mips64 test.py:
248   tags: [ 'all' ]
249   variables:
250     TEST_PY_BD: "qemu_mips64"
251     TEST_PY_TEST_SPEC: "not sleep"
252     QEMU_TARGET: "mips64-softmmu"
253     BUILDMAN: "^qemu_mips64$"
254     TOOLCHAIN: "mips"
255   <<: *buildman_and_testpy_dfn
256
257 qemu_mips64el test.py:
258   tags: [ 'all' ]
259   variables:
260     TEST_PY_BD: "qemu_mips64el"
261     TEST_PY_TEST_SPEC: "not sleep"
262     QEMU_TARGET: "mips64el-softmmu"
263     BUILDMAN: "^qemu_mips64el$"
264     TOOLCHAIN: "mips"
265   <<: *buildman_and_testpy_dfn
266
267 qemu-ppce500 test.py:
268   tags: [ 'all' ]
269   variables:
270     TEST_PY_BD: "qemu-ppce500"
271     TEST_PY_TEST_SPEC: "not sleep"
272     QEMU_TARGET: "ppc-softmmu"
273     BUILDMAN: "^qemu-ppce500$"
274     TOOLCHAIN: "powerpc"
275   <<: *buildman_and_testpy_dfn
276
277 qemu-x86 test.py:
278   tags: [ 'all' ]
279   variables:
280     TEST_PY_BD: "qemu-x86"
281     TEST_PY_TEST_SPEC: "not sleep"
282     QEMU_TARGET: "i386-softmmu"
283     BUILDMAN: "^qemu-x86$"
284     TOOLCHAIN: "i386"
285   <<: *buildman_and_testpy_dfn
286
287 qemu-x86_64 test.py:
288   tags: [ 'all' ]
289   variables:
290     TEST_PY_BD: "qemu-x86_64"
291     TEST_PY_TEST_SPEC: "not sleep"
292     QEMU_TARGET: "x86_64-softmmu"
293     BUILDMAN: "^qemu-x86_64$"
294     TOOLCHAIN: "i386"
295   <<: *buildman_and_testpy_dfn
296
297 zynq_zc702 test.py:
298   tags: [ 'all' ]
299   variables:
300     TEST_PY_BD: "zynq_zc702"
301     TEST_PY_TEST_SPEC: "not sleep"
302     QEMU_TARGET: "arm-softmmu"
303     TEST_PY_ID: "--id qemu"
304     BUILDMAN: "^zynq_zc702$"
305   <<: *buildman_and_testpy_dfn
306
307 xilinx_versal_virt test.py:
308   tags: [ 'all' ]
309   variables:
310     TEST_PY_BD: "xilinx_versal_virt"
311     TEST_PY_TEST_SPEC: "not sleep"
312     QEMU_TARGET: "aarch64-softmmu"
313     TEST_PY_ID: "--id qemu"
314     BUILDMAN: "^xilinx_versal_virt$"
315   <<: *buildman_and_testpy_dfn
316
317 xtfpga test.py:
318   tags: [ 'all' ]
319   variables:
320     TEST_PY_BD: "xtfpga"
321     TEST_PY_TEST_SPEC: "not sleep"
322     QEMU_TARGET: "xtensa-softmmu"
323     TEST_PY_ID: "--id qemu"
324     BUILDMAN: "^xtfpga$"
325     TOOLCHAIN: "xtensa-dc233c-elf"
326   <<: *buildman_and_testpy_dfn