From 585c3bcda8407fcbc975c831ec49c2b507c08b3d Mon Sep 17 00:00:00 2001 From: Denis P <denis.pisarev@parity.io> Date: Mon, 19 Jul 2021 17:29:50 +0200 Subject: [PATCH 01/10] CI: return codecov job with a token --- .gitlab-ci.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8422ff64f95..4e7fb37c368 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -187,6 +187,51 @@ spellcheck: cargo spellcheck check -vvv --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 examples/delegator/${contract}/; done +codecov: + stage: workspace + <<: *docker-env + <<: *test-refs + needs: + - job: check-std + artifacts: false + variables: + # For codecov it's sufficient to run the fuzz tests only once. + QUICKCHECK_TESTS: 1 + # Variables partly came from https://github.com/mozilla/grcov/blob/master/README.md + CARGO_INCREMENTAL: 0 + 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. + before_script: + - *rust-info-script + - unset "CARGO_TARGET_DIR" + - cargo clean + script: + # RUSTFLAGS are the cause target cache can't be used here + - cargo build --verbose --all-features --workspace + - cargo test --verbose --all-features --no-fail-fast --workspace + + # Just needed as long as we have the `ink-experimental-engine` feature. + # We must additionally run the coverage without `--all-features` here -- this + # would imply the feature `ink-experimental-engine`. So in order to still run + # the tests without the experimental engine feature we need this command. + - cargo test --verbose --features std --no-fail-fast --workspace + + # coverage with branches + - grcov . --source-dir . --output-type lcov --llvm --branch --ignore-not-existing + --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info + - rust-covfix lcov-w-branch.info --output lcov-w-branch-fixed.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-fixed.info + # lines coverage + - grcov . --source-dir . --output-type lcov --llvm --ignore-not-existing + --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info + - rust-covfix lcov-lines.info --output lcov-lines-fixed.info + - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_P_TOKEN" -f lcov-lines-fixed.info + clippy-std: stage: workspace <<: *docker-env From b79eb7c8acfb5271eaaee9d636dcdb370979c8da Mon Sep 17 00:00:00 2001 From: Denis P <denis.pisarev@parity.io> Date: Mon, 19 Jul 2021 17:30:45 +0200 Subject: [PATCH 02/10] CI: typo --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4e7fb37c368..cc2c91dab30 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -230,7 +230,7 @@ codecov: - grcov . --source-dir . --output-type lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info - rust-covfix lcov-lines.info --output lcov-lines-fixed.info - - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_P_TOKEN" -f lcov-lines-fixed.info + - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" -f lcov-lines-fixed.info clippy-std: stage: workspace From aa41087ce8cad33cb64aad5ad152d024ee1f3656 Mon Sep 17 00:00:00 2001 From: Denis P <denis.pisarev@parity.io> Date: Mon, 19 Jul 2021 17:58:23 +0200 Subject: [PATCH 03/10] CI: exit with 1 if not successful --- .gitlab-ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cc2c91dab30..e3c5b30a42d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -225,12 +225,15 @@ codecov: - rust-covfix lcov-w-branch.info --output lcov-w-branch-fixed.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-fixed.info + # -t TOKEN Set the private repository token + # -f FILE Target file(s) to upload + # -Z Exit with 1 if not successful. Default will Exit with 0 + - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_P_TOKEN" -f lcov-w-branch-fixed.info -Z # lines coverage - grcov . --source-dir . --output-type lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info - rust-covfix lcov-lines.info --output lcov-lines-fixed.info - - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" -f lcov-lines-fixed.info + - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" -f lcov-lines-fixed.info -Z clippy-std: stage: workspace From 9bf6d0596e38fc45b8883d5c8b345fc1138dcde3 Mon Sep 17 00:00:00 2001 From: Denis P <denis.pisarev@parity.io> Date: Mon, 19 Jul 2021 18:27:03 +0200 Subject: [PATCH 04/10] CI: binary uploader yay! --- .gitlab-ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e3c5b30a42d..01506375047 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -225,15 +225,12 @@ codecov: - rust-covfix lcov-w-branch.info --output lcov-w-branch-fixed.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. - # -t TOKEN Set the private repository token - # -f FILE Target file(s) to upload - # -Z Exit with 1 if not successful. Default will Exit with 0 - - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_P_TOKEN" -f lcov-w-branch-fixed.info -Z + - codecov --token "$CODECOV_P_TOKEN" --file lcov-w-branch-fixed.info --nonZero # lines coverage - grcov . --source-dir . --output-type lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info - rust-covfix lcov-lines.info --output lcov-lines-fixed.info - - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" -f lcov-lines-fixed.info -Z + - codecov --token "$CODECOV_TOKEN" --file lcov-lines-fixed.info --nonZero clippy-std: stage: workspace From fc6e87b1cf458139f9cf869bfbbfa45c93d426a8 Mon Sep 17 00:00:00 2001 From: Michael Mueller <mich@elmueller.net> Date: Mon, 19 Jul 2021 21:45:57 +0200 Subject: [PATCH 05/10] Remove `-Clink-dead-code` Causes a linker error when building `08-flipper-as-dependency-trait` due to `__ink_enforce_error` otherwise. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 01506375047..19daf26cb42 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -200,7 +200,7 @@ codecov: # Variables partly came from https://github.com/mozilla/grcov/blob/master/README.md CARGO_INCREMENTAL: 0 RUSTFLAGS: "-Zprofile -Zmir-opt-level=0 -Ccodegen-units=1 - -Copt-level=0 -Clink-dead-code -Coverflow-checks=off" + -Copt-level=0 -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. From d7f396ad791b9bee8d0ea08798a1f84c15e7d93e Mon Sep 17 00:00:00 2001 From: Denis P <denis.pisarev@parity.io> Date: Tue, 20 Jul 2021 18:02:33 +0200 Subject: [PATCH 06/10] CI: switch to MIR source-based Rust coverage; return to remote bash uploader --- .gitlab-ci.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 01506375047..86cc24e0274 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -197,19 +197,21 @@ codecov: variables: # For codecov it's sufficient to run the fuzz tests only once. QUICKCHECK_TESTS: 1 - # Variables partly came from https://github.com/mozilla/grcov/blob/master/README.md + # Now we're using the MIR source-based Rust test coverage, the setup assumes that default + # toolchain is nightly and both `grcov` and `rustup component add llvm-tools-preview` are + # installed on it. + RUSTFLAGS: "-Zinstrument-coverage" + LLVM_PROFILE_FILE: "llvmcoveragedata-%p-%m.profraw" CARGO_INCREMENTAL: 0 - 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. before_script: - *rust-info-script + # RUSTFLAGS are the cause target cache can't be used here - unset "CARGO_TARGET_DIR" - cargo clean script: - # RUSTFLAGS are the cause target cache can't be used here - cargo build --verbose --all-features --workspace - cargo test --verbose --all-features --no-fail-fast --workspace @@ -220,17 +222,18 @@ codecov: - cargo test --verbose --features std --no-fail-fast --workspace # coverage with branches - - grcov . --source-dir . --output-type lcov --llvm --branch --ignore-not-existing - --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info + - grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --branch + --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info - rust-covfix lcov-w-branch.info --output lcov-w-branch-fixed.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. - - codecov --token "$CODECOV_P_TOKEN" --file lcov-w-branch-fixed.info --nonZero + # binary named `codecov` is already installed in the CI image, just doesn't work + # https://github.com/codecov/uploader/issues/217 https://github.com/codecov/uploader/issues/222 + - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_P_TOKEN" -f lcov-w-branch-fixed.info -Z # lines coverage - - grcov . --source-dir . --output-type lcov --llvm --ignore-not-existing - --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info + - grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm + --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info - rust-covfix lcov-lines.info --output lcov-lines-fixed.info - - codecov --token "$CODECOV_TOKEN" --file lcov-lines-fixed.info --nonZero + - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" -f lcov-lines-fixed.info -Z clippy-std: stage: workspace From d999cf9808f61fd2ffdbd0ae04999c954befe166 Mon Sep 17 00:00:00 2001 From: Denis P <denis.pisarev@parity.io> Date: Fri, 23 Jul 2021 14:25:18 +0200 Subject: [PATCH 07/10] CI: codecov is fixed; try with cache --- .gitlab-ci.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 86cc24e0274..14cb2243ba6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -209,8 +209,11 @@ codecov: before_script: - *rust-info-script # RUSTFLAGS are the cause target cache can't be used here - - unset "CARGO_TARGET_DIR" - - cargo clean + # FIXME: try with cache + # - unset "CARGO_TARGET_DIR" + # - cargo clean + # make sure there's no stale coverage artifacts + - find . -name "*.profraw" -type f -delete script: - cargo build --verbose --all-features --workspace - cargo test --verbose --all-features --no-fail-fast --workspace @@ -228,12 +231,12 @@ codecov: # We'd like to not use a remote bash script for uploading the coverage reports, # binary named `codecov` is already installed in the CI image, just doesn't work # https://github.com/codecov/uploader/issues/217 https://github.com/codecov/uploader/issues/222 - - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_P_TOKEN" -f lcov-w-branch-fixed.info -Z + - codecov --token "$CODECOV_P_TOKEN" --file lcov-w-branch-fixed.info --nonZero # lines coverage - grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info - rust-covfix lcov-lines.info --output lcov-lines-fixed.info - - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" -f lcov-lines-fixed.info -Z + - codecov --token "$CODECOV_TOKEN" --file lcov-lines-fixed.info --nonZero clippy-std: stage: workspace From 2b38b8645a47bbcb0ea2bd663687df14388e29c0 Mon Sep 17 00:00:00 2001 From: Denis P <denis.pisarev@parity.io> Date: Thu, 29 Jul 2021 15:07:11 +0200 Subject: [PATCH 08/10] CI: try pointing the binary in the CARGO_TARGET_DIR --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 14cb2243ba6..a7061063fd5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -225,7 +225,7 @@ codecov: - cargo test --verbose --features std --no-fail-fast --workspace # coverage with branches - - grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --branch + - grcov . --binary-path ${CARGO_TARGET_DIR}/debug/ --source-dir . --output-type lcov --llvm --branch --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info - rust-covfix lcov-w-branch.info --output lcov-w-branch-fixed.info # We'd like to not use a remote bash script for uploading the coverage reports, @@ -233,7 +233,7 @@ codecov: # https://github.com/codecov/uploader/issues/217 https://github.com/codecov/uploader/issues/222 - codecov --token "$CODECOV_P_TOKEN" --file lcov-w-branch-fixed.info --nonZero # lines coverage - - grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm + - grcov . --binary-path ${CARGO_TARGET_DIR}/debug/ --source-dir . --output-type lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info - rust-covfix lcov-lines.info --output lcov-lines-fixed.info - codecov --token "$CODECOV_TOKEN" --file lcov-lines-fixed.info --nonZero From 644d0abe88a9fd3d6503e4b589fe1456b7e99be6 Mon Sep 17 00:00:00 2001 From: Denis P <denis.pisarev@parity.io> Date: Thu, 29 Jul 2021 15:24:48 +0200 Subject: [PATCH 09/10] CI: cust-covfix doesn't support the external target dir --- .gitlab-ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a7061063fd5..e1e01b8e2e6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -209,9 +209,10 @@ codecov: before_script: - *rust-info-script # RUSTFLAGS are the cause target cache can't be used here - # FIXME: try with cache - # - unset "CARGO_TARGET_DIR" - # - cargo clean + # FIXME: cust-covfix doesn't support the external target dir + # https://github.com/Kogia-sima/rust-covfix/issues/7 + - unset "CARGO_TARGET_DIR" + - cargo clean # make sure there's no stale coverage artifacts - find . -name "*.profraw" -type f -delete script: @@ -225,7 +226,7 @@ codecov: - cargo test --verbose --features std --no-fail-fast --workspace # coverage with branches - - grcov . --binary-path ${CARGO_TARGET_DIR}/debug/ --source-dir . --output-type lcov --llvm --branch + - grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --branch --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info - rust-covfix lcov-w-branch.info --output lcov-w-branch-fixed.info # We'd like to not use a remote bash script for uploading the coverage reports, @@ -233,7 +234,7 @@ codecov: # https://github.com/codecov/uploader/issues/217 https://github.com/codecov/uploader/issues/222 - codecov --token "$CODECOV_P_TOKEN" --file lcov-w-branch-fixed.info --nonZero # lines coverage - - grcov . --binary-path ${CARGO_TARGET_DIR}/debug/ --source-dir . --output-type lcov --llvm + - grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info - rust-covfix lcov-lines.info --output lcov-lines-fixed.info - codecov --token "$CODECOV_TOKEN" --file lcov-lines-fixed.info --nonZero From 3664e96b4ce92432b136ba6b44f6f9ee53392d34 Mon Sep 17 00:00:00 2001 From: Denis P <denis.pisarev@parity.io> Date: Thu, 19 Aug 2021 13:58:08 +0200 Subject: [PATCH 10/10] CI: edit comments [skip ci] --- .gitlab-ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e1e01b8e2e6..2d5127d311f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -218,20 +218,15 @@ codecov: script: - cargo build --verbose --all-features --workspace - cargo test --verbose --all-features --no-fail-fast --workspace - # Just needed as long as we have the `ink-experimental-engine` feature. # We must additionally run the coverage without `--all-features` here -- this # would imply the feature `ink-experimental-engine`. So in order to still run # the tests without the experimental engine feature we need this command. - cargo test --verbose --features std --no-fail-fast --workspace - # coverage with branches - grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --branch --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info - rust-covfix lcov-w-branch.info --output lcov-w-branch-fixed.info - # We'd like to not use a remote bash script for uploading the coverage reports, - # binary named `codecov` is already installed in the CI image, just doesn't work - # https://github.com/codecov/uploader/issues/217 https://github.com/codecov/uploader/issues/222 - codecov --token "$CODECOV_P_TOKEN" --file lcov-w-branch-fixed.info --nonZero # lines coverage - grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm