From 77eea55d61ed1c9b8b0e5f953ee96d889ee3e1a4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 8 Apr 2025 10:18:12 +0200 Subject: [PATCH] gitlab-ci: use a workflow Also simplify the rules based on the workflow. --- .gitlab-ci.yml | 34 +++++++++++++++++----------------- .gitlab/rules.yml | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 70a75e6a..84cffd03 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,7 +37,7 @@ cache-newest:prep: - .cargo_fetch_job - .cargo_build_tags - .cargo_fetch_artifacts - - .run_automatically + - .rules # cache-mindeps:prep: # extends: @@ -45,7 +45,7 @@ cache-newest:prep: # - .cargo_fetch_job # - .cargo_build_tags # - .cargo_fetch_artifacts -# - .run_automatically +# - .rules # variables: # GENERATE_LOCKFILE_ARGS: "-Z minimal-versions" # CARGO_UPDATE_POLICY: mindeps @@ -55,7 +55,7 @@ clippy:build: - .rust_stable - .cargo_clippy_job - .cargo_build_tags - - .run_automatically + - .rules needs: - cache-newest:prep @@ -75,7 +75,7 @@ clippy:build: # - .rust_minimum # - .cargo_audit_job # - .cargo_build_tags -# - .run_automatically +# - .rules # - .cargo_audit_ignore # needs: # - cache-mindeps:prep @@ -87,7 +87,7 @@ audit-newest:build: - .rust_stable - .cargo_audit_job - .cargo_build_tags - - .run_automatically + - .rules - .cargo_audit_ignore needs: - cache-newest:prep @@ -98,7 +98,7 @@ minimum:build: - .cargo_build_job - .cargo_build_tags - .cargo_build_artifacts - - .run_automatically + - .rules needs: - cache-newest:prep @@ -108,7 +108,7 @@ minimum:test: - .cargo_test_job - .cargo_build_tags - .cargo_test_artifacts - - .run_automatically + - .rules needs: - minimum:build @@ -118,7 +118,7 @@ stable:build: - .cargo_build_job - .cargo_build_tags - .cargo_build_artifacts - - .run_automatically + - .rules needs: - cache-newest:prep @@ -128,7 +128,7 @@ stable:test: - .cargo_test_job - .cargo_build_tags - .cargo_test_artifacts - - .run_automatically + - .rules needs: - stable:build @@ -138,7 +138,7 @@ tarpaulin:build: - .cargo_tarpaulin_build_job - .cargo_build_tags - .cargo_build_artifacts - - .run_automatically + - .rules needs: - cache-newest:prep @@ -147,7 +147,7 @@ tarpaulin:test: - .rust_stable - .cargo_tarpaulin_test_job - .cargo_privileged_tags - - .run_automatically + - .rules needs: - tarpaulin:build @@ -157,7 +157,7 @@ nightly:build: - .cargo_build_job - .cargo_build_tags - .cargo_build_artifacts - - .run_automatically + - .rules needs: - cache-newest:prep @@ -167,7 +167,7 @@ nightly:test: - .cargo_test_job - .cargo_build_tags - .cargo_test_artifacts - - .run_automatically + - .rules needs: - nightly:build @@ -177,7 +177,7 @@ nightly:test: # - .cargo_build_job # - .cargo_build_tags # - .cargo_build_artifacts -# - .run_automatically +# - .rules # needs: # - cache-mindeps:prep @@ -187,7 +187,7 @@ nightly:test: # - .cargo_test_job # - .cargo_build_tags # - .cargo_test_artifacts -# - .run_automatically +# - .rules # needs: # - mindeps:build @@ -195,7 +195,7 @@ git:prep: extends: - .git_build_master - .cargo_build_tags - - .run_automatically + - .rules git-master:test: extends: @@ -203,7 +203,7 @@ git-master:test: - .cargo_test_job - .cargo_build_tags - .cargo_test_artifacts - - .run_automatically + - .rules needs: - git:prep - stable:build diff --git a/.gitlab/rules.yml b/.gitlab/rules.yml index 29198599..e1b5aeeb 100644 --- a/.gitlab/rules.yml +++ b/.gitlab/rules.yml @@ -1,9 +1,36 @@ # Rules for where jobs can run -.run_automatically: +# When to even consider running a pipeline. +workflow: rules: + # Run for merge requests. - if: '$CI_MERGE_REQUEST_ID' - when: on_success - - if: '$CI_PROJECT_PATH == "utils/rust-ghostflow"' - when: on_success + when: always + auto_cancel: + # Cancel all pipeline jobs if a new commit comes in on the branch. + on_new_commit: interruptible + # Do not run for other projects. + - if: '$CI_PROJECT_PATH != "utils/rust-ghostflow"' + when: never + # Run for protected branches. + - if: '$CI_COMMIT_REF_PROTECTED == "true"' + when: always + auto_cancel: + # Cancel all pipeline jobs if a new commit comes in on the branch. + on_new_commit: interruptible + # Run for tags. + - if: '$CI_COMMIT_TAG' + when: always + # Run for schedules. + - if: '$CI_PIPELINE_SOURCE == "schedule"' + when: always + auto_cancel: + # Never cancel scheduled pipelines because of new commits. + on_new_commit: none + # Skip pipelines in all other cases. - when: never + +.rules: + rules: + # Jobs run right away. + - when: on_success -- GitLab