Skip to content

Commit bc2d158

Browse files
chore(ci): measure coverage in prs
1 parent 12a2763 commit bc2d158

File tree

7 files changed

+146
-8
lines changed

7 files changed

+146
-8
lines changed

.github/workflows/coverage.yaml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Code Coverage
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
web-prover-circuits-cache-key:
7+
required: true
8+
type: string
9+
outputs:
10+
coverage-report:
11+
description: "Path to the coverage report"
12+
value: ${{ jobs.coverage.outputs.coverage-report }}
13+
14+
jobs:
15+
coverage:
16+
name: Generate code coverage
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
checks: write
21+
pull-requests: write # Needed for coverage comments
22+
outputs:
23+
coverage-report: ${{ steps.upload-coverage.outputs.artifact-url }}
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 2 # Needed for coverage comparison in PRs
29+
30+
- uses: ./.github/actions/setup-rust-ubuntu
31+
with:
32+
rust-cache-key: coverage
33+
34+
- name: Fetch web-prover-circuits cache
35+
uses: actions/cache/restore@v4
36+
with:
37+
path: proofs/web_proof_circuits
38+
key: ${{ inputs.web-prover-circuits-cache-key }}
39+
fail-on-error: true
40+
41+
- name: Install tarpaulin
42+
run: cargo install cargo-tarpaulin --version "^0.27" # Pin version for stability
43+
44+
- name: Run tarpaulin
45+
id: run-tarpaulin
46+
run: |
47+
cargo tarpaulin --workspace \
48+
--exclude client_wasm \
49+
--timeout 360 \
50+
--out Xml \
51+
--out Html \
52+
--output-dir coverage \
53+
--exclude-files 'tests/*' \
54+
--fail-under 70 # Fail if coverage drops below 70%
55+
56+
- name: Upload coverage reports to Codecov
57+
uses: codecov/codecov-action@v3
58+
with:
59+
token: ${{ secrets.CODECOV_TOKEN }}
60+
files: ./coverage/cobertura.xml
61+
fail_ci_if_error: true # Fail if upload fails
62+
verbose: true # Better debugging
63+
64+
- name: Upload coverage report
65+
id: upload-coverage
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: coverage-report
69+
path: coverage/
70+
retention-days: 7
71+
if-no-files-found: error # Fail if no coverage files generated
72+
73+
- name: Check coverage report exists
74+
run: |
75+
if [ ! -f coverage/tarpaulin-report.html ]; then
76+
echo "Coverage report not generated"
77+
exit 1
78+
fi

.github/workflows/web-prover.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ jobs:
1515
check:
1616
uses: ./.github/workflows/check.yaml
1717

18+
coverage:
19+
needs: ["web-prover-circuits"]
20+
uses: ./.github/workflows/coverage.yaml
21+
with:
22+
web-prover-circuits-cache-key: ${{ needs.web-prover-circuits.outputs.cache-key }}
23+
secrets: inherit
24+
1825
build_notary:
1926
uses: ./.github/workflows/build_notary.yaml
2027

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@ book/**/*.html
1313
rustls_acme_cache
1414

1515
# rust tools
16-
bacon.toml
16+
bacon.toml
17+
18+
# coverage reports
19+
coverage/
20+
cobertura.xml
21+
tarpaulin-report.html

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# Web Prover
1515

1616
[![web-prover workflow](https://github.com/pluto/web-prover/actions/workflows/web-prover.yaml/badge.svg)](https://github.com/pluto/web-prover/actions/workflows/web-prover.yaml)
17+
[![codecov](https://codecov.io/gh/pluto/web-prover/branch/main/graph/badge.svg)](https://codecov.io/gh/pluto/web-prover)
1718
[![docs](https://img.shields.io/badge/docs-e28f00)](https://docs.pluto.xyz)
1819

1920
The Web Prover is infrastructure for generating Web Proofs with [Trusted Execution Environments (TEEs)](https://pluto.xyz/blog/web-proof-techniques-tee-mode).

codecov.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
codecov:
2+
require_ci_to_pass: true
3+
notify:
4+
wait_for_ci: true
5+
6+
coverage:
7+
precision: 2
8+
round: down
9+
range: "70...100"
10+
status:
11+
project:
12+
default:
13+
target: auto
14+
threshold: 1%
15+
base: auto
16+
if_ci_failed: error
17+
informational: false
18+
only_pulls: false
19+
patch:
20+
default:
21+
target: auto
22+
threshold: 1%
23+
base: auto
24+
if_ci_failed: error
25+
only_pulls: true
26+
27+
parsers:
28+
gcov:
29+
branch_detection:
30+
conditional: true
31+
loop: true
32+
method: false
33+
macro: false
34+
35+
comment:
36+
layout: "reach,diff,flags,files,footer"
37+
behavior: default
38+
require_changes: false
39+
require_base: false
40+
require_head: true
41+
42+
ignore:
43+
- "tests/**/*"
44+
- "**/tests/**/*"
45+
- "**/*.md"
46+
- "**/*.yml"
47+
- "**/*.yaml"

core/src/http.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ pub mod tests {
705705
($($key:ident: $value:expr),* $(,)?) => {{
706706
// Make clippy happy
707707
#[allow(unused_mut) ]
708-
let mut request = ManifestRequest {
708+
let mut request = crate::http::ManifestRequest {
709709
method: "GET".to_string(),
710710
url: "https://example.com".to_string(),
711711
version: "HTTP/1.1".to_string(),
@@ -739,18 +739,18 @@ pub mod tests {
739739
// Match with optional parameters
740740
($($key:ident: $value:expr),* $(,)?) => {{
741741
#[allow(unused_mut)]
742-
let mut response = ManifestResponse {
742+
let mut response = crate::http::ManifestResponse { // Changed from crate::manifest::ManifestResponse
743743
status: "200".to_string(),
744744
version: "HTTP/1.1".to_string(),
745745
message: "OK".to_string(),
746746
headers: std::collections::HashMap::from([
747747
("Content-Type".to_string(), "application/json".to_string())
748748
]),
749-
body: ManifestResponseBody {
749+
body: crate::http::ManifestResponseBody {
750750
json_path: vec![
751-
JsonKey::String("key1".to_string()),
752-
JsonKey::String("key2".to_string()),
753-
JsonKey::Num(3)
751+
crate::http::JsonKey::String("key1".to_string()),
752+
crate::http::JsonKey::String("key2".to_string()),
753+
crate::http::JsonKey::Num(3)
754754
]
755755
},
756756
};

core/src/manifest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ mod tests {
9292
$response:expr
9393
$(, $field:ident = $value:expr)* $(,)?
9494
) => {{
95-
Manifest {
95+
crate::manifest::Manifest {
9696
// manifest_version: "1".to_string(),
9797
// id: "Default Manifest ID".to_string(),
9898
// title: "Default Manifest Title".to_string(),

0 commit comments

Comments
 (0)