Skip to content

Commit

Permalink
WIP feat(ci): add code coverage report
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-melnychuk committed Sep 28, 2024
1 parent 7f90eda commit 56268db
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,30 @@ jobs:
- uses: crate-ci/typos@v1.24.1
with:
files: .

coverage:
if: ${{ !startsWith(github.head_ref, 'dependabot/') }}
runs-on: ubuntu-latest
env:
BEERUS_TEST_RUN: 1
BEERUS_TEST_STARKNET_URL: https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/v0_7/${{ secrets.ALCHEMY_KEY }}
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: rm -rf /opt/hostedtoolcache
- name: Install Tarpaulin for code coverage
run: cargo install cargo-tarpaulin
# Exclude 'web' directory from coverage
- run: rm -rf ./web
- name: Run tests with coverage
run: cargo tarpaulin --out html
- name: View context attributes
uses: actions/github-script@v7
with:
script: console.log(context)
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./tarpaulin-report.html
#token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions src/bin/beerus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use beerus::{
use tokio::sync::RwLock;
use validator::Validate;

#[cfg(not(tarpaulin_include))] // exclude from coverage report
#[tokio::main]
async fn main() -> eyre::Result<()> {
tracing_subscriber::fmt::init();
Expand Down Expand Up @@ -56,6 +57,7 @@ async fn main() -> eyre::Result<()> {
Ok(())
}

#[cfg(not(tarpaulin_include))] // exclude from coverage report
async fn get_config() -> eyre::Result<ServerConfig> {
let path = std::env::args().nth(1);
let config = if let Some(path) = path {
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ pub mod client;
pub mod config;
pub mod eth;
pub mod exe;

#[cfg(not(tarpaulin_include))] // exclude from coverage report
pub mod gen;

pub mod proof;

#[cfg(not(target_arch = "wasm32"))]
Expand Down

0 comments on commit 56268db

Please sign in to comment.