Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Refactor the automatic-crate-publishing logic, make triggered pipelin…
Browse files Browse the repository at this point in the history
…es uninterruptible as well (#13908)

* Use a new approach to make automatic-crate-publishing uninterruptible

It's not neccessary to dynamically change the `interruptible` setting
for *all* jobs as the old approach does; gitlab already considers a
pipeline uninterruptible as soon as a single uninterruptible job has
started (cf https://docs.gitlab.com/ee/ci/yaml/#interruptible).

IMO this approach is more readable, as it avoids dynamically loading the
.defaults section from different files based on import conditions; the
logic is now shorter and entirely contained in the main .gitlab-ci.yml.

* Make triggered multi-project pipelines uninterruptible
  • Loading branch information
Mira Ressel authored Apr 13, 2023
1 parent b5b5751 commit a49292a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
42 changes: 19 additions & 23 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,15 @@ variables:
NEXTEST_SUCCESS_OUTPUT: final
ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.3.43"

.shared-default: &shared-default
default:
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
cache: {}

.default-pipeline-definitions:
default:
<<: *shared-default
interruptible: true

.crate-publishing-pipeline-definitions:
default:
<<: *shared-default
# The crate-publishing pipeline defaults to `interruptible: false` so that we'll be able to
# reach and run the publishing jobs despite the "Auto-cancel redundant pipelines" CI setting.
# The setting is relevant because the crate-publishing pipeline runs on `master`, thus future
# pipelines on `master` (e.g. created for new commits or other schedules) might unintendedly
# cancel the publishing jobs or its dependencies before we get to actually publish the crates.
interruptible: false
interruptible: true

.collect-artifacts:
artifacts:
Expand Down Expand Up @@ -291,6 +277,23 @@ check-crates-publishing-pipeline:
https://github.com/paritytech/releng-scripts.git
- ONLY_CHECK_PIPELINE=true ./releng-scripts/publish-crates

# By default our pipelines are interruptible, but some special pipelines shouldn't be interrupted:
# * multi-project pipelines such as the ones triggered by the scripts repo
# * the scheduled automatic-crate-publishing pipeline
#
# In those cases, we add an uninterruptible .pre job; once that one has started,
# the entire pipeline becomes uninterruptible
uninterruptible-pipeline:
extends: .kubernetes-env
variables:
CI_IMAGE: "paritytech/tools:latest"
stage: .pre
interruptible: false
rules:
- if: $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_PIPELINE_SOURCE == "schedule" && $PIPELINE == "automatic-crate-publishing"
script: "true"

include:
# check jobs
- scripts/ci/gitlab/pipeline/check.yml
Expand All @@ -311,13 +314,6 @@ include:
# pipeline is made uninterruptible to ensure that test jobs also get a chance to run to
# completion, because the publishing jobs depends on them AS INTENDED: crates should not be
# published before their source code is checked.
- local: scripts/ci/gitlab/crate-publishing-pipeline.yml
rules:
- if: $PIPELINE == "automatic-crate-publishing"
# For normal pipelines: run it with defaults + `interruptible: true`
- local: scripts/ci/gitlab/default-pipeline.yml
rules:
- if: $PIPELINE != "automatic-crate-publishing"
- project: parity/infrastructure/ci_cd/shared
ref: v0.2
file: /common/timestamp.yml
Expand Down
1 change: 0 additions & 1 deletion scripts/ci/gitlab/crate-publishing-pipeline.yml

This file was deleted.

1 change: 0 additions & 1 deletion scripts/ci/gitlab/default-pipeline.yml

This file was deleted.

0 comments on commit a49292a

Please sign in to comment.