Skip to content

Commit f2d2344

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

File tree

7 files changed

+139
-10
lines changed

7 files changed

+139
-10
lines changed

.github/workflows/coverage.yaml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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: Install tarpaulin
35+
run: cargo install cargo-tarpaulin --version "^0.27" # Pin version for stability
36+
37+
- name: Run tarpaulin
38+
id: run-tarpaulin
39+
run: |
40+
cargo tarpaulin --workspace \
41+
--exclude client_wasm \
42+
--timeout 360 \
43+
--out Xml \
44+
--out Html \
45+
--output-dir coverage \
46+
--exclude-files 'tests/*' \
47+
--fail-under 70 # Fail if coverage drops below 70%
48+
49+
- name: Upload coverage reports to Codecov
50+
uses: codecov/codecov-action@v3
51+
with:
52+
token: ${{ secrets.CODECOV_TOKEN }}
53+
files: ./coverage/cobertura.xml
54+
fail_ci_if_error: true # Fail if upload fails
55+
verbose: true # Better debugging
56+
57+
- name: Upload coverage report
58+
id: upload-coverage
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: coverage-report
62+
path: coverage/
63+
retention-days: 7
64+
if-no-files-found: error # Fail if no coverage files generated
65+
66+
- name: Check coverage report exists
67+
run: |
68+
if [ ! -f coverage/tarpaulin-report.html ]; then
69+
echo "Coverage report not generated"
70+
exit 1
71+
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: ["check"]
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

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
- "**/*.md"
44+
- "**/*.yml"
45+
- "**/*.yaml"

core/src/http.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ pub mod tests {
696696
use serde_json::json;
697697

698698
use super::*;
699-
use crate::http::{ManifestRequest, ManifestResponse};
699+
use crate::http::{ManifestRequest};
700700

701701
/// Creates a new HTTP request with optional parameters.
702702
#[macro_export]
@@ -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 {
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mod tests {
7979
use crate::{
8080
error::WebProverCoreError,
8181
http::{
82-
JsonKey, ManifestRequest, ManifestResponse, ManifestResponseBody, TemplateVar, HTTP_1_1,
82+
TemplateVar, HTTP_1_1,
8383
},
8484
manifest::Manifest,
8585
request, response,
@@ -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)