Skip to content

Commit c2b3a56

Browse files
joao-paulo-parityalvicsam
authored andcommitted
Avoid unintentionally canceling the scheduled crate publishing job (paritytech#13088)
* avoid unintentionally canceling the scheduled crate publishing job because publish-crates and publish-crates-manual share the resource group "crates-publishing", any instance of publish-crates-manual cancels a running instance of publish-crates, as demonstrated by https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/2212179 a workaround for that unintended interaction is to avoid creating instances of publish-crates-manual and instead require pipelines to be triggered manually by checking $CI_JOB_MANUAL == "true" * check manual pipelines by $CI_PIPELINE_SOURCE instead of $CI_JOB_MANUAL * make crate-publishing pipelines uninterruptible * use conditional includes to work around interruptible limitations * organize comments * remove interruptible from common pipeline * wip: check include * wip: check include * fix include * fix include * fix include * fix yaml * fix yaml * remove shared common-pipeline * wip: retry common-pipeline * move .default-template to .gitlab-ci.yml * fix the pipeline add comments * fix default-pipeline.yml * revert publish-crates-manual to when: manual * move "needs:" back to publish-crates * avoid manual repetition * improve previous commit * try to avoid manual repetition * fix indentation * minor adjustments * move defaults to top of .gitlab-ci.yml * fix positioning on default in the diff * comments * indentation * Apply suggestions from code review Co-authored-by: Alexander Samusev <[email protected]> Co-authored-by: Alexander Samusev <[email protected]>
1 parent f8c66ed commit c2b3a56

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

.gitlab-ci.yml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,30 @@ variables:
5757
NEXTEST_SUCCESS_OUTPUT: final
5858
ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.3.22"
5959

60-
default:
60+
.shared-default: &shared-default
6161
retry:
6262
max: 2
6363
when:
6464
- runner_system_failure
6565
- unknown_failure
6666
- api_failure
67-
interruptible: true
6867
cache: {}
6968

69+
.default-pipeline-definitions:
70+
default:
71+
<<: *shared-default
72+
interruptible: true
73+
74+
.crate-publishing-pipeline-definitions:
75+
default:
76+
<<: *shared-default
77+
# The crate-publishing pipeline defaults to `interruptible: false` so that we'll be able to
78+
# reach and run the publishing jobs despite the "Auto-cancel redundant pipelines" CI setting.
79+
# The setting is relevant because the crate-publishing pipeline runs on `master`, thus future
80+
# pipelines on `master` (e.g. created for new commits or other schedules) might unintendedly
81+
# cancel the publishing jobs or its dependencies before we get to actually publish the crates.
82+
interruptible: false
83+
7084
.collect-artifacts:
7185
artifacts:
7286
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
@@ -215,9 +229,15 @@ default:
215229
# this job runs only on nightly pipeline with the mentioned variable, against `master` branch
216230
- if: $CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "schedule" && $PIPELINE == "nightly"
217231

232+
.crate-publishing-pipeline:
233+
rules:
234+
- if: $CI_COMMIT_REF_NAME != "master"
235+
when: never
236+
218237
.scheduled-crate-publishing-pipeline:
219238
rules:
220-
- if: $CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "schedule" && $PIPELINE == "automatic-crate-publishing"
239+
- !reference [.crate-publishing-pipeline, rules]
240+
- if: $CI_PIPELINE_SOURCE == "schedule" && $PIPELINE == "automatic-crate-publishing"
221241

222242
.crates-publishing-template:
223243
stage: test
@@ -265,6 +285,22 @@ include:
265285
- scripts/ci/gitlab/pipeline/publish.yml
266286
# zombienet jobs
267287
- scripts/ci/gitlab/pipeline/zombienet.yml
288+
# The crate-publishing pipeline requires a customized `interruptible` configuration. Unfortunately
289+
# `interruptible` can't currently be dynamically set based on variables as per:
290+
# - https://gitlab.com/gitlab-org/gitlab/-/issues/38349
291+
# - https://gitlab.com/gitlab-org/gitlab/-/issues/194023
292+
# Thus we work around that limitation by using conditional includes.
293+
# For crate-publishing pipelines: run it with defaults + `interruptible: false`. The WHOLE
294+
# pipeline is made uninterruptible to ensure that test jobs also get a chance to run to
295+
# completion, because the publishing jobs depends on them AS INTENDED: crates should not be
296+
# published before their source code is checked.
297+
- local: scripts/ci/gitlab/crate-publishing-pipeline.yml
298+
rules:
299+
- if: $PIPELINE == "automatic-crate-publishing"
300+
# For normal pipelines: run it with defaults + `interruptible: true`
301+
- local: scripts/ci/gitlab/default-pipeline.yml
302+
rules:
303+
- if: $PIPELINE != "automatic-crate-publishing"
268304

269305
#### stage: deploy
270306

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
default: !reference [.crate-publishing-pipeline-definitions, default]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
default: !reference [.default-pipeline-definitions, default]

scripts/ci/gitlab/pipeline/publish.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ update-node-template:
214214
timeout: 9h
215215
# A custom publishing environment is used for us to be able to set up protected secrets
216216
# specifically for it
217-
environment: publish-crates
217+
environment: publish-crates
218218
script:
219219
- rusty-cachier snapshot create
220220
- git clone
@@ -234,5 +234,6 @@ publish-crates:
234234

235235
publish-crates-manual:
236236
extends: .publish-crates-template
237+
rules: !reference [.crate-publishing-pipeline, rules]
237238
when: manual
238239
allow_failure: true

0 commit comments

Comments
 (0)