Newer
Older
# .gitlab-ci.yml
#
# ink
#
# pipelines can be triggered manually in the web
stages:
CARGO_INCREMENTAL: 0
CARGO_HOME: "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_JOB_NAME}"
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
ALL_CRATES: "core core/derive alloc prelude primitives lang lang/macro lang/ir"
.collect-artifacts: &collect-artifacts
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: on_success
expire_in: 7 days
paths:
- artifacts/
.docker-env: &docker-env
image: paritytech/ink-ci-linux:latest
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "tags"
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
- runner_system_failure
- unknown_failure
- api_failure
cargo check --verbose --all-features --manifest-path crates/${crate}/Cargo.toml;
Andrew Jones
committed
- for crate in ${ALL_CRATES}; do
cargo check --verbose --no-default-features --target wasm32-unknown-unknown --manifest-path crates/${crate}/Cargo.toml;
- job: check-std
artifacts: false
cargo build --verbose --all-features --release --manifest-path crates/${crate}/Cargo.toml;
- job: check-wasm
artifacts: false
Andrew Jones
committed
- for crate in ${ALL_CRATES}; do
cargo build --verbose --no-default-features --release --target wasm32-unknown-unknown --manifest-path crates/${crate}/Cargo.toml;
- job: check-std
artifacts: false
- cargo test --verbose --all-features --no-fail-fast --workspace
codecov:
stage: workspace
<<: *docker-env
needs:
- job: check-std
artifacts: false
# Variables partly came from https://github.com/mozilla/grcov/blob/master/README.md
RUSTFLAGS: "-Zprofile -Zmir-opt-level=0 -Ccodegen-units=1
-Copt-level=0 -Clink-dead-code -Coverflow-checks=off"
# The `cargo-taurpalin` coverage reporting tool seems to have better code instrumentation and thus
# 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.
# We removed the `-Cinline-threshold=0` flag from the above `RUSTFLAGS` since it was bugged
# at the time and lead to inlining of functions that shouldn't be inlined for the coverage
# report. (More information here: https://github.com/Kogia-sima/rust-covfix/issues/2)
script:
# RUSTFLAGS are the cause target cache can't be used here
- unset "CARGO_TARGET_DIR"
- cargo clean
- cargo test --verbose --all-features --no-fail-fast --workspace
- cargo build --verbose --all-features --workspace
# coverage with branches
- grcov ./target -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov-w-branch.info
- rust-covfix -o lcov-w-branch.info lcov-w-branch.info
# We'd like to not use a remote bash script for uploading the coverage reports,
# however this job seems to be more tricky than we hoped.
- bash <(curl -s https://codecov.io/bash) -t "$CODECOV_P_TOKEN" -f lcov-w-branch.info
# lines coverage
- grcov ./target -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov-lines.info
- rust-covfix -o lcov-lines.info lcov-lines.info
- bash <(curl -s https://codecov.io/bash) -f lcov-lines.info
- job: check-std
artifacts: false
cargo clippy --verbose --all-features --manifest-path crates/${crate}/Cargo.toml -- -D warnings;
- job: check-wasm
artifacts: false
Andrew Jones
committed
- for crate in ${ALL_CRATES}; do
cargo clippy --verbose --no-default-features --manifest-path crates/${crate}/Cargo.toml --target wasm32-unknown-unknown -- -D warnings;
.update-cargo-contract: &update-cargo-contract
# `cargo install` returns an error if there is nothing to update, so have to suppress it here temporarily
# restore this once ink! 3.0 is published and the new version of cargo-contract has been released to crates.io
# - cargo install cargo-contract || echo $?
- cargo install --git https://github.com/paritytech/cargo-contract --tag ink-ci || echo $?
- job: clippy-std
artifacts: false
- for example in examples/*/; do
cargo test --verbose --manifest-path ${example}/Cargo.toml;
- for example in examples/*/; do
cargo fmt --verbose --manifest-path ${example}/Cargo.toml -- --check;
- job: clippy-std
artifacts: false
- for example in examples/*/; do
cargo clippy --verbose --manifest-path ${example}/Cargo.toml -- -D warnings;
done
examples-clippy-wasm:
stage: examples
<<: *docker-env
script:
- for example in examples/*/; do
cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
done
examples-contract-build:
stage: examples
<<: *docker-env
script:
- for example in examples/*/; do
pushd $example &&
cargo contract build &&
popd;
done
- job: build-wasm
artifacts: false
- for example in examples/*/; do
#### stage: publish
publish-docs:
stage: publish
<<: *docker-env
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "tags"
# Set git config
- rm .git/config
- git config user.email "devops-team@parity.io"
- git config user.name "${GITHUB_USER}"
- git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/ink.git"
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- git fetch origin gh-pages
-p scale-info -p ink_metadata -p ink_core -p ink_core_derive
-p ink_primitives -p ink_prelude -p ink_lang -p ink_lang_macro
# saving README and docs
- mv target/doc/ /tmp/
- cp README.md /tmp/doc/
- mv _config.yml /tmp/doc/
# remove everything and restore generated docs, README and Jekyll config
- git commit -m "Updated docs for ${CI_COMMIT_REF_NAME} and pushed to gh-pages"