Implement crate publishing on CI (#12768)

* implement crate publishing from CI

* fix indentation

* use resource_group for job exclusivity

ensure that at most one instance of the publish-crates job is running at any given time to prevent race conditions

* correct publish = false

* Remove YAML anchors as GitLab's `extends:` doesn't need it

* Temporarily force cache upload for the new jobs

* Revert `RUSTY_CACHIER_FORCE_UPLOAD`

* pin libp2p-tcp=0.37.0 for sc-telemetry

* Revert "pin libp2p-tcp=0.37.0 for sc-telemetry"

This reverts commit 29146bfad6c31e8cf0e2f17ad92a71bb81a373af.

* always collect generated crates

* increase timeout for publish-crates-template

* Force upload the new job cache again

* Revert "Force upload the new job cache again"

This reverts commit 5a5feee1b2c51fdef768b25a76be4c3949ec1c99.

* reformat

* improve timeout explanation

* s/usual/average

Co-authored-by: Vladimir Istyufeev <vladimir@parity.io>
This commit is contained in:
João Paulo Silva de Souza
2022-12-07 15:08:48 -03:00
committed by GitHub
parent 3b9d781afc
commit 8751f88fc7
48 changed files with 137 additions and 36 deletions
@@ -161,3 +161,41 @@ update-node-template:
--template-path "bin/node-template"
--github-api-token "$GITHUB_TOKEN"
--polkadot-branch "$CI_COMMIT_REF_NAME"
.publish-crates-template:
stage: publish
extends: .crates-publishing-template
# We don't want multiple jobs racing to publish crates as it's redundant and they might overwrite
# the releases of one another. Use resource_group to ensure that at most one instance of this job
# is running at any given time.
resource_group: crates-publishing
variables:
# crates.io rate limits crates publishing by 1 per minute, so a delay needs to be inserted
# slightly higher than that after publishing each crate. The value is specified in seconds.
SPUB_AFTER_PUBLISH_DELAY: 64
# We might have to publish lots of crates at a time. Given the 1 minute delay introduced above and
# taking into account the 202 (as of Dec 07, 2022) publishable Substrate crates, that would equate
# to roughly 202 minutes of delay, or 3h and 22 minutes. As such, the job needs to have a much
# higher timeout than average.
timeout: 5h
script:
- rusty-cachier snapshot create
- git clone
--depth 1
--branch "$RELENG_SCRIPTS_BRANCH"
https://github.com/paritytech/releng-scripts.git
- CRATESIO_TARGET_INSTANCE=default ./releng-scripts/publish-crates
- rusty-cachier cache upload
publish-crates:
extends: .publish-crates-template
needs:
- job: publish-crates-locally
artifacts: false
rules:
- if: $CI_COMMIT_REF_NAME == "master"
publish-crates-manual:
extends: .publish-crates-template
when: manual
allow_failure: true
@@ -394,6 +394,19 @@ cargo-check-each-crate:
- if [ "$CI_NODE_INDEX" == 1 ]; then rusty-cachier cache upload; fi
parallel: 2
publish-crates-locally:
extends:
- .test-refs
- .crates-publishing-template
script:
- rusty-cachier snapshot create
- git clone
--depth 1
--branch "$RELENG_SCRIPTS_BRANCH"
https://github.com/paritytech/releng-scripts.git
- CRATESIO_TARGET_INSTANCE=local ./releng-scripts/publish-crates
- rusty-cachier cache upload
cargo-check-each-crate-macos:
stage: test
extends: