From f3428dc71e13b434aa06916f360fd97b6c96cea7 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 14 Mar 2022 18:19:23 +0000 Subject: [PATCH] ci: Only run by default when scheduled for merge request VirGL just runs way too many jobs, with each pipeline consuming the entire committed x86-64 build capacity we have available, so we need to restrict it anyway. This is made worse by the fact it will create duplicate pipelines for merge requests. Signed-off-by: Daniel Stone Part-of: --- .gitlab-ci.yml | 57 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ce416b4..dde80e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,6 +32,38 @@ include: file: - '/.gitlab-ci/image-tags.yml' +# YAML anchors for rule conditions +# -------------------------------- +.rules-anchors: + rules: + # Scheduled pipeline + - if: &is-scheduled-pipeline '$CI_PIPELINE_SOURCE == "schedule"' + when: on_success + # For Marge Bot + - if: &is-for-marge '$GITLAB_USER_LOGIN == "marge-bot"' + when: never + # Forked project branch + - if: &is-forked-branch '$CI_PROJECT_NAMESPACE != "virgl" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME != $CI_COMMIT_REF_NAME' + when: manual + # Forked project branch / pre-merge pipeline not for Marge bot + - if: &is-forked-branch-or-pre-merge-not-for-marge '$CI_PROJECT_NAMESPACE != "virgl" || ($GITLAB_USER_LOGIN != "marge-bot" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == $CI_COMMIT_REF_NAME)' + when: manual + # Pipeline runs for the main branch of the upstream virglrenderer project + - if: &is-virglrenderer-main '$CI_PROJECT_NAMESPACE == "virgl" && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME != $CI_DEFAULT_BRANCH' + when: always + # Post-merge pipeline + - if: &is-post-merge '$CI_PROJECT_NAMESPACE == "virgl" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME != $CI_COMMIT_REF_NAME' + when: on_success + # Post-merge pipeline, not for Marge Bot + - if: &is-post-merge-not-for-marge '$CI_PROJECT_NAMESPACE == "virgl" && $GITLAB_USER_LOGIN != "marge-bot" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME != $CI_COMMIT_REF_NAME' + when: on_success + # Pre-merge pipeline + - if: &is-pre-merge '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == $CI_COMMIT_REF_NAME' + when: on_success + # Pre-merge pipeline for Marge Bot + - if: &is-pre-merge-for-marge '$GITLAB_USER_LOGIN == "marge-bot" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == $CI_COMMIT_REF_NAME' + when: on_success + stages: - build - sanity test @@ -64,11 +96,16 @@ debian/x86_build: paths: - install/ - results/ - only: - - branches - - tags - - merge_requests - - schedules + rules: + - if: *is-scheduled-pipeline + when: on_success + - if: *is-post-merge + when: never + - if: *is-forked-branch-or-pre-merge-not-for-marge + when: manual + - if: *is-pre-merge-for-marge + when: on_success + - when: manual # # Sanity test jobs @@ -77,6 +114,7 @@ debian/x86_build: .make_check_base: stage: sanity test extends: debian/x86_build + dependencies: [] artifacts: when: always paths: @@ -126,13 +164,10 @@ make check venus: - results/ reports: junit: results/junit.xml - needs: + dependencies: - debian/x86_build - only: - - branches - - tags - - merge_requests - - schedules + rules: + - when: on_success .gl-host-test: extends: