From a66e22774899efb4a3c8ec1f95f43b9f68caa396 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Wed, 12 Feb 2025 14:50:15 +0100 Subject: [PATCH] ci/build: lower the delay to start build-only jobs What we need is a way to tell GitLab "queue `build-only` jobs after `build-for-tests` jobs have started", to make sure that `build-only` jobs don't start before `build-for-tests` jobs and thus delays test jobs and the overall pipeline. The best I had found was "queue `build-only` jobs after *all* the `build-for-tests` jobs have finished", but this introduces a larger delay than we want, and causes `build-only` jobs to often be the last ones to finish in a pipeline, after test jobs that respect the 15min runtime limit. Instead, we can tell GitLab "queue `build-only` jobs after the `build-for-tests` jobs have been queued for X minutes", which is closer to what we want, and in particular this ensures the correct order of *starting* jobs as long as the CI is not overwhelmed and doesn't manage to actually start a queued `build-for-tests` job within 5min, in which case I'd argue we don't care about job order anymore because we have bigger problems anyway and likely everything's going to timeout. This also gets rid of the hard-to-maintain `.build-for-tests-jobs` list of `needs:`, which also needed to be manually merged in half the jobs. The trade-off is that we need to make a (shallow) copy of the `.container+build-rules` list, that replaces all the `when: on_success` with `when: delayed` + `start_in: 5 minutes`. This means that we'll need to make sure the two lists of conditions remain identical, but this seems more manageable; nevertheless, I added a comment to remind us. Part-of: --- .gitlab-ci.yml | 45 +++++++++++++++++++++++ .gitlab-ci/build/gitlab-ci.yml | 66 +--------------------------------- 2 files changed, 46 insertions(+), 65 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8a75433d4d6..3662784e6eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -210,6 +210,8 @@ include: when: never +# Note: make sure the branches in this list are the same as in +# `.build-only-delayed-rules` below. .container+build-rules: rules: - !reference [.common-rules, rules] @@ -266,6 +268,49 @@ include: # manually triggered - when: manual +# Repeat of the above but with `when: on_success` replaced with +# `when: delayed` + `start_in:`, for build-only jobs. +# Note: make sure the branches in this list are the same as in +# `.container+build-rules` above. +.build-only-delayed-rules: + rules: + - !reference [.common-rules, rules] + # Run when re-enabling a disabled farm, but not when disabling it + - !reference [.disable-farm-mr-rules, rules] + # Never run immediately after merging, as we just ran everything + - !reference [.never-post-merge-rules, rules] + # Build everything in merge pipelines, if any files affecting the pipeline + # were changed + - if: *is-merge-attempt + changes: *all_paths + when: delayed + start_in: &build-delay 5 minutes + # Same as above, but for pre-merge pipelines + - if: *is-pre-merge + changes: *all_paths + when: manual + # Skip everything for pre-merge and merge pipelines which don't change + # anything in the build + - if: *is-merge-attempt + when: never + - if: *is-pre-merge + when: never + # Build everything after someone bypassed the CI + - if: *is-direct-push + when: delayed + start_in: *build-delay + # Build everything when pushing to staging branches + - if: *is-staging-push + when: delayed + start_in: *build-delay + # Build everything in scheduled pipelines + - if: *is-scheduled-pipeline + when: delayed + start_in: *build-delay + # Allow building everything in fork pipelines, but build nothing unless + # manually triggered + - when: manual + .ci-deqp-artifacts: artifacts: diff --git a/.gitlab-ci/build/gitlab-ci.yml b/.gitlab-ci/build/gitlab-ci.yml index 207110fe169..98c89ef8fb3 100644 --- a/.gitlab-ci/build/gitlab-ci.yml +++ b/.gitlab-ci/build/gitlab-ci.yml @@ -66,41 +66,12 @@ .meson-build-only: extends: - .meson-build-for-tests + - .build-only-delayed-rules stage: build-only script: - *meson-build -# Make sure this list stays the same as all the jobs with -# `stage: build-for-tests`, except for the windows job as -# explained below. -.build-for-tests-jobs: - - job: debian-testing - optional: true - - job: debian-testing-asan - optional: true - - job: debian-testing-ubsan - optional: true - - job: debian-build-testing - optional: true - - job: debian-arm32 - optional: true - - job: debian-arm32-asan - optional: true - - job: debian-arm64 - optional: true - - job: debian-arm64-asan - optional: true - - job: debian-android - optional: true - # Windows runners don't have more than one build right now, so there is - # no need to wait on the "first one" to be done. - # - job: windows-msvc - # optional: true - - job: python-artifacts - optional: true - - debian-testing: extends: - .meson-build-for-tests @@ -176,7 +147,6 @@ debian-testing-msan: extends: - debian-clang - .meson-build-only - # `needs:` inherited from debian-clang variables: BUILD_JOB_TIMEOUT: 30m # l_undef is incompatible with msan @@ -280,9 +250,6 @@ debian-release: extends: - .meson-build-only - .use-debian/x86_64_build - needs: - - !reference [.use-debian/x86_64_build, needs] - - !reference [.build-for-tests-jobs] variables: UNWIND: "enabled" C_ARGS: > @@ -321,9 +288,6 @@ alpine-build-testing: extends: - .meson-build-only - .use-alpine/x86_64_build - needs: - - !reference [.use-alpine/x86_64_build, needs] - - !reference [.build-for-tests-jobs] variables: BUILD_JOB_TIMEOUT: 30m BUILDTYPE: "release" @@ -359,9 +323,6 @@ fedora-release: extends: - .meson-build-only - .use-fedora/x86_64_build - needs: - - !reference [.use-fedora/x86_64_build, needs] - - !reference [.build-for-tests-jobs] variables: BUILDTYPE: "release" # array-bounds are pure non-LTO gcc buggy warning @@ -633,9 +594,6 @@ debian-arm64-build-test: - .meson-arm - .ci-deqp-artifacts - .meson-build-only - needs: - - !reference [.meson-arm, needs] - - !reference [.build-for-tests-jobs] variables: VULKAN_DRIVERS: "amd,asahi,imagination-experimental,nouveau" DRI_LOADERS: @@ -648,9 +606,6 @@ debian-arm64-release: extends: - debian-arm64 - .meson-build-only - needs: - - !reference [debian-arm64, needs] - - !reference [.build-for-tests-jobs] variables: BUILDTYPE: release S3_ARTIFACT_NAME: mesa-arm64-default-${BUILDTYPE} @@ -666,9 +621,6 @@ debian-no-libdrm: extends: - .meson-arm - .meson-build-only - needs: - - !reference [.meson-arm, needs] - - !reference [.build-for-tests-jobs] variables: VULKAN_DRIVERS: freedreno GALLIUM_DRIVERS: "zink,llvmpipe" @@ -687,9 +639,6 @@ debian-clang: extends: - .meson-build-only - .use-debian/x86_64_build - needs: - - !reference [.use-debian/x86_64_build, needs] - - !reference [.build-for-tests-jobs] variables: BUILDTYPE: debug UNWIND: "enabled" @@ -744,7 +693,6 @@ debian-clang-release: extends: - debian-clang - .meson-build-only - # `needs:` inherited from debian-clang variables: BUILD_JOB_TIMEOUT: 30m BUILDTYPE: "release" @@ -781,9 +729,6 @@ debian-vulkan: extends: - .meson-build-only - .use-debian/x86_64_build - needs: - - !reference [.use-debian/x86_64_build, needs] - - !reference [.build-for-tests-jobs] variables: BUILD_JOB_TIMEOUT: 30m BUILDTYPE: debug @@ -820,9 +765,6 @@ debian-x86_32: - .meson-cross - .use-debian/x86_32_build - .meson-build-only - needs: - - !reference [.use-debian/x86_32_build, needs] - - !reference [.build-for-tests-jobs] variables: BUILDTYPE: debug CROSS: i386 @@ -857,9 +799,6 @@ debian-s390x: - .meson-cross - .use-debian/s390x_build - .meson-build-only - needs: - - !reference [.use-debian/s390x_build, needs] - - !reference [.build-for-tests-jobs] tags: - kvm variables: @@ -875,9 +814,6 @@ debian-ppc64el: - .meson-cross - .use-debian/ppc64el_build - .meson-build-only - needs: - - !reference [.use-debian/ppc64el_build, needs] - - !reference [.build-for-tests-jobs] variables: BUILDTYPE: debug CROSS: ppc64el