Skip to content

Commit

Permalink
ci: cancel old piplines (#639)
Browse files Browse the repository at this point in the history
## fixes KILTprotocol/ticket#3406

This PR introduces automatic cancellation of pipelines when a new commit
is pushed to the branch.

Furthermore, if any test fails, the entire pipeline will be canceled. If
this is not wished, I can revert the changes.

Lastly, if a commit has the title "ci: Updates Snapshots", the tests
will be skipped.

Example branch, where the pipeline is skipped because of the commit
message:
https://gitlab.com/kiltprotocol/kilt-node/-/pipelines/1293783978

---------

Co-authored-by: Antonio <antonio@kilt.io>
  • Loading branch information
Ad96el and ntn-x2 authored May 24, 2024
1 parent 193190d commit b0e6bf2
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
.check_skip_rust:
before_script:
- |-
if echo "$CI_COMMIT_TITLE" | grep -q "ci-skip-rust"; then
echo "Skipping rust tests due to commit title"
exit 0
fi
.check_skip_integration_tests:
before_script:
- |-
if echo "$CI_COMMIT_TITLE" | grep -q "ci-skip-integration-tests"; then
echo "Skipping integration tests due to commit title"
exit 0
fi
workflow:
auto_cancel:
on_new_commit: interruptible


stages:
- test
- build

clippy-and-docs:
extends: .check_skip_rust
interruptible: true
timeout: 2 hours
image: paritytech/ci-unified:bullseye-1.70.0
stage: test
Expand All @@ -11,6 +34,8 @@ clippy-and-docs:
- RUSTDOCFLAGS='-D warnings' cargo doc --all-features --no-deps --locked

fmt:
interruptible: true
extends: .check_skip_rust
image: paritytech/ci-unified:bullseye-1.70.0
stage: test
script:
Expand All @@ -19,20 +44,26 @@ fmt:
- taplo fmt --check

test:
interruptible: true
extends: .check_skip_rust
timeout: 2 hours
image: paritytech/ci-unified:bullseye-1.70.0
stage: test
script:
- cargo test --all --all-targets --locked

test-features:
extends: .check_skip_rust
interruptible: true
timeout: 2 hours
image: paritytech/ci-unified:bullseye-1.70.0
stage: test
script:
- cargo test --all --all-features --all-targets --locked

integration-tests:
extends: .check_skip_integration_tests
interruptible: true
timeout: 30 minutes
image: paritytech/ci-unified:bullseye-1.70.0
stage: test
Expand All @@ -50,6 +81,8 @@ integration-tests:

# TODO: The try-runtime-cli executable could be built as part of the Docker image directly, saving some time.
test-try-runtime:
extends: .check_skip_rust
interruptible: true
parallel:
matrix:
- RUNTIME: "peregrine"
Expand All @@ -69,6 +102,7 @@ test-try-runtime:
- ./try-runtime --runtime ./target/release/wbuild/${RUNTIME}-runtime/${RUNTIME}_runtime.compact.compressed.wasm on-runtime-upgrade --disable-spec-version-check --checks=all live --uri=${ENDPOINT}

build:
interruptible: true
timeout: 2 hours
image:
name: kiltprotocol/kilt-ci:2.7.31
Expand Down Expand Up @@ -100,6 +134,7 @@ build:
- "if [[ ! -z ${CI_COMMIT_TAG} && ! -z ${CI_COMMIT_TAG##*-rc*} && ! -z ${CI_COMMIT_TAG##*dev-*} ]]; then ./.maintain/push-image.sh build latest; fi"

build-wasm-peregrine:
interruptible: true
image:
name: paritytech/srtool:1.70.0
entrypoint: [""]
Expand Down Expand Up @@ -128,6 +163,7 @@ build-wasm-peregrine:
expire_in: 12 week

build-wasm-spiritnet:
interruptible: true
image:
name: paritytech/srtool:1.70.0
entrypoint: [""]
Expand Down Expand Up @@ -156,6 +192,7 @@ build-wasm-spiritnet:
expire_in: 12 week

build-wasm-try-runtime:
interruptible: true
parallel:
matrix:
- RUNTIME: "peregrine"
Expand Down

0 comments on commit b0e6bf2

Please sign in to comment.