Skip to content

Commit 2714513

Browse files
chore(ci): measure coverage in prs
1 parent 1786a25 commit 2714513

File tree

8 files changed

+155
-16
lines changed

8 files changed

+155
-16
lines changed

.github/workflows/coverage.yaml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
--timeout 360 \
49+
--out Xml \
50+
--out Html \
51+
--output-dir coverage \
52+
--exclude-files 'tests/*' \
53+
--fail-under 70 # Fail if coverage drops below 70%
54+
55+
- name: Upload coverage reports to Codecov
56+
uses: codecov/codecov-action@v3
57+
with:
58+
token: ${{ secrets.CODECOV_TOKEN }}
59+
files: ./coverage/cobertura.xml
60+
fail_ci_if_error: true # Fail if upload fails
61+
verbose: true # Better debugging
62+
63+
- name: Upload coverage report
64+
id: upload-coverage
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: coverage-report
68+
path: coverage/
69+
retention-days: 7
70+
if-no-files-found: error # Fail if no coverage files generated
71+
72+
- name: Check coverage report exists
73+
run: |
74+
if [ ! -f coverage/tarpaulin-report.html ]; then
75+
echo "Coverage report not generated"
76+
exit 1
77+
fi

.github/workflows/web-prover.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ jobs:
2020
with:
2121
web-prover-circuits-cache-key: ${{ needs.web-prover-circuits.outputs.cache-key }}
2222

23+
coverage:
24+
needs: ["web-prover-circuits"]
25+
uses: ./.github/workflows/coverage.yaml
26+
with:
27+
web-prover-circuits-cache-key: ${{ needs.web-prover-circuits.outputs.cache-key }}
28+
secrets: inherit
29+
2330
build_notary:
2431
needs: ["web-prover-circuits"]
2532
uses: ./.github/workflows/build_notary.yaml

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ client_ios/demo/demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChec
3030
*.zip
3131

3232
# rust tools
33-
bacon.toml
33+
bacon.toml
34+
35+
# coverage reports
36+
coverage/
37+
cobertura.xml
38+
tarpaulin-report.html

Makefile

+6-1
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,9 @@ wasm-demo/node_modules:
6464
wasm-demo: wasm-demo/node_modules
6565
cd client_wasm/demo && npm run start
6666

67-
.PHONY: wasm wasm-debug wasm-demo ios
67+
coverage: artifacts
68+
-cargo install cargo-tarpaulin
69+
cargo tarpaulin --workspace --timeout 360 --out Xml --out Html --output-dir coverage
70+
@echo "Coverage report generated in coverage/tarpaulin-report.html"
71+
72+
.PHONY: wasm wasm-debug wasm-demo ios coverage

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Web Prover
22

33
[![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)
4+
[![codecov](https://codecov.io/gh/pluto/web-prover/branch/main/graph/badge.svg)](https://codecov.io/gh/pluto/web-prover)
45
[![docs](https://img.shields.io/badge/docs-e28f00)](https://docs.pluto.xyz)
56

67
The Web Prover is infrastructure for generating Web Proofs. There are 3 components of the Web Prover — (1) the Client Crates, which run inside of the app or browser; (2) Notary Crate, which is a hosted service; and (3) the Proofs Crate, which handles running the circuits through the `client-side-prover`.

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"

web-prover-core/src/http.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ pub mod tests {
685685
macro_rules! request {
686686
// Match with optional parameters
687687
($($key:ident: $value:expr),* $(,)?) => {{
688-
let mut request = ManifestRequest {
688+
let mut request = crate::http::ManifestRequest {
689689
method: "GET".to_string(),
690690
url: "https://example.com".to_string(),
691691
version: "HTTP/1.1".to_string(),
@@ -719,18 +719,18 @@ pub mod tests {
719719
// Match with optional parameters
720720
($($key:ident: $value:expr),* $(,)?) => {{
721721
#[allow(unused_mut)]
722-
let mut response = ManifestResponse {
722+
let mut response = crate::http::ManifestResponse { // Changed from crate::manifest::ManifestResponse
723723
status: "200".to_string(),
724724
version: "HTTP/1.1".to_string(),
725725
message: "OK".to_string(),
726726
headers: std::collections::HashMap::from([
727727
("Content-Type".to_string(), "application/json".to_string())
728728
]),
729-
body: ManifestResponseBody {
729+
body: crate::http::ManifestResponseBody {
730730
json_path: vec![
731-
JsonKey::String("key1".to_string()),
732-
JsonKey::String("key2".to_string()),
733-
JsonKey::Num(3)
731+
crate::http::JsonKey::String("key1".to_string()),
732+
crate::http::JsonKey::String("key2".to_string()),
733+
crate::http::JsonKey::Num(3)
734734
]
735735
},
736736
};

web-prover-core/src/manifest.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,11 @@ mod tests {
7777
use std::collections::HashMap;
7878

7979
use crate::{
80-
errors::ProofError,
81-
program::{
82-
http::{JsonKey, ManifestRequest, ManifestResponse, ManifestResponseBody, TemplateVar},
83-
manifest::HTTP_1_1,
84-
plain_manifest::Manifest,
85-
},
80+
errors::ManifestError,
81+
http::{TemplateVar, HTTP_1_1},
82+
manifest::Manifest,
8683
request, response,
87-
tests::inputs::TEST_MANIFEST,
84+
test_utils::TEST_MANIFEST,
8885
};
8986

9087
macro_rules! create_manifest {
@@ -93,7 +90,7 @@ mod tests {
9390
$response:expr
9491
$(, $field:ident = $value:expr)* $(,)?
9592
) => {{
96-
Manifest {
93+
crate::manifest::Manifest {
9794
// manifest_version: "1".to_string(),
9895
// id: "Default Manifest ID".to_string(),
9996
// title: "Default Manifest Title".to_string(),

0 commit comments

Comments
 (0)