Unverified Commit 1747b345 authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Use different mechanism to trigger `ink-waterfall` CI (#851)

* Move `pre_cache` script to hidden folder

* Add `trigger_pipeline` script from Polkadot

* Use `trigger_pipeline` to trigger `ink-waterfall` CI

* Update GitLab config

* Update GitLab config

* Add debug output

* Revert me: Remove all other stages

* More debugging

* More debugging

* More debugging

* More debugging

* Fix syntax

* Check for env variable

* Revert "Revert me: Remove all other stages"

This reverts commit a15ec5b0.

* Decrease response time

* Remove unnecessary variables

* Fix link

* CI: chore

* CI: add rules everywhere

* CI: add rust info

* Add image name and tag

* Revert "Add image name and tag"

This reverts commit 88cd94f0

.

* CI: add image to run in k8s
Co-authored-by: Denis_P's avatarDenis P <denis.pisarev@parity.io>
parent 5c79f3b8
Pipeline #146657 failed with stages
in 7 minutes and 52 seconds
...@@ -39,15 +39,15 @@ workflow: ...@@ -39,15 +39,15 @@ workflow:
paths: paths:
- artifacts/ - artifacts/
.docker-env: &docker-env .rust-info-script: &rust-info-script
image: "${CI_IMAGE}" - rustup show
before_script: - cargo --version
- cargo -vV - rustup +nightly show
- rustc -vV - cargo +nightly --version
- rustup show - bash --version
- bash --version - sccache -s
- ./scripts/pre_cache.sh
- sccache -s .test-refs: &test-refs
rules: rules:
- if: $CI_PIPELINE_SOURCE == "web" - if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_PIPELINE_SOURCE == "schedule"
...@@ -55,6 +55,13 @@ workflow: ...@@ -55,6 +55,13 @@ workflow:
- if: $CI_COMMIT_REF_NAME == "tags" - if: $CI_COMMIT_REF_NAME == "tags"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
.docker-env: &docker-env
image: "${CI_IMAGE}"
before_script:
- *rust-info-script
- ./scripts/.ci/pre_cache.sh
- sccache -s
interruptible: true interruptible: true
retry: retry:
max: 2 max: 2
...@@ -65,12 +72,23 @@ workflow: ...@@ -65,12 +72,23 @@ workflow:
tags: tags:
- linux-docker - linux-docker
.kubernetes-env: &kubernetes-env
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
tags:
- kubernetes-parity-build
#### stage: check #### stage: check
check-std: check-std:
stage: check stage: check
<<: *docker-env <<: *docker-env
<<: *test-refs
script: script:
- for crate in ${ALL_CRATES}; do - for crate in ${ALL_CRATES}; do
cargo check --verbose --all-features --manifest-path crates/${crate}/Cargo.toml; cargo check --verbose --all-features --manifest-path crates/${crate}/Cargo.toml;
...@@ -79,6 +97,7 @@ check-std: ...@@ -79,6 +97,7 @@ check-std:
check-wasm: check-wasm:
stage: check stage: check
<<: *docker-env <<: *docker-env
<<: *test-refs
script: script:
- for crate in ${ALSO_WASM_CRATES}; do - for crate in ${ALSO_WASM_CRATES}; do
cargo check --verbose --no-default-features --target wasm32-unknown-unknown --manifest-path crates/${crate}/Cargo.toml; cargo check --verbose --no-default-features --target wasm32-unknown-unknown --manifest-path crates/${crate}/Cargo.toml;
...@@ -90,6 +109,7 @@ check-wasm: ...@@ -90,6 +109,7 @@ check-wasm:
build-std: build-std:
stage: workspace stage: workspace
<<: *docker-env <<: *docker-env
<<: *test-refs
needs: needs:
- job: check-std - job: check-std
artifacts: false artifacts: false
...@@ -101,6 +121,7 @@ build-std: ...@@ -101,6 +121,7 @@ build-std:
build-wasm: build-wasm:
stage: workspace stage: workspace
<<: *docker-env <<: *docker-env
<<: *test-refs
needs: needs:
- job: check-wasm - job: check-wasm
artifacts: false artifacts: false
...@@ -112,6 +133,7 @@ build-wasm: ...@@ -112,6 +133,7 @@ build-wasm:
test: test:
stage: workspace stage: workspace
<<: *docker-env <<: *docker-env
<<: *test-refs
needs: needs:
- job: check-std - job: check-std
artifacts: false artifacts: false
...@@ -134,6 +156,7 @@ test: ...@@ -134,6 +156,7 @@ test:
docs: docs:
stage: workspace stage: workspace
<<: *docker-env <<: *docker-env
<<: *test-refs
variables: variables:
RUSTDOCFLAGS: -Dwarnings RUSTDOCFLAGS: -Dwarnings
artifacts: artifacts:
...@@ -151,20 +174,22 @@ docs: ...@@ -151,20 +174,22 @@ docs:
- mv ${CARGO_TARGET_DIR}/doc ./crate-docs - mv ${CARGO_TARGET_DIR}/doc ./crate-docs
spellcheck: spellcheck:
stage: workspace stage: workspace
<<: *docker-env <<: *docker-env
script: <<: *test-refs
- cargo spellcheck check -vvv --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 script:
- for example in examples/*/; do - cargo spellcheck check -vvv --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1
cargo spellcheck check -vvv --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 ${example}; - for example in examples/*/; do
done cargo spellcheck check -vvv --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 ${example};
- for contract in ${DELEGATOR_SUBCONTRACTS}; do done
cargo spellcheck check -vvv --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 examples/delegator/${contract}/; - for contract in ${DELEGATOR_SUBCONTRACTS}; do
done cargo spellcheck check -vvv --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 examples/delegator/${contract}/;
done
codecov: codecov:
stage: workspace stage: workspace
<<: *docker-env <<: *docker-env
<<: *test-refs
needs: needs:
- job: check-std - job: check-std
artifacts: false artifacts: false
...@@ -179,10 +204,7 @@ codecov: ...@@ -179,10 +204,7 @@ codecov:
# produces better results for Rust codebases in general. However, unlike `grcov` it requires # produces better results for Rust codebases in general. However, unlike `grcov` it requires
# running docker with `--security-opt seccomp=unconfined` which is why we use `grcov` instead. # running docker with `--security-opt seccomp=unconfined` which is why we use `grcov` instead.
before_script: before_script:
- cargo -vV - *rust-info-script
- rustc -vV
- rustup show
- bash --version
- unset "CARGO_TARGET_DIR" - unset "CARGO_TARGET_DIR"
- cargo clean - cargo clean
script: script:
...@@ -212,6 +234,7 @@ codecov: ...@@ -212,6 +234,7 @@ codecov:
clippy-std: clippy-std:
stage: workspace stage: workspace
<<: *docker-env <<: *docker-env
<<: *test-refs
needs: needs:
- job: check-std - job: check-std
artifacts: false artifacts: false
...@@ -223,6 +246,7 @@ clippy-std: ...@@ -223,6 +246,7 @@ clippy-std:
clippy-wasm: clippy-wasm:
stage: workspace stage: workspace
<<: *docker-env <<: *docker-env
<<: *test-refs
needs: needs:
- job: check-wasm - job: check-wasm
artifacts: false artifacts: false
...@@ -234,9 +258,9 @@ clippy-wasm: ...@@ -234,9 +258,9 @@ clippy-wasm:
fmt: fmt:
stage: workspace stage: workspace
<<: *docker-env <<: *docker-env
<<: *test-refs
script: script:
- cargo fmt --verbose --all -- --check - cargo fmt --verbose --all -- --check
# For the UI tests we need to disable the license check # For the UI tests we need to disable the license check
- cargo fmt --verbose --all -- --check --config=license_template_path="" crates/lang/macro/tests/ui/{pass,fail}/*.rs - cargo fmt --verbose --all -- --check --config=license_template_path="" crates/lang/macro/tests/ui/{pass,fail}/*.rs
...@@ -246,6 +270,7 @@ fmt: ...@@ -246,6 +270,7 @@ fmt:
examples-test: examples-test:
stage: examples stage: examples
<<: *docker-env <<: *docker-env
<<: *test-refs
needs: needs:
- job: clippy-std - job: clippy-std
artifacts: false artifacts: false
...@@ -260,6 +285,7 @@ examples-test: ...@@ -260,6 +285,7 @@ examples-test:
examples-test-experimental-engine: examples-test-experimental-engine:
stage: examples stage: examples
<<: *docker-env <<: *docker-env
<<: *test-refs
needs: needs:
- job: clippy-std - job: clippy-std
artifacts: false artifacts: false
...@@ -274,6 +300,7 @@ examples-test-experimental-engine: ...@@ -274,6 +300,7 @@ examples-test-experimental-engine:
examples-fmt: examples-fmt:
stage: examples stage: examples
<<: *docker-env <<: *docker-env
<<: *test-refs
script: script:
- for example in examples/*/; do - for example in examples/*/; do
cargo fmt --verbose --manifest-path ${example}/Cargo.toml -- --check; cargo fmt --verbose --manifest-path ${example}/Cargo.toml -- --check;
...@@ -285,6 +312,7 @@ examples-fmt: ...@@ -285,6 +312,7 @@ examples-fmt:
examples-clippy-std: examples-clippy-std:
stage: examples stage: examples
<<: *docker-env <<: *docker-env
<<: *test-refs
needs: needs:
- job: clippy-std - job: clippy-std
artifacts: false artifacts: false
...@@ -299,6 +327,7 @@ examples-clippy-std: ...@@ -299,6 +327,7 @@ examples-clippy-std:
examples-clippy-wasm: examples-clippy-wasm:
stage: examples stage: examples
<<: *docker-env <<: *docker-env
<<: *test-refs
script: script:
- for example in examples/*/; do - for example in examples/*/; do
cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings; cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
...@@ -310,6 +339,7 @@ examples-clippy-wasm: ...@@ -310,6 +339,7 @@ examples-clippy-wasm:
examples-contract-build: examples-contract-build:
stage: examples stage: examples
<<: *docker-env <<: *docker-env
<<: *test-refs
script: script:
- cargo contract -V - cargo contract -V
- for example in examples/*/; do - for example in examples/*/; do
...@@ -324,41 +354,47 @@ examples-contract-build: ...@@ -324,41 +354,47 @@ examples-contract-build:
done done
examples-contract-build-delegator: examples-contract-build-delegator:
stage: examples stage: examples
<<: *docker-env <<: *docker-env
<<: *test-refs
script: script:
- cargo contract -V - cargo contract -V
- cd examples/delegator/ && ./build-all.sh - cd examples/delegator/ && ./build-all.sh
examples-docs: examples-docs:
stage: examples stage: examples
<<: *docker-env <<: *docker-env
variables: <<: *test-refs
RUSTDOCFLAGS: -Dwarnings variables:
script: RUSTDOCFLAGS: -Dwarnings
# `--document-private-items` needs to be in here because currently our contract macro script:
# puts the contract functions in a private module. # `--document-private-items` needs to be in here because currently our contract macro
# Once https://github.com/paritytech/ink/issues/336 has been implemented we can get rid # puts the contract functions in a private module.
# of this flag. # Once https://github.com/paritytech/ink/issues/336 has been implemented we can get rid
- for example in examples/*/; do # of this flag.
cargo doc --manifest-path ${example}/Cargo.toml --document-private-items --verbose --no-deps; - for example in examples/*/; do
done cargo doc --manifest-path ${example}/Cargo.toml --document-private-items --verbose --no-deps;
- for contract in ${DELEGATOR_SUBCONTRACTS}; do done
cargo doc --manifest-path examples/delegator/${contract}/Cargo.toml --document-private-items --verbose --no-deps; - for contract in ${DELEGATOR_SUBCONTRACTS}; do
done cargo doc --manifest-path examples/delegator/${contract}/Cargo.toml --document-private-items --verbose --no-deps;
done
#### stage: ink-waterfall #### stage: ink-waterfall
ink-waterfall: ink-waterfall:
stage: ink-waterfall stage: ink-waterfall
image: paritytech/tools:latest
<<: *kubernetes-env
<<: *test-refs
variables: variables:
UPSTREAM_PR_ID: $CI_COMMIT_REF_NAME TRGR_PROJECT: ${CI_PROJECT_NAME}
CI_IMAGE: "paritytech/ink-waterfall-ci:latest" TRGR_REF: ${CI_COMMIT_REF_NAME}
trigger: # The `ink-waterfall` project id in GitLab
project: parity/ink-waterfall DWNSTRM_ID: 409
branch: master script:
strategy: depend - ./scripts/.ci/trigger_pipeline.sh
allow_failure: true
#### stage: publish #### stage: publish
...@@ -366,19 +402,21 @@ ink-waterfall: ...@@ -366,19 +402,21 @@ ink-waterfall:
publish-docs: publish-docs:
stage: publish stage: publish
<<: *docker-env <<: *docker-env
<<: *test-refs
needs: needs:
- job: docs - job: docs
artifacts: true artifacts: true
variables: variables:
GIT_DEPTH: 100 GIT_DEPTH: 100
rules: rules:
- if: $CI_PIPELINE_SOURCE == "web" - if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master" - if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "tags" - if: $CI_COMMIT_REF_NAME == "tags"
# need to overwrite `before_script` from `*docker-env` here, # need to overwrite `before_script` from `*docker-env` here,
# this branch does not have a `./scripts/pre_cache.sh` # this branch does not have a `./scripts/.ci/pre_cache.sh`
before_script: before_script:
- *rust-info-script
- unset CARGO_TARGET_DIR - unset CARGO_TARGET_DIR
script: script:
- rm -rf /tmp/* - rm -rf /tmp/*
...@@ -416,36 +454,37 @@ publish-docs: ...@@ -416,36 +454,37 @@ publish-docs:
#### stage: fuzz #### stage: fuzz
fuzz-tests: fuzz-tests:
stage: fuzz stage: fuzz
<<: *docker-env <<: *docker-env
variables: <<: *test-refs
# The QUICKCHECK_TESTS default is 100 variables:
QUICKCHECK_TESTS: 20000 # The QUICKCHECK_TESTS default is 100
rules: QUICKCHECK_TESTS: 20000
- if: $CI_PIPELINE_SOURCE == "schedule" rules:
- if: $CI_COMMIT_REF_NAME == "master" - if: $CI_PIPELINE_SOURCE == "schedule"
script: - if: $CI_COMMIT_REF_NAME == "master"
# We fuzz-test only crates which possess the `ink-fuzz-tests` feature script:
- all_tests_passed=0 # We fuzz-test only crates which possess the `ink-fuzz-tests` feature
- for crate in ${ALL_CRATES}; do - all_tests_passed=0
if grep "ink-fuzz-tests =" crates/${crate}/Cargo.toml; - for crate in ${ALL_CRATES}; do
then if grep "ink-fuzz-tests =" crates/${crate}/Cargo.toml;
cargo test --verbose --features ink-fuzz-tests --manifest-path crates/${crate}/Cargo.toml --no-fail-fast -- fuzz_ || exit_code=$?; then
all_tests_passed=$(( all_tests_passed | exit_code )); cargo test --verbose --features ink-fuzz-tests --manifest-path crates/${crate}/Cargo.toml --no-fail-fast -- fuzz_ || exit_code=$?;
fi all_tests_passed=$(( all_tests_passed | exit_code ));
done fi
- if [ $all_tests_passed -eq 0 ]; then exit 0; fi done
- | - if [ $all_tests_passed -eq 0 ]; then exit 0; fi
curl -X "POST" "https://api.github.com/repos/paritytech/ink/issues" \ - |
-H "Cookie: logged_in=no" \ curl -X "POST" "https://api.github.com/repos/paritytech/ink/issues" \
-H "Authorization: token ${GITHUB_TOKEN}" \ -H "Cookie: logged_in=no" \
-H "Content-Type: application/json; charset=utf-8" \ -H "Authorization: token ${GITHUB_TOKEN}" \
-d $'{ -H "Content-Type: application/json; charset=utf-8" \
"title": "[ci] Failing fuzz tests on master ('"$( date +"%d %b %Y" )"')", -d $'{
"body": "The CI job ['"${CI_JOB_ID}"']('"${CI_JOB_URL}"') just failed.\n\nThe offending commit is ['"${CI_COMMIT_TITLE}"'](https://github.com/paritytech/ink/commit/'"${CI_COMMIT_SHA}"').", "title": "[ci] Failing fuzz tests on master ('"$( date +"%d %b %Y" )"')",
"assignees": [], "body": "The CI job ['"${CI_JOB_ID}"']('"${CI_JOB_URL}"') just failed.\n\nThe offending commit is ['"${CI_COMMIT_TITLE}"'](https://github.com/paritytech/ink/commit/'"${CI_COMMIT_SHA}"').",
"labels": [ "assignees": [],
"P-high" "labels": [
] "P-high"
}' ]
- exit ${all_tests_passed} }'
- exit ${all_tests_passed}
#!/bin/bash
# This script is mostly copied from here:
# https://github.com/paritytech/polkadot/blob/d822565487bdb41a9e8d73615877a8ea31ae0f6c/scripts/gitlab/trigger_pipeline.sh
set -eu
if [ ! -n "$PIPELINE_TOKEN" ]; then
echo "PIPELINE_TOKEN is missing!"
exit 1
fi
# API trigger another project's pipeline
echo "Triggering ink-waterfall pipeline."
echo "https://${CI_SERVER_HOST}/api/v4/projects/${DWNSTRM_ID}/trigger/pipeline"
curl --silent \
-X POST \
-F "token=${CI_JOB_TOKEN}" \
-F "ref=master" \
-F "variables[TRGR_PROJECT]=${TRGR_PROJECT}" \
-F "variables[TRGR_REF]=${TRGR_REF}" \
"https://${CI_SERVER_HOST}/api/v4/projects/${DWNSTRM_ID}/trigger/pipeline" | \
tee pipeline;
PIPELINE_ID=$(cat pipeline | jq ".id")
PIPELINE_URL=$(cat pipeline | jq ".web_url")
echo
echo "ink-waterfall pipeline ${PIPELINE_URL} was successfully triggered."
echo "Now we're polling it to obtain the distinguished status."
# This is a workaround for a Gitlab bug, waits here until
# https://gitlab.com/gitlab-org/gitlab/-/issues/326137 gets fixed.
# The timeout is 360 curls with 8 sec interval, roughly an hour.
function get_status() {
curl --silent \
--header "PRIVATE-TOKEN: ${PIPELINE_TOKEN}" \
"https://${CI_SERVER_HOST}/api/v4/projects/${DWNSTRM_ID}/pipelines/${PIPELINE_ID}" | \
jq --raw-output ".status";
}
echo "Waiting on ${PIPELINE_ID} status..."
for i in $(seq 1 360); do
STATUS=$(get_status);
echo "Triggered pipeline status is ${STATUS}";
if [[ ${STATUS} =~ ^(pending|running|created)$ ]]; then
echo;
elif [[ ${STATUS} =~ ^(failed|canceled|skipped|manual)$ ]]; then
echo "Something's broken in: ${PIPELINE_URL}"; exit 1;
elif [[ ${STATUS} =~ ^(success)$ ]]; then
echo "Look how green it is: ${PIPELINE_URL}"; exit 0;
else
echo "Something else has happened in ${PIPELINE_URL}"; exit 1;
fi
sleep 5;
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment