Skip to content

Commit 56268db

Browse files
WIP feat(ci): add code coverage report
1 parent 7f90eda commit 56268db

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

.github/workflows/check.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,30 @@ jobs:
8484
- uses: crate-ci/typos@v1.24.1
8585
with:
8686
files: .
87+
88+
coverage:
89+
if: ${{ !startsWith(github.head_ref, 'dependabot/') }}
90+
runs-on: ubuntu-latest
91+
env:
92+
BEERUS_TEST_RUN: 1
93+
BEERUS_TEST_STARKNET_URL: https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/v0_7/${{ secrets.ALCHEMY_KEY }}
94+
steps:
95+
- uses: actions/checkout@v3
96+
- uses: dtolnay/rust-toolchain@stable
97+
- uses: Swatinem/rust-cache@v2
98+
- run: rm -rf /opt/hostedtoolcache
99+
- name: Install Tarpaulin for code coverage
100+
run: cargo install cargo-tarpaulin
101+
# Exclude 'web' directory from coverage
102+
- run: rm -rf ./web
103+
- name: Run tests with coverage
104+
run: cargo tarpaulin --out html
105+
- name: View context attributes
106+
uses: actions/github-script@v7
107+
with:
108+
script: console.log(context)
109+
- name: Upload coverage to Codecov
110+
uses: codecov/codecov-action@v4
111+
with:
112+
files: ./tarpaulin-report.html
113+
#token: ${{ secrets.CODECOV_TOKEN }}

src/bin/beerus.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use beerus::{
77
use tokio::sync::RwLock;
88
use validator::Validate;
99

10+
#[cfg(not(tarpaulin_include))] // exclude from coverage report
1011
#[tokio::main]
1112
async fn main() -> eyre::Result<()> {
1213
tracing_subscriber::fmt::init();
@@ -56,6 +57,7 @@ async fn main() -> eyre::Result<()> {
5657
Ok(())
5758
}
5859

60+
#[cfg(not(tarpaulin_include))] // exclude from coverage report
5961
async fn get_config() -> eyre::Result<ServerConfig> {
6062
let path = std::env::args().nth(1);
6163
let config = if let Some(path) = path {

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ pub mod client;
22
pub mod config;
33
pub mod eth;
44
pub mod exe;
5+
6+
#[cfg(not(tarpaulin_include))] // exclude from coverage report
57
pub mod gen;
8+
69
pub mod proof;
710

811
#[cfg(not(target_arch = "wasm32"))]

0 commit comments

Comments
 (0)