e82b7e0045aa812ea99d8dd396819f90ddd77368
[platform/upstream/mesa.git] / .gitlab-ci / test / gitlab-ci.yml
1 .test:
2   # Cancel job if a newer commit is pushed to the same branch
3   interruptible: true
4   variables:
5     GIT_STRATEGY: none # testing doesn't build anything from source
6   before_script:
7     - !reference [default, before_script]
8     # Note: Build dir (and thus install) may be dirty due to GIT_STRATEGY
9     - rm -rf install
10     - tar -xf artifacts/install.tar
11     - echo -e "\e[0Ksection_start:$(date +%s):ldd_section[collapsed=true]\r\e[0KChecking ldd on driver build"
12     - LD_LIBRARY_PATH=install/lib find install/lib -name "*.so" -print -exec ldd {} \;
13     - echo -e "\e[0Ksection_end:$(date +%s):ldd_section\r\e[0K"
14   artifacts:
15     when: always
16     name: "mesa_${CI_JOB_NAME}"
17     paths:
18       - results/
19
20 rustfmt:
21   # Cancel job if a newer commit is pushed to the same branch
22   interruptible: true
23   stage: lint
24   extends:
25     - .use-debian/x86_build
26     - .lint-rustfmt-rules
27   variables:
28     GIT_STRATEGY: fetch
29   script:
30     - git ls-files */{lib,app}.rs | xargs rustfmt --check
31
32 .test-gl:
33   extends:
34     - .test
35     - .use-debian/x86_test-gl
36   needs:
37     - debian/x86_test-gl
38     - debian-testing
39
40 .test-vk:
41   extends:
42     - .test
43     - .use-debian/x86_test-vk
44   needs:
45     - debian-testing
46     - debian/x86_test-vk
47
48 .test-cl:
49   extends:
50     - .test
51     - .use-debian/x86_test-gl
52   needs:
53     - debian/x86_test-gl
54
55 .vkd3d-proton-test:
56   artifacts:
57     when: on_failure
58     name: "mesa_${CI_JOB_NAME}"
59     paths:
60       - results/vkd3d-proton.log
61   script:
62     - ./install/vkd3d-proton/run.sh
63
64 .piglit-test:
65   artifacts:
66     name: "mesa_${CI_JOB_NAME}"
67     paths:
68       - results
69     reports:
70       junit: results/junit.xml
71   variables:
72     PIGLIT_NO_WINDOW: 1
73     HWCI_TEST_SCRIPT: "/install/piglit/piglit-runner.sh"
74   script:
75     - install/piglit/piglit-runner.sh
76
77 .piglit-traces-test:
78   extends:
79     - .piglit-test
80   artifacts:
81     when: on_failure
82     name: "mesa_${CI_JOB_NAME}"
83     reports:
84       junit: results/junit.xml
85     paths:
86       - results/
87     exclude:
88       - results/*.shader_cache
89   variables:
90     PIGLIT_REPLAY_EXTRA_ARGS: --keep-image --db-path ${CI_PROJECT_DIR}/replayer-db/ --minio_bucket=mesa-tracie-public --jwt-file=${CI_JOB_JWT_FILE}
91   script:
92     - echo -e "\e[0Ksection_start:$(date +%s):variables[collapsed=true]\r\e[0KVariables passed through:"
93     - install/common/generate-env.sh
94     - echo -e "\e[0Ksection_end:$(date +%s):variables\r\e[0K"
95     - install/piglit/piglit-traces.sh
96
97 .deqp-test:
98   script:
99     - ./install/deqp-runner.sh
100   artifacts:
101     exclude:
102       - results/*.shader_cache
103     reports:
104       junit: results/junit.xml
105
106 .deqp-test-vk:
107   extends:
108     - .deqp-test
109   variables:
110     DEQP_VER: vk
111
112 .skqp-test:
113   variables:
114     HWCI_START_XORG: 1
115     HWCI_TEST_SCRIPT: "/install/skqp-runner.sh"
116
117 .fossilize-test:
118   script:
119     - ./install/fossilize-runner.sh
120   artifacts:
121     when: on_failure
122     name: "mesa_${CI_JOB_NAME}"
123     paths:
124       - results/
125
126 .baremetal-test:
127   extends:
128     - .test
129   # Cancel job if a newer commit is pushed to the same branch
130   interruptible: true
131   before_script:
132     - !reference [default, before_script]
133     # Use this instead of gitlab's artifacts download because it hits packet.net
134     # instead of fd.o.  Set FDO_HTTP_CACHE_URI to an http cache for your test lab to
135     # improve it even more (see https://docs.mesa3d.org/ci/bare-metal.html for
136     # setup).
137     - echo -e "\e[0Ksection_start:$(date +%s):artifacts_download[collapsed=true]\r\e[0KDownloading artifacts from minio"
138     - wget ${FDO_HTTP_CACHE_URI:-}https://${PIPELINE_ARTIFACTS_BASE}/${MINIO_ARTIFACT_NAME}.tar.zst -S --progress=dot:giga -O- | tar --zstd -x
139     - echo -e "\e[0Ksection_end:$(date +%s):artifacts_download\r\e[0K"
140   artifacts:
141     when: always
142     name: "mesa_${CI_JOB_NAME}"
143     paths:
144       - results/
145       - serial*.txt
146     exclude:
147       - results/*.shader_cache
148     reports:
149       junit: results/junit.xml
150
151 # ARM testing of bare-metal boards attached to an x86 gitlab-runner system
152 .baremetal-test-armhf:
153   extends:
154     - .baremetal-test
155     - .use-debian/arm_test
156   variables:
157     BM_ROOTFS: /rootfs-armhf
158     MINIO_ARTIFACT_NAME: mesa-armhf
159   needs:
160     - debian/arm_test
161     - job: debian-armhf
162       artifacts: false
163
164 # ARM64 testing of bare-metal boards attached to an x86 gitlab-runner system
165 .baremetal-test-arm64:
166   extends:
167     - .baremetal-test
168     - .use-debian/arm_test
169   variables:
170     BM_ROOTFS: /rootfs-arm64
171     MINIO_ARTIFACT_NAME: mesa-arm64
172   needs:
173     - debian/arm_test
174     - job: debian-arm64
175       artifacts: false
176
177 # ARM64 testing of bare-metal boards attached to an x86 gitlab-runner system, using an asan mesa build
178 .baremetal-arm64-asan-test:
179   extends:
180     - .baremetal-test
181     - .use-debian/arm_test
182   variables:
183     DEQP_RUNNER_OPTIONS: "--env LD_PRELOAD=libasan.so.6:/install/lib/libdlclose-skip.so"
184     MINIO_ARTIFACT_NAME: mesa-arm64-asan
185   needs:
186     - debian/arm_test
187     - job: debian-arm64-asan
188       artifacts: false
189
190 .baremetal-deqp-test:
191   variables:
192     HWCI_TEST_SCRIPT: "/install/deqp-runner.sh"
193     FDO_CI_CONCURRENT: 0 # Default to number of CPUs
194
195 # For Valve's bare-metal testing farm jobs.
196 .b2c-test:
197   # It would be nice to use ci-templates within Mesa CI for this job's
198   # image:, but the integration is not possible for the current
199   # use-case. Within this job, two containers are managed. 1) the
200   # gitlab runner container from which the job is submitted to the
201   # DUT, and 2) the test container (e.g. debian/x86_test-vk) within
202   # which the test cases will run on the DUT. Since ci-templates and
203   # the associated image setting macros in this file rely on variables
204   # like FDO_DISTRIBUTION_TAG for *the* image, there is no way to
205   # depend on more than one image per job. So, the job container is
206   # built as part of the CI in the boot2container project.
207   image: registry.freedesktop.org/mupuf/valve-infra/mesa-trigger:2022-03-03.2
208   timeout: 1h 40m
209   variables:
210     # No need by default to pull the whole repo
211     GIT_STRATEGY: none
212     # boot2container initrd configuration parameters.
213     B2C_KERNEL_URL: 'https://gitlab.freedesktop.org/mupuf/valve-infra/-/package_files/144/download'  # 5.17.1
214     B2C_INITRAMFS_URL: 'https://gitlab.freedesktop.org/mupuf/boot2container/-/releases/v0.9.8/downloads/initramfs.linux_amd64.cpio.xz'
215     B2C_JOB_SUCCESS_REGEX: '\[.*\]: Execution is over, pipeline status: 0\r$'
216     B2C_JOB_WARN_REGEX: '\*ERROR\* ring .* timeout, but soft recovered'
217     B2C_LOG_LEVEL: 6
218     B2C_POWEROFF_DELAY: 15
219     B2C_SESSION_END_REGEX: '^.*It''s now safe to turn off your computer\r$'
220     B2C_SESSION_REBOOT_REGEX: '(GPU hang detected!|\*ERROR\* ring [^\s]+ timeout(?!, but soft recovered)|The CS has been cancelled because the context is lost)'
221     B2C_TIMEOUT_BOOT_MINUTES: 45
222     B2C_TIMEOUT_BOOT_RETRIES: 1
223     B2C_TIMEOUT_FIRST_MINUTES: 5
224     B2C_TIMEOUT_FIRST_RETRIES: 3
225     B2C_TIMEOUT_MINUTES: 2
226     B2C_TIMEOUT_OVERALL_MINUTES: 90
227     B2C_TIMEOUT_RETRIES: 0
228
229     # As noted in the top description, we make a distinction between the
230     # container used by gitlab-runner to queue the work, and the container
231     # used by the DUTs/test machines. To make this distinction quite clear,
232     # we rename the MESA_IMAGE variable into IMAGE_UNDER_TEST.
233     IMAGE_UNDER_TEST: "$MESA_IMAGE"
234
235     INSTALL_TARBALL_NAME: "install.tar"
236     INSTALL_TARBALL: "./artifacts/${INSTALL_TARBALL_NAME}"
237     CI_B2C_ARTIFACTS: "./artifacts/b2c"
238     CI_COMMON_SCRIPTS: "./artifacts/ci-common"
239     GENERATE_ENV_SCRIPT: "${CI_COMMON_SCRIPTS}/generate-env.sh"
240     B2C_JOB_TEMPLATE: "${CI_B2C_ARTIFACTS}/b2c.yml.jinja2.jinja2"
241     JOB_FOLDER: "job_folder"
242   before_script:
243     # We don't want the tarball unpacking of .test, but will take the JWT bits.
244     - !reference [default, before_script]
245     - |
246       set -x
247
248       # Useful as a hook point for runner admins. You may edit the
249       # config.toml for the Gitlab runner and use a bind-mount to
250       # populate the hook script with some executable commands. This
251       # allows quicker feedback than resubmitting pipelines and
252       # potentially having to wait for a debug build of Mesa to
253       # complete.
254       if [ -x /runner-before-script.sh ]; then
255          echo "Executing runner before-script hook..."
256          sh /runner-before-script.sh
257          if [ $? -ne 0 ]; then
258             echo "Runner hook failed, goodbye"
259             exit $?
260          fi
261       fi
262
263       [ -s "$INSTALL_TARBALL" ] || exit 1
264       [ -d "$CI_B2C_ARTIFACTS" ] || exit 1
265       [ -d "$CI_COMMON_SCRIPTS" ] || exit 1
266
267
268       B2C_TEST_SCRIPT="bash -c 'source ./set-job-env-vars.sh; tar xf ${INSTALL_TARBALL_NAME}; ${B2C_TEST_SCRIPT}'"
269
270       # The Valve CI gateway receives jobs in a YAML format. Create a
271       # job description from the CI environment.
272       python3 "$CI_B2C_ARTIFACTS"/generate_b2c.py \
273         --ci-job-id "${CI_JOB_ID}" \
274         --container-cmd "${B2C_TEST_SCRIPT}" \
275         --initramfs-url "${B2C_INITRAMFS_URL}" \
276         --job-success-regex "${B2C_JOB_SUCCESS_REGEX}" \
277         --job-warn-regex "${B2C_JOB_WARN_REGEX}" \
278         --kernel-url "${B2C_KERNEL_URL}" \
279         --log-level "${B2C_LOG_LEVEL}" \
280         --poweroff-delay "${B2C_POWEROFF_DELAY}" \
281         --session-end-regex "${B2C_SESSION_END_REGEX}" \
282         --session-reboot-regex "${B2C_SESSION_REBOOT_REGEX}" \
283         --tags "${CI_RUNNER_TAGS}" \
284         --template "${B2C_JOB_TEMPLATE}" \
285         --timeout-boot-minutes "${B2C_TIMEOUT_BOOT_MINUTES}" \
286         --timeout-boot-retries "${B2C_TIMEOUT_BOOT_RETRIES}" \
287         --timeout-first-minutes "${B2C_TIMEOUT_FIRST_MINUTES}" \
288         --timeout-first-retries "${B2C_TIMEOUT_FIRST_RETRIES}" \
289         --timeout-minutes "${B2C_TIMEOUT_MINUTES}" \
290         --timeout-overall-minutes "${B2C_TIMEOUT_OVERALL_MINUTES}" \
291         --timeout-retries "${B2C_TIMEOUT_RETRIES}" \
292         --job-volume-exclusions "${B2C_JOB_VOLUME_EXCLUSIONS}" \
293         --local-container "${IMAGE_UNDER_TEST}" \
294         ${B2C_EXTRA_VOLUME_ARGS} \
295         --working-dir "$CI_PROJECT_DIR"
296
297       cat b2c.yml.jinja2
298
299       rm -rf ${JOB_FOLDER} || true
300       mkdir -v ${JOB_FOLDER}
301       # Create a script to regenerate the CI environment when this job
302       # begins running on the remote DUT.
303       set +x
304       "$CI_COMMON_SCRIPTS"/generate-env.sh > ${JOB_FOLDER}/set-job-env-vars.sh
305       chmod +x ${JOB_FOLDER}/set-job-env-vars.sh
306       echo "Variables passed through:"
307       cat ${JOB_FOLDER}/set-job-env-vars.sh
308       echo "export CI_JOB_JWT=${CI_JOB_JWT}" >> ${JOB_FOLDER}/set-job-env-vars.sh
309       set -x
310
311       # Copy the mesa install tarball to the job folder, for later extraction
312       mv "${INSTALL_TARBALL}" "${JOB_FOLDER}"
313
314   script: |
315       slugify () {
316           echo "$1" | sed -r s/[~\^]+//g | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z
317       }
318
319       # Submit the job to Valve's CI gateway service with the CI
320       # provisioned job_folder.
321       env PYTHONUNBUFFERED=1 executorctl \
322           run -w b2c.yml.jinja2 -j $(slugify "$CI_JOB_NAME") -s ${JOB_FOLDER}
323
324       ls -l
325       # Anything our job places in results/ will be collected by the
326       # Gitlab coordinator for status presentation. results/junit.xml
327       # will be parsed by the UI for more detailed explanations of
328       # test execution.
329   artifacts:
330     when: always
331     name: "mesa_${CI_JOB_NAME}"
332     paths:
333       - ${JOB_FOLDER}/results
334     reports:
335       junit: ${JOB_FOLDER}/results/junit.xml
336
337 .b2c-test-vk:
338   extends:
339     - .use-debian/x86_test-vk
340     - .b2c-test
341   needs:
342     - debian/x86_test-vk
343     - debian-testing
344
345 .b2c-test-gl:
346   extends:
347     - .use-debian/x86_test-gl
348     - .b2c-test
349   needs:
350     - debian/x86_test-gl
351     - debian-testing