Skip to content

Commit 82905b0

Browse files
committed
feat(ci): add llvm-cov in ci
1 parent 8f6b016 commit 82905b0

File tree

7 files changed

+69
-10
lines changed

7 files changed

+69
-10
lines changed

.github/workflows/coprocessor-cargo-tests.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- .github/workflows/coprocessor-cargo-tests.yml
3232
- coprocessor/fhevm-engine/**
3333
- coprocessor/proto/**
34+
- ci/coverage-thresholds.json
3435
cargo-tests:
3536
name: coprocessor-cargo-test/cargo-tests (bpr)
3637
needs: check-changes
@@ -54,6 +55,12 @@ jobs:
5455
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
5556
with:
5657
toolchain: stable
58+
components: llvm-tools-preview
59+
60+
- name: Install cargo-llvm-cov
61+
uses: taiki-e/install-action@a37010ded18ff788be4440302bd6830b1ae50d8b # v2.68.25
62+
with:
63+
tool: cargo-llvm-cov
5764

5865
- name: Install cargo dependencies
5966
run: |
@@ -71,8 +78,8 @@ jobs:
7178
~/.cargo/registry
7279
~/.cargo/git
7380
target
74-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
75-
restore-keys: ${{ runner.os }}-cargo-
81+
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
82+
restore-keys: ${{ runner.os }}-cargo-coverage-
7683

7784
- name: Login to GitHub Container Registry
7885
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
@@ -101,7 +108,19 @@ jobs:
101108
run: |
102109
docker run --rm -d -p 4566:4566 --name localstack localstack/localstack:latest
103110
104-
- name: Run tests
111+
- name: Run tests with coverage
112+
run: |
113+
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor \
114+
TEST_GLOBAL_LOCALSTACK=1 \
115+
cargo llvm-cov --workspace --profile coverage -- --test-threads=1
116+
working-directory: coprocessor/fhevm-engine
117+
118+
- name: Coverage summary
119+
if: always()
105120
run: |
106-
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor TEST_GLOBAL_LOCALSTACK=1 cargo test --release -- --test-threads=1
121+
echo '## Coverage: coprocessor/fhevm-engine' >> "$GITHUB_STEP_SUMMARY"
122+
echo '```' >> "$GITHUB_STEP_SUMMARY"
123+
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor \
124+
cargo llvm-cov report --workspace --profile coverage >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || echo 'No coverage data available' >> "$GITHUB_STEP_SUMMARY"
125+
echo '```' >> "$GITHUB_STEP_SUMMARY"
107126
working-directory: coprocessor/fhevm-engine

.github/workflows/kms-connector-tests.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
- kms-connector/Cargo.*
4242
- gateway-contracts/rust-bindings/**
4343
- host-contracts/rust-bindings/**
44+
- ci/coverage-thresholds.json
4445
4546
start-runner:
4647
name: kms-connector-tests/start-runner
@@ -105,7 +106,12 @@ jobs:
105106
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
106107
with:
107108
toolchain: stable
108-
components: rustfmt, clippy
109+
components: rustfmt, clippy, llvm-tools-preview
110+
111+
- name: Install cargo-llvm-cov
112+
uses: taiki-e/install-action@a37010ded18ff788be4440302bd6830b1ae50d8b # v2.68.25
113+
with:
114+
tool: cargo-llvm-cov
109115

110116
- name: Install Protoc
111117
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
@@ -124,11 +130,19 @@ jobs:
124130
- name: Linting
125131
run: cargo clippy --all-targets --all-features -- -D warnings
126132

127-
- name: Run Tests
133+
- name: Run Tests with coverage
128134
env:
129135
BLOCKCHAIN_ACTIONS_TOKEN: ${{ secrets.BLOCKCHAIN_ACTIONS_TOKEN }}
130136
run: |
131-
RUST_BACKTRACE=full cargo test
137+
RUST_BACKTRACE=full cargo llvm-cov --workspace
138+
139+
- name: Coverage summary
140+
if: always()
141+
run: |
142+
echo '## Coverage: kms-connector' >> "$GITHUB_STEP_SUMMARY"
143+
echo '```' >> "$GITHUB_STEP_SUMMARY"
144+
cargo llvm-cov report --workspace >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || echo 'No coverage data available' >> "$GITHUB_STEP_SUMMARY"
145+
echo '```' >> "$GITHUB_STEP_SUMMARY"
132146
133147
stop-runner:
134148
name: kms-connector-tests/stop-runner

.github/workflows/sdk-rust-sdk-tests.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
- 'sdk/rust-sdk/examples/**'
4040
- 'sdk/rust-sdk/Cargo.toml'
4141
- gateway-contracts/rust-bindings/**
42+
- ci/coverage-thresholds.json
4243
4344
start-runner:
4445
name: sdk-rust-sdk-tests/start-runner
@@ -103,7 +104,12 @@ jobs:
103104
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
104105
with:
105106
toolchain: stable
106-
components: rustfmt, clippy
107+
components: rustfmt, clippy, llvm-tools-preview
108+
109+
- name: Install cargo-llvm-cov
110+
uses: taiki-e/install-action@a37010ded18ff788be4440302bd6830b1ae50d8b # v2.68.25
111+
with:
112+
tool: cargo-llvm-cov
107113

108114
- name: Install Protoc
109115
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
@@ -127,11 +133,19 @@ jobs:
127133
run: |
128134
RUST_BACKTRACE=full cargo run --example keygen
129135
130-
- name: Run Tests
136+
- name: Run Tests with coverage
131137
env:
132138
BLOCKCHAIN_ACTIONS_TOKEN: ${{ secrets.BLOCKCHAIN_ACTIONS_TOKEN }}
133139
run: |
134-
RUST_BACKTRACE=full cargo test
140+
RUST_BACKTRACE=full cargo llvm-cov
141+
142+
- name: Coverage summary
143+
if: always()
144+
run: |
145+
echo '## Coverage: sdk/rust-sdk' >> "$GITHUB_STEP_SUMMARY"
146+
echo '```' >> "$GITHUB_STEP_SUMMARY"
147+
cargo llvm-cov report >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || echo 'No coverage data available' >> "$GITHUB_STEP_SUMMARY"
148+
echo '```' >> "$GITHUB_STEP_SUMMARY"
135149
136150
- name: Run Examples
137151
env:

ci/coverage-thresholds.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"coprocessor/fhevm-engine": 40,
3+
"kms-connector": 50,
4+
"sdk/rust-sdk": 60
5+
}

coprocessor/fhevm-engine/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,8 @@ inherits = "release"
111111
opt-level = 1
112112
lto = false
113113
codegen-units = 16
114+
115+
[profile.coverage]
116+
inherits = "release"
117+
lto = false
118+
codegen-units = 16
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[toolchain]
22
channel = "1.91.1"
3+
components = ["llvm-tools-preview"]

kms-connector/rust-toolchain.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[toolchain]
22
channel = "1.92.0"
3+
components = ["llvm-tools-preview"]

0 commit comments

Comments
 (0)