Skip to content

Commit da133ba

Browse files
authored
Merge pull request #2391 from CosmWasm/co/fix-coverage
Fix codecov job
2 parents 3d55e51 + 2041b60 commit da133ba

File tree

2 files changed

+71
-43
lines changed

2 files changed

+71
-43
lines changed

.circleci/config.yml

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
version: 2.1
22

33
orbs:
4-
codecov: codecov/[email protected]
5-
win: circleci/[email protected]
4+
win: circleci/[email protected]
65

76
commands:
87
check_contract:
@@ -1182,58 +1181,77 @@ jobs:
11821181
coverage:
11831182
docker:
11841183
- image: rust:1.84.1-alpine3.21
1185-
environment:
1186-
# Limit the number of parallel jobs to avoid OOM crashes during doc testing
1187-
RUST_TEST_THREADS: 8
11881184
resource_class: medium+
11891185
steps:
11901186
- checkout
11911187
- run:
11921188
name: Install necessary packages
11931189
command: |
11941190
apk update
1195-
apk add mold clang curl coreutils gnupg llvm19-dev zlib-static clang19-static
1191+
# needed for grcov and compiling tests
1192+
apk add --no-cache mold clang curl llvm19-dev zlib-static clang19-static lcov
11961193
- run:
1197-
name: Install grcov
1194+
name: Install cargo-llvm-cov and cargo-nextest
11981195
command: |
11991196
rustup component add llvm-tools-preview
1200-
cargo install grcov --locked
1197+
1198+
# cargo-nextest
1199+
curl -L --proto '=https' --tlsv1.2 -OsSf https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-0.9.92/cargo-nextest-0.9.92-x86_64-unknown-linux-musl.tar.gz
1200+
tar -xzf cargo-nextest-0.9.92-x86_64-unknown-linux-musl.tar.gz
1201+
mv cargo-nextest /usr/local/bin/
1202+
1203+
# cargo-llvm-cov
1204+
curl -L --proto '=https' --tlsv1.2 -OsSf https://github.com/taiki-e/cargo-llvm-cov/releases/download/v0.6.16/cargo-llvm-cov-x86_64-unknown-linux-musl.tar.gz
1205+
tar -xzf cargo-llvm-cov-x86_64-unknown-linux-musl.tar.gz
1206+
mv cargo-llvm-cov /usr/local/bin/
1207+
- run:
1208+
name: Install CodeCov CLI
1209+
command: |
1210+
curl -L --proto '=https' --tlsv1.2 -OsSf https://cli.codecov.io/v10.1.1/alpine/codecov
1211+
chmod +x codecov
12011212
- run:
12021213
name: Run tests with coverage
12031214
command: |
1204-
mkdir -p reports
1205-
cargo test --all-features
1215+
# Generate full coverage report
1216+
cargo llvm-cov nextest --lcov --output-path lcov.info
1217+
1218+
# List of package directories and their flags
1219+
set -- \
1220+
"check:cosmwasm-check" \
1221+
"core:cosmwasm-core" \
1222+
"crypto:cosmwasm-crypto" \
1223+
"derive:cosmwasm-derive" \
1224+
"schema:cosmwasm-schema" \
1225+
"schema-derive:cosmwasm-schema-derive" \
1226+
"std:cosmwasm-std" \
1227+
"vm:cosmwasm-vm" \
1228+
"vm-derive:cosmwasm-vm-derive"
1229+
1230+
# Process each package-flag pair
1231+
for entry in "$@"; do
1232+
dir="${entry%%:*}"
1233+
flag="${entry#*:}"
12061234
1207-
grcov . -s packages/core --binary-path ./target/debug -t lcov -o ./reports/core.info
1208-
grcov . -s packages/crypto --binary-path ./target/debug -t lcov -o ./reports/crypto.info
1209-
grcov . -s packages/derive --binary-path ./target/debug -t lcov -o ./reports/derive.info
1210-
grcov . -s packages/schema --binary-path ./target/debug -t lcov -o ./reports/schema.info
1211-
grcov . -s packages/std --binary-path ./target/debug -t lcov -o ./reports/std.info
1212-
grcov . -s packages/vm --binary-path ./target/debug -t lcov -o ./reports/vm.info
1235+
echo "Processing directory: $dir with flag: $flag"
1236+
1237+
# Extract coverage for specific directory using lcov
1238+
lcov \
1239+
--ignore-errors empty,unused \
1240+
--extract lcov.info "packages/$dir/**/*" \
1241+
--output-file "lcov-$dir.info"
1242+
1243+
# Upload filtered report
1244+
./codecov upload-coverage -t "$CODECOV_TOKEN" \
1245+
--disable-search \
1246+
--git-service github \
1247+
--pr "${CIRCLE_PULL_REQUEST##*/}" \
1248+
--branch "$CIRCLE_BRANCH" \
1249+
--sha "$CIRCLE_SHA1" \
1250+
-f "lcov-$dir.info" \
1251+
-F "$flag"
1252+
done
12131253
environment:
1214-
RUSTFLAGS: "-Clinker=clang -Clink-arg=-fuse-ld=/usr/bin/mold -Cinstrument-coverage"
1215-
LLVM_PROFILE_FILE: "cosmwasm-%p-%m.profraw"
1216-
- run:
1217-
name: Quick fix for GPG error in Codecov
1218-
command: mkdir -p ~/.gnupg
1219-
- codecov/upload:
1220-
file: reports/core.info
1221-
flags: cosmwasm-core
1222-
- codecov/upload:
1223-
file: reports/crypto.info
1224-
flags: cosmwasm-crypto
1225-
- codecov/upload:
1226-
file: reports/derive.info
1227-
flags: cosmwasm-derive
1228-
- codecov/upload:
1229-
file: reports/schema.info
1230-
flags: cosmwasm-schema
1231-
- codecov/upload:
1232-
file: reports/std.info
1233-
flags: cosmwasm-std
1234-
- codecov/upload:
1235-
file: reports/vm.info
1236-
flags: cosmwasm-vm
1254+
RUSTFLAGS: "-Clinker=clang -Clink-arg=-fuse-ld=/usr/bin/mold"
12371255

12381256
# This job roughly follows the instructions from https://circleci.com/blog/publishing-to-github-releases-via-circleci/
12391257
build_and_upload_devcontracts:

codecov.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ coverage:
99
default:
1010
threshold: 0.05%
1111

12-
ignore:
13-
- "contracts"
14-
# Disabled due to "cargo_tarpaulin: Failed to get test coverage! Error: Failed to run tests: Error running test - SIGILL raised in 5835"
15-
- "packages/vm"
12+
fixes:
13+
- "/root/project/::" # reduce root, e.g. "/root/project/path/" => "path/"
1614

1715
flags:
16+
cosmwasm-check:
17+
paths:
18+
- packages/check/
19+
cosmwasm-core:
20+
paths:
21+
- packages/core/
1822
cosmwasm-crypto:
1923
paths:
2024
- packages/crypto/
@@ -30,3 +34,9 @@ flags:
3034
cosmwasm-std:
3135
paths:
3236
- packages/std/
37+
cosmwasm-vm:
38+
paths:
39+
- packages/vm/
40+
cosmwasm-vm-derive:
41+
paths:
42+
- packages/vm-derive/

0 commit comments

Comments
 (0)