xref: /linux/drivers/gpu/drm/ci/gitlab-ci.yml (revision fb7399cf2d0b33825b8039f95c45395c7deba25c)
1variables:
2  DRM_CI_PROJECT_PATH: &drm-ci-project-path mesa/mesa
3  DRM_CI_COMMIT_SHA: &drm-ci-commit-sha f73132f1215a37ce8ffc711a0136c90649aaf128
4
5  UPSTREAM_REPO: https://gitlab.freedesktop.org/drm/kernel.git
6  TARGET_BRANCH: drm-next
7
8  IGT_VERSION: 04bedb9238586b81d4d4ca62b02e584f6cfc77af
9
10  DEQP_RUNNER_GIT_URL: https://gitlab.freedesktop.org/mesa/deqp-runner.git
11  DEQP_RUNNER_GIT_TAG: v0.20.0
12
13  FDO_UPSTREAM_REPO: helen.fornazier/linux   # The repo where the git-archive daily runs
14  MESA_TEMPLATES_COMMIT: &ci-templates-commit d5aa3941aa03c2f716595116354fb81eb8012acb
15  DRM_CI_PROJECT_URL: https://gitlab.freedesktop.org/${DRM_CI_PROJECT_PATH}
16  CI_PRE_CLONE_SCRIPT: |-
17          set -o xtrace
18          curl -L --retry 4 -f --retry-all-errors --retry-delay 60 -s ${DRM_CI_PROJECT_URL}/-/raw/${DRM_CI_COMMIT_SHA}/.gitlab-ci/download-git-cache.sh -o download-git-cache.sh
19          bash download-git-cache.sh
20          rm download-git-cache.sh
21          set +o xtrace
22  S3_JWT_FILE: /s3_jwt
23  S3_JWT_HEADER_FILE: /s3_jwt_header
24  S3_JWT_FILE_SCRIPT: |-
25      echo -n '${S3_JWT}' > '${S3_JWT_FILE}' &&
26      echo -n "Authorization: Bearer ${S3_JWT}" > '${S3_JWT_HEADER_FILE}' &&
27      unset CI_JOB_JWT S3_JWT  # Unsetting vulnerable env variables
28  S3_HOST: s3.freedesktop.org
29  # This bucket is used to fetch the kernel image
30  S3_KERNEL_BUCKET: mesa-rootfs
31  # Bucket for git cache
32  S3_GITCACHE_BUCKET: git-cache
33  # Bucket for the pipeline artifacts pushed to S3
34  S3_ARTIFACTS_BUCKET: artifacts
35  # per-pipeline artifact storage on MinIO
36  PIPELINE_ARTIFACTS_BASE: ${S3_HOST}/${S3_ARTIFACTS_BUCKET}/${CI_PROJECT_PATH}/${CI_PIPELINE_ID}
37  # per-job artifact storage on MinIO
38  JOB_ARTIFACTS_BASE: ${PIPELINE_ARTIFACTS_BASE}/${CI_JOB_ID}
39  KERNEL_IMAGE_BASE: https://${S3_HOST}/${S3_KERNEL_BUCKET}/${KERNEL_REPO}/${KERNEL_TAG}
40  LAVA_TAGS: subset-1-gfx
41  LAVA_JOB_PRIORITY: 30
42  ARTIFACTS_BASE_URL: https://${CI_PROJECT_ROOT_NAMESPACE}.${CI_PAGES_DOMAIN}/-/${CI_PROJECT_NAME}/-/jobs/${CI_JOB_ID}/artifacts
43  # Python scripts for structured logger
44  PYTHONPATH: "$PYTHONPATH:$CI_PROJECT_DIR/install"
45
46
47default:
48  id_tokens:
49    S3_JWT:
50      aud: https://s3.freedesktop.org
51  before_script:
52    - export SCRIPTS_DIR=$(mktemp -d)
53    - curl -L -s --retry 4 -f --retry-all-errors --retry-delay 60 -O --output-dir "${SCRIPTS_DIR}" "${DRM_CI_PROJECT_URL}/-/raw/${DRM_CI_COMMIT_SHA}/.gitlab-ci/setup-test-env.sh"
54    - source ${SCRIPTS_DIR}/setup-test-env.sh
55    - eval "$S3_JWT_FILE_SCRIPT"
56
57    - echo -e "\e[0Ksection_start:$(date +%s):drm_ci_download_section[collapsed=true]\r\e[0KDownloading mesa from $DRM_CI_PROJECT_URL/-/archive/$DRM_CI_COMMIT_SHA/mesa-$DRM_CI_COMMIT_SHA.tar.gz"
58    - cd $CI_PROJECT_DIR
59    - curl --output - $DRM_CI_PROJECT_URL/-/archive/$DRM_CI_COMMIT_SHA/mesa-$DRM_CI_COMMIT_SHA.tar.gz | tar -xz
60    - mv mesa-$DRM_CI_COMMIT_SHA/.gitlab-ci* .
61    - mv mesa-$DRM_CI_COMMIT_SHA/bin .
62    - rm -rf mesa-$DRM_CI_COMMIT_SHA/
63    - echo -e "\e[0Ksection_end:$(date +%s):drm_ci_download_section\r\e[0K"
64
65  after_script:
66    - >
67      set +x
68
69      test -e "${S3_JWT_FILE}" &&
70      export S3_JWT="$(<${S3_JWT_FILE})" &&
71      rm "${S3_JWT_FILE}"
72
73
74include:
75  - project: 'freedesktop/ci-templates'
76    ref: 16bc29078de5e0a067ff84a1a199a3760d3b3811
77    file:
78      - '/templates/ci-fairy.yml'
79  - project: 'freedesktop/ci-templates'
80    ref: *ci-templates-commit
81    file:
82      - '/templates/alpine.yml'
83      - '/templates/debian.yml'
84      - '/templates/fedora.yml'
85  - project: *drm-ci-project-path
86    ref: *drm-ci-commit-sha
87    file:
88      - '/.gitlab-ci/build/gitlab-ci.yml'
89      - '/.gitlab-ci/container/gitlab-ci.yml'
90      - '/.gitlab-ci/farm-rules.yml'
91      - '/.gitlab-ci/lava/lava-gitlab-ci.yml'
92      - '/.gitlab-ci/test-source-dep.yml'
93      - '/.gitlab-ci/test/gitlab-ci.yml'
94      - '/src/amd/ci/gitlab-ci-inc.yml'
95      - '/src/freedreno/ci/gitlab-ci-inc.yml'
96      - '/src/gallium/drivers/crocus/ci/gitlab-ci-inc.yml'
97      - '/src/gallium/drivers/llvmpipe/ci/gitlab-ci-inc.yml'
98      - '/src/gallium/drivers/nouveau/ci/gitlab-ci-inc.yml'
99      - '/src/gallium/drivers/softpipe/ci/gitlab-ci-inc.yml'
100      - '/src/gallium/drivers/virgl/ci/gitlab-ci-inc.yml'
101      - '/src/gallium/drivers/zink/ci/gitlab-ci-inc.yml'
102      - '/src/gallium/frontends/lavapipe/ci/gitlab-ci-inc.yml'
103      - '/src/gallium/frontends/rusticl/ci/gitlab-ci.yml'
104      - '/src/intel/ci/gitlab-ci-inc.yml'
105      - '/src/microsoft/ci/gitlab-ci-inc.yml'
106      - '/src/nouveau/ci/gitlab-ci-inc.yml'
107      - '/src/virtio/ci/gitlab-ci-inc.yml'
108  - drivers/gpu/drm/ci/image-tags.yml
109  - drivers/gpu/drm/ci/container.yml
110  - drivers/gpu/drm/ci/static-checks.yml
111  - drivers/gpu/drm/ci/build.yml
112  - drivers/gpu/drm/ci/test.yml
113  - 'https://gitlab.freedesktop.org/gfx-ci/lab-status/-/raw/main/lab-status.yml'
114
115
116stages:
117  - sanity
118  - container
119  - git-archive
120  - build-for-tests
121  - build-only
122  - code-validation
123  - amdgpu
124  - i915
125  - mediatek
126  - meson
127  - msm
128  - panfrost
129  - powervr
130  - rockchip
131  - software-driver
132
133
134# YAML anchors for rule conditions
135# --------------------------------
136.rules-anchors:
137  rules:
138    # do not duplicate pipelines on merge pipelines
139    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
140      when: never
141    # merge pipeline
142    - if: &is-merge-attempt $GITLAB_USER_LOGIN == "marge-bot" && $CI_PIPELINE_SOURCE == "merge_request_event"
143    # post-merge pipeline
144    - if: &is-post-merge $GITLAB_USER_LOGIN == "marge-bot" && $CI_PIPELINE_SOURCE == "push"
145    # Pre-merge pipeline
146    - if: &is-pre-merge $CI_PIPELINE_SOURCE == "merge_request_event"
147    # Push to a branch on a fork
148    - if: &is-fork-push $CI_PIPELINE_SOURCE == "push"
149    # nightly pipeline
150    - if: &is-scheduled-pipeline $CI_PIPELINE_SOURCE == "schedule"
151    # pipeline for direct pushes that bypassed the CI
152    - if: &is-direct-push $CI_PIPELINE_SOURCE == "push" && $GITLAB_USER_LOGIN != "marge-bot"
153
154
155# Rules applied to every job in the pipeline
156.common-rules:
157  rules:
158    - if: *is-fork-push
159      when: manual
160
161
162.never-post-merge-rules:
163  rules:
164    - if: *is-post-merge
165      when: never
166
167
168.container+build-rules:
169  rules:
170    - !reference [.common-rules, rules]
171    # Run when re-enabling a disabled farm, but not when disabling it
172    - !reference [.disable-farm-mr-rules, rules]
173    # Never run immediately after merging, as we just ran everything
174    - !reference [.never-post-merge-rules, rules]
175    # Build everything in merge pipelines
176    - if: *is-merge-attempt
177      when: on_success
178    # Same as above, but for pre-merge pipelines
179    - if: *is-pre-merge
180      when: manual
181    # Build everything after someone bypassed the CI
182    - if: *is-direct-push
183      when: manual
184    # Build everything in scheduled pipelines
185    - if: *is-scheduled-pipeline
186      when: on_success
187    # Allow building everything in fork pipelines, but build nothing unless
188    # manually triggered
189    - when: manual
190
191
192# Repeat of the above but with `when: on_success` replaced with
193# `when: delayed` + `start_in:`, for build-only jobs.
194# Note: make sure the branches in this list are the same as in
195# `.container+build-rules` above.
196.build-only-delayed-rules:
197  rules:
198    - !reference [.common-rules, rules]
199    # Run when re-enabling a disabled farm, but not when disabling it
200    - !reference [.disable-farm-mr-rules, rules]
201    # Never run immediately after merging, as we just ran everything
202    - !reference [.never-post-merge-rules, rules]
203    # Build everything in merge pipelines
204    - if: *is-merge-attempt
205      when: delayed
206      start_in: &build-delay 5 minutes
207    # Same as above, but for pre-merge pipelines
208    - if: *is-pre-merge
209      when: manual
210    # Build everything after someone bypassed the CI
211    - if: *is-direct-push
212      when: manual
213    # Build everything in scheduled pipelines
214    - if: *is-scheduled-pipeline
215      when: delayed
216      start_in: *build-delay
217    # Allow building everything in fork pipelines, but build nothing unless
218    # manually triggered
219    - when: manual
220
221
222.ci-deqp-artifacts:
223  artifacts:
224    name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}"
225    when: always
226    untracked: false
227    paths:
228      # Watch out!  Artifacts are relative to the build dir.
229      # https://gitlab.com/gitlab-org/gitlab-ce/commit/8788fb925706cad594adf6917a6c5f6587dd1521
230      - artifacts
231      - _build/meson-logs/*.txt
232      - _build/meson-logs/strace
233
234
235# Git archive
236make git archive:
237  extends:
238    - .fdo.ci-fairy
239  stage: git-archive
240  rules:
241    - !reference [.scheduled_pipeline-rules, rules]
242  # ensure we are running on packet
243  tags:
244    - packet.net
245  script:
246    # Remove drm-ci files we just added
247    - rm -rf .gitlab-ci.*
248    - rm -rf ci
249
250    # Compactify the .git directory
251    - git gc --aggressive
252    # compress the current folder
253    - tar -cvzf ../$CI_PROJECT_NAME.tar.gz .
254
255    # Use id_tokens for JWT auth
256    - s3_upload ../$CI_PROJECT_NAME.tar.gz https://$S3_HOST/${S3_GITCACHE_BUCKET}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/
257
258
259# Sanity checks of MR settings and commit logs
260sanity:
261  extends:
262    - .fdo.ci-fairy
263  stage: sanity
264  rules:
265    - if: *is-pre-merge
266      when: on_success
267    - when: never
268  variables:
269    GIT_STRATEGY: none
270  script:
271    # ci-fairy check-commits --junit-xml=check-commits.xml
272    - ci-fairy check-merge-request --require-allow-collaboration --junit-xml=check-merge-request.xml
273    - |
274      set -eu
275      image_tags=(
276        ALPINE_X86_64_LAVA_SSH_TAG
277        CONTAINER_TAG
278        DEBIAN_BASE_TAG
279        DEBIAN_BUILD_TAG
280        DEBIAN_PYUTILS_TAG
281        DEBIAN_TEST_GL_TAG
282        KERNEL_ROOTFS_TAG
283        KERNEL_TAG
284        PKG_REPO_REV
285      )
286      for var in "${image_tags[@]}"
287      do
288        if [ "$(echo -n "${!var}" | wc -c)" -gt 20 ]
289        then
290          echo "$var is too long; please make sure it is at most 20 chars."
291          exit 1
292        fi
293      done
294  artifacts:
295    when: on_failure
296    reports:
297      junit: check-*.xml
298  tags:
299    - placeholder-job
300
301
302mr-label-maker-test:
303  extends:
304    - .fdo.ci-fairy
305  stage: sanity
306  rules:
307    - !reference [.mr-label-maker-rules, rules]
308  variables:
309    GIT_STRATEGY: fetch
310  timeout: 10m
311  script:
312    - set -eu
313    - python3 -m venv .venv
314    - source .venv/bin/activate
315    - pip install git+https://gitlab.freedesktop.org/freedesktop/mr-label-maker
316    - mr-label-maker --dry-run --mr $CI_MERGE_REQUEST_IID
317
318
319# Jobs that need to pass before spending hardware resources on further testing
320.required-for-hardware-jobs:
321  needs:
322    - job: clang-format
323      optional: true
324    - job: rustfmt
325      optional: true
326    - job: toml-lint
327      optional: true
328