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:
paths:
- artifacts/
.docker-env: &docker-env
image: "${CI_IMAGE}"
before_script:
- cargo -vV
- rustc -vV
.rust-info-script: &rust-info-script
- rustup show
- cargo --version
- rustup +nightly show
- cargo +nightly --version
- bash --version
- ./scripts/pre_cache.sh
- sccache -s
.test-refs: &test-refs
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
......@@ -55,6 +55,13 @@ workflow:
- if: $CI_COMMIT_REF_NAME == "tags"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
- 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
retry:
max: 2
......@@ -65,12 +72,23 @@ workflow:
tags:
- 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
check-std:
stage: check
<<: *docker-env
<<: *test-refs
script:
- for crate in ${ALL_CRATES}; do
cargo check --verbose --all-features --manifest-path crates/${crate}/Cargo.toml;
......@@ -79,6 +97,7 @@ check-std:
check-wasm:
stage: check
<<: *docker-env
<<: *test-refs
script:
- for crate in ${ALSO_WASM_CRATES}; do
cargo check --verbose --no-default-features --target wasm32-unknown-unknown --manifest-path crates/${crate}/Cargo.toml;
......@@ -90,6 +109,7 @@ check-wasm:
build-std:
stage: workspace
<<: *docker-env
<<: *test-refs
needs:
- job: check-std
artifacts: false
......@@ -101,6 +121,7 @@ build-std:
build-wasm:
stage: workspace
<<: *docker-env
<<: *test-refs
needs:
- job: check-wasm
artifacts: false
......@@ -112,6 +133,7 @@ build-wasm:
test:
stage: workspace
<<: *docker-env
<<: *test-refs
needs:
- job: check-std
artifacts: false
......@@ -134,6 +156,7 @@ test:
docs:
stage: workspace
<<: *docker-env
<<: *test-refs
variables:
RUSTDOCFLAGS: -Dwarnings
artifacts:
......@@ -153,6 +176,7 @@ docs:
spellcheck:
stage: workspace
<<: *docker-env
<<: *test-refs
script:
- cargo spellcheck check -vvv --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1
- for example in examples/*/; do
......@@ -165,6 +189,7 @@ spellcheck:
codecov:
stage: workspace
<<: *docker-env
<<: *test-refs
needs:
- job: check-std
artifacts: false
......@@ -179,10 +204,7 @@ codecov:
# 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.
before_script:
- cargo -vV
- rustc -vV
- rustup show
- bash --version
- *rust-info-script
- unset "CARGO_TARGET_DIR"
- cargo clean
script:
......@@ -212,6 +234,7 @@ codecov:
clippy-std:
stage: workspace
<<: *docker-env
<<: *test-refs
needs:
- job: check-std
artifacts: false
......@@ -223,6 +246,7 @@ clippy-std:
clippy-wasm:
stage: workspace
<<: *docker-env
<<: *test-refs
needs:
- job: check-wasm
artifacts: false
......@@ -234,9 +258,9 @@ clippy-wasm:
fmt:
stage: workspace
<<: *docker-env
<<: *test-refs
script:
- cargo fmt --verbose --all -- --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
......@@ -246,6 +270,7 @@ fmt:
examples-test:
stage: examples
<<: *docker-env
<<: *test-refs
needs:
- job: clippy-std
artifacts: false
......@@ -260,6 +285,7 @@ examples-test:
examples-test-experimental-engine:
stage: examples
<<: *docker-env
<<: *test-refs
needs:
- job: clippy-std
artifacts: false
......@@ -274,6 +300,7 @@ examples-test-experimental-engine:
examples-fmt:
stage: examples
<<: *docker-env
<<: *test-refs
script:
- for example in examples/*/; do
cargo fmt --verbose --manifest-path ${example}/Cargo.toml -- --check;
......@@ -285,6 +312,7 @@ examples-fmt:
examples-clippy-std:
stage: examples
<<: *docker-env
<<: *test-refs
needs:
- job: clippy-std
artifacts: false
......@@ -299,6 +327,7 @@ examples-clippy-std:
examples-clippy-wasm:
stage: examples
<<: *docker-env
<<: *test-refs
script:
- for example in examples/*/; do
cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
......@@ -310,6 +339,7 @@ examples-clippy-wasm:
examples-contract-build:
stage: examples
<<: *docker-env
<<: *test-refs
script:
- cargo contract -V
- for example in examples/*/; do
......@@ -326,6 +356,7 @@ examples-contract-build:
examples-contract-build-delegator:
stage: examples
<<: *docker-env
<<: *test-refs
script:
- cargo contract -V
- cd examples/delegator/ && ./build-all.sh
......@@ -333,6 +364,7 @@ examples-contract-build-delegator:
examples-docs:
stage: examples
<<: *docker-env
<<: *test-refs
variables:
RUSTDOCFLAGS: -Dwarnings
script:
......@@ -352,13 +384,17 @@ examples-docs:
ink-waterfall:
stage: ink-waterfall
image: paritytech/tools:latest
<<: *kubernetes-env
<<: *test-refs
variables:
UPSTREAM_PR_ID: $CI_COMMIT_REF_NAME
CI_IMAGE: "paritytech/ink-waterfall-ci:latest"
trigger:
project: parity/ink-waterfall
branch: master
strategy: depend
TRGR_PROJECT: ${CI_PROJECT_NAME}
TRGR_REF: ${CI_COMMIT_REF_NAME}
# The `ink-waterfall` project id in GitLab
DWNSTRM_ID: 409
script:
- ./scripts/.ci/trigger_pipeline.sh
allow_failure: true
#### stage: publish
......@@ -366,6 +402,7 @@ ink-waterfall:
publish-docs:
stage: publish
<<: *docker-env
<<: *test-refs
needs:
- job: docs
artifacts: true
......@@ -377,8 +414,9 @@ publish-docs:
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "tags"
# 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:
- *rust-info-script
- unset CARGO_TARGET_DIR
script:
- rm -rf /tmp/*
......@@ -418,6 +456,7 @@ publish-docs:
fuzz-tests:
stage: fuzz
<<: *docker-env
<<: *test-refs
variables:
# The QUICKCHECK_TESTS default is 100
QUICKCHECK_TESTS: 20000
......
#!/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