Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): add code coverage report #787

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected]
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 }}
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ wiremock = "0.6.2"

[patch.crates-io]
starknet-core = { git = "https://github.com/kariy/starknet-rs", branch = "dojo-patch" }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
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
Loading