Skip to content

Commit 051904e

Browse files
authored
ci: fix codecov integration and add coverage instrumentation (#17)
1 parent 380a7cc commit 051904e

File tree

3 files changed

+65
-9
lines changed

3 files changed

+65
-9
lines changed

.github/workflows/functional.yml

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Functional tests
22

33
on:
4+
workflow_call:
45
pull_request:
56
merge_group:
67
push:
@@ -10,7 +11,7 @@ env:
1011
CARGO_TERM_COLOR: always
1112

1213
concurrency:
13-
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
group: functional-tests-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1415
cancel-in-progress: true
1516

1617
permissions: {}
@@ -76,9 +77,14 @@ jobs:
7677
7778
- name: Install Rust toolchain
7879
run: |
79-
rustup toolchain install nightly --profile minimal
80+
rustup toolchain install nightly --profile minimal --component llvm-tools-preview
8081
rustup default nightly
8182
83+
- name: Install cargo-llvm-cov
84+
uses: taiki-e/install-action@81ecf985428d5c2ea81dbf079bceca32bc9604ab # v2.62.43
85+
with:
86+
tool: cargo-llvm-cov
87+
8288
- name: Rust cache
8389
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
8490
with:
@@ -93,13 +99,47 @@ jobs:
9399
cache-suffix: "functional-tests"
94100
python-version: "3.12"
95101

102+
- name: Build with coverage instrumentation
103+
run: |
104+
COV_TARGET_DIR="$GITHUB_WORKSPACE/target/llvm-cov-target"
105+
RUSTFLAGS="-Cinstrument-coverage" cargo build --locked --bin strata-asm-runner --target-dir "$COV_TARGET_DIR"
106+
96107
- name: Run functional tests
108+
id: funcTestsRun
109+
continue-on-error: true
97110
env:
98111
NO_COLOR: "1"
99112
LOG_LEVEL: "info"
100113
run: |
114+
export LLVM_PROFILE_FILE="$GITHUB_WORKSPACE/target/llvm-cov-target/asm-%p-%m.profraw"
115+
NEWPATH="$GITHUB_WORKSPACE/target/llvm-cov-target/debug"
116+
export PATH="$NEWPATH:$PATH"
117+
export STRATA_ASM_RUNNER_BIN="$NEWPATH/strata-asm-runner"
101118
cd functional-tests
102-
./run_test.sh
119+
source ./env.bash
120+
uv run python entry.py
121+
122+
- name: Generate coverage lcov
123+
id: genFunctionalLcov
124+
continue-on-error: true
125+
run: |
126+
export CARGO_TARGET_DIR="$GITHUB_WORKSPACE/target"
127+
export LLVM_PROFILE_FILE="$GITHUB_WORKSPACE/target/llvm-cov-target/asm-%p-%m.profraw"
128+
cargo llvm-cov report --lcov > lcov.functional.info
129+
130+
- name: Upload coverage lcov artifact
131+
if: steps.genFunctionalLcov.outcome == 'success'
132+
continue-on-error: true
133+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
134+
with:
135+
name: functional-lcov
136+
path: lcov.functional.info
137+
138+
- name: Fail job if functional tests fail
139+
if: steps.funcTestsRun.outcome == 'failure'
140+
run: |
141+
echo "Functional tests failed"
142+
exit 1
103143
104144
functional-success:
105145
name: Check that functional tests pass

.github/workflows/test-coverage.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ concurrency:
2222
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-test-coverage
2323
cancel-in-progress: true
2424

25-
permissions: {}
25+
permissions:
26+
contents: read
2627

2728
jobs:
2829
unit-tests:
@@ -32,7 +33,7 @@ jobs:
3233
uses: ./.github/workflows/functional.yml
3334

3435
publish-coverage:
35-
name: Check that unit tests pass
36+
name: Publish test coverage
3637
runs-on: ubuntu-latest
3738
if: always()
3839
needs: [functional-tests, unit-tests]
@@ -68,4 +69,5 @@ jobs:
6869
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
6970
env:
7071
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # zizmor: ignore[secrets-outside-env]
72+
with:
7173
files: lcov.info

.github/workflows/unit.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
name: Unit Tests
44

55
on:
6+
workflow_call:
67
pull_request:
78
merge_group:
89
push:
@@ -12,7 +13,7 @@ env:
1213
CARGO_TERM_COLOR: always
1314

1415
concurrency:
15-
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
group: unit-tests-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1617
cancel-in-progress: true
1718

1819
permissions: {}
@@ -32,14 +33,19 @@ jobs:
3233

3334
- name: Install Rust toolchain
3435
run: |
35-
rustup toolchain install nightly --profile minimal
36+
rustup toolchain install nightly --profile minimal --component llvm-tools-preview
3637
rustup default nightly
3738
3839
- name: Install latest cargo-nextest release
3940
uses: taiki-e/install-action@81ecf985428d5c2ea81dbf079bceca32bc9604ab # v2.62.43
4041
with:
4142
tool: nextest
4243

44+
- name: Install cargo-llvm-cov
45+
uses: taiki-e/install-action@81ecf985428d5c2ea81dbf079bceca32bc9604ab # v2.62.43
46+
with:
47+
tool: cargo-llvm-cov
48+
4349
- name: Install bitcoind
4450
env:
4551
BITCOIND_VERSION: "30.2"
@@ -58,9 +64,17 @@ jobs:
5864
with:
5965
cache-on-failure: true
6066

61-
- name: Run tests
67+
- name: Run tests with coverage
6268
run: |
63-
cargo --locked nextest run --all-features
69+
cargo llvm-cov --locked --workspace nextest --all-features --lcov --output-path lcov.unit.info
70+
env:
71+
RUST_BACKTRACE: 1
72+
73+
- name: Upload coverage lcov artifact
74+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
75+
with:
76+
name: unit-lcov
77+
path: lcov.unit.info
6478

6579
doc:
6680
name: Run doc tests

0 commit comments

Comments
 (0)