diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f1ef0172a20f7451a2e5a8e4fb517eedaa5fd483..4f9e792e58cd5386d4ea9b79cb9d2caea2f03132 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,7 +42,7 @@ cache-newest:prep: - .cargo_fetch_job - .cargo_build_tags - .cargo_fetch_artifacts - - .run_automatically + - .rules cache-mindeps:prep: extends: @@ -50,7 +50,7 @@ cache-mindeps:prep: - .cargo_fetch_job - .cargo_build_tags - .cargo_fetch_artifacts - - .run_automatically + - .rules variables: GENERATE_LOCKFILE_ARGS: "-Z minimal-versions" CARGO_UPDATE_POLICY: mindeps @@ -60,7 +60,7 @@ clippy:build: - .rust_stable - .cargo_clippy_job - .cargo_build_tags - - .run_automatically + - .rules needs: - cache-newest:prep @@ -70,7 +70,7 @@ clippy-features:build: - .cargo_all_features - .cargo_clippy_job - .cargo_build_tags - - .run_automatically + - .rules needs: - cache-newest:prep @@ -88,7 +88,7 @@ semver-checks:git-checks-core:prep: - .rust_stable - .cargo_semver_checks_job - .cargo_build_tags - - .run_automatically + - .rules variables: PACKAGE: git-checks-core CHANGELOG_PATH: git-checks-core/CHANGELOG.md @@ -98,7 +98,7 @@ semver-checks:git-checks-config:prep: - .rust_stable - .cargo_semver_checks_job - .cargo_build_tags - - .run_automatically + - .rules variables: PACKAGE: git-checks-config CHANGELOG_PATH: git-checks-config/CHANGELOG.md @@ -108,7 +108,7 @@ semver-checks:git-checks:prep: - .rust_stable - .cargo_semver_checks_job - .cargo_build_tags - - .run_automatically + - .rules variables: PACKAGE: git-checks CHANGELOG_PATH: git-checks/CHANGELOG.md @@ -118,7 +118,7 @@ semver-checks:git-checks:features:prep: - .rust_stable - .cargo_semver_checks_job - .cargo_build_tags - - .run_automatically + - .rules variables: CARGO_FEATURES: "--features config" PACKAGE: git-checks @@ -129,7 +129,7 @@ audit-mindeps:build: - .rust_mindeps - .cargo_audit_job - .cargo_build_tags - - .run_automatically + - .rules - .cargo_audit_ignore needs: - cache-mindeps:prep @@ -139,7 +139,7 @@ audit-newest:build: - .rust_stable - .cargo_audit_job - .cargo_build_tags - - .run_automatically + - .rules - .cargo_audit_ignore needs: - cache-newest:prep @@ -150,7 +150,7 @@ stable:build: - .cargo_build_job - .cargo_build_tags - .cargo_build_artifacts - - .run_automatically + - .rules needs: - cache-newest:prep @@ -160,7 +160,7 @@ stable:test: - .cargo_test_job - .cargo_build_tags - .cargo_test_artifacts - - .run_automatically + - .rules needs: - stable:build @@ -170,7 +170,7 @@ nightly:build: - .cargo_build_job - .cargo_build_tags - .cargo_build_artifacts - - .run_automatically + - .rules needs: - cache-newest:prep @@ -180,7 +180,7 @@ nightly:test: - .cargo_test_job - .cargo_build_tags - .cargo_test_artifacts - - .run_automatically + - .rules needs: - nightly:build @@ -190,7 +190,7 @@ mindeps:build: - .cargo_build_job - .cargo_build_tags - .cargo_build_artifacts - - .run_automatically + - .rules needs: - cache-mindeps:prep @@ -200,7 +200,7 @@ mindeps:test: - .cargo_test_job - .cargo_build_tags - .cargo_test_artifacts - - .run_automatically + - .rules needs: - mindeps:build @@ -211,7 +211,7 @@ stable-features:build: - .cargo_build_job - .cargo_build_tags - .cargo_build_artifacts - - .run_automatically + - .rules needs: - cache-newest:prep @@ -222,7 +222,7 @@ stable-features:test: - .cargo_test_job - .cargo_build_tags - .cargo_test_artifacts - - .run_automatically + - .rules needs: - stable-features:build @@ -233,7 +233,7 @@ tarpaulin-features:build: - .cargo_tarpaulin_build_job - .cargo_build_tags - .cargo_build_artifacts - - .run_automatically + - .rules needs: - cache-newest:prep @@ -243,7 +243,7 @@ tarpaulin-features:test: - .cargo_all_features - .cargo_tarpaulin_test_job - .cargo_privileged_tags - - .run_automatically + - .rules needs: - tarpaulin-features:build @@ -254,7 +254,7 @@ nightly-features:build: - .cargo_build_job - .cargo_build_tags - .cargo_build_artifacts - - .run_automatically + - .rules needs: - cache-newest:prep @@ -265,7 +265,7 @@ nightly-features:test: - .cargo_test_job - .cargo_build_tags - .cargo_test_artifacts - - .run_automatically + - .rules needs: - nightly-features:build @@ -276,7 +276,7 @@ mindeps-features:build: - .cargo_build_job - .cargo_build_tags - .cargo_build_artifacts - - .run_automatically + - .rules needs: - cache-mindeps:prep @@ -287,7 +287,7 @@ mindeps-features:test: - .cargo_test_job - .cargo_build_tags - .cargo_test_artifacts - - .run_automatically + - .rules needs: - mindeps-features:build @@ -295,7 +295,7 @@ git:prep: extends: - .git_build_master - .cargo_build_tags - - .run_automatically + - .rules git-master:test: extends: @@ -303,7 +303,7 @@ git-master:test: - .cargo_test_job - .cargo_build_tags - .cargo_test_artifacts - - .run_automatically + - .rules needs: - git:prep - stable:build @@ -313,7 +313,7 @@ publish: - .rust_stable - .cargo_publish_job - .cargo_build_tags - - .run_automatically + - .rules needs: - job: audit-mindeps:build artifacts: false diff --git a/.gitlab/cargo.yml b/.gitlab/cargo.yml index 94af437d424b1bc389814dffbc3720eaacc161f7..ef63b0711f3fd22d32e5ea56c31f30e634c68c64 100644 --- a/.gitlab/cargo.yml +++ b/.gitlab/cargo.yml @@ -153,4 +153,4 @@ esac - cargo publish --no-verify --token $token variables: - IS_FOR_RELEASE: "true" + RUST_CI_RELEASE_ONLY: "true" diff --git a/.gitlab/rules.yml b/.gitlab/rules.yml index a0b226dda00dd10dae073b78b547cb0a7c66a9ee..6e07432b8c8620cec19d5fa330ef47e87936015d 100644 --- a/.gitlab/rules.yml +++ b/.gitlab/rules.yml @@ -1,22 +1,48 @@ # Rules for where jobs can run -.run_automatically: +### +# Job variables: +# RUST_CI_RELEASE_ONLY +# Set to "true" to only perform for tag pipelines. +### + +# When to even consider running a pipeline. +workflow: rules: - # Release jobs ignore MRs. - - if: '$CI_MERGE_REQUEST_ID && $IS_FOR_RELEASE == "true"' - when: never + # Run for merge requests. - if: '$CI_MERGE_REQUEST_ID' - when: on_success - # Non-protected branches without tags should be skipped. - - if: '$CI_COMMIT_REF_PROTECTED != "true" && $CI_COMMIT_TAG == ""' + 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-git-checks"' when: never - # Run everything for tags. - - if: '$CI_PROJECT_PATH == "utils/rust-git-checks" && $CI_COMMIT_TAG' + # 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: + # Run release-only jobs for tags. + - if: '$RUST_CI_RELEASE_ONLY == "true" && $CI_COMMIT_TAG' when: on_success - # Skip release-only jobs. - - if: '$CI_PROJECT_PATH == "utils/rust-git-checks" && $IS_FOR_RELEASE == "true"' + # Skip release jobs without tag. + - if: '$RUST_CI_RELEASE_ONLY == "true"' when: never - # Run everything on the main project. - - if: '$CI_PROJECT_PATH == "utils/rust-git-checks"' - when: on_success - - when: never + # Other jobs run right away. + - when: on_success