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

include coverage instrumentation #797

Closed
wants to merge 14 commits into from
40 changes: 33 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ jobs:
rust: [stable, 1.71.0]
test: ['std', 'no-std']
include:
- cache: stable
rust: stable
- cache: 1-71-0
rust: 1.71.0

- rust: stable
test: std
rustflags: -Cinstrument-coverage -Clink-dead-code
rustcomponents: ', llvm-tools-preview'
testflags: --jobs 4
cache: stable
- rust: 1.71.0
cache: 1-71-0
steps:

- name: checkout
Expand All @@ -32,7 +35,7 @@ jobs:
- name: install rust
uses: dtolnay/rust-toolchain@master
with:
components: rustfmt, clippy
components: rustfmt, clippy ${{ matrix.rustcomponents }}
toolchain: ${{ matrix.rust }}

- name: caching
Expand All @@ -58,7 +61,30 @@ jobs:
sudo apt install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers

- name: run checks & tests
run: RUST_MATRIX=${{ matrix.rust }} cargo xtask run-checks ${{ matrix.test }}
run: RUST_MATRIX=${{ matrix.rust }} cargo xtask run-checks ${{ matrix.test }} ${{ matrix.testflags }}
env:
RUSTFLAGS: ${{ matrix.rustflags }}
CARGO_INCREMENTAL: 0
LLVM_PROFILE_FILE: coverage-%p-%s.profraw

- name: Install grcov
if: matrix.rust == 'stable' && matrix.test == 'std'
env:
GRCOV_LINK: https://github.com/mozilla/grcov/releases/download
GRCOV_VERSION: v0.8.18
run: |
curl -L "$GRCOV_LINK/$GRCOV_VERSION/grcov-x86_64-unknown-linux-musl.tar.bz2" |
tar xj -C $HOME/.cargo/bin

- name: Run grcov
if: matrix.rust == 'stable' && matrix.test == 'std'
run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore 'target/**' --ignore '../**' --ignore '/*' -o lcov.info

- name: Codecov upload
if: matrix.rust == 'stable' && matrix.test == 'std'
uses: codecov/codecov-action@v3
with:
files: lcov.info

check-typos:
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
[![Current Crates.io Version](https://img.shields.io/crates/v/burn.svg)](https://crates.io/crates/burn)
[![Rust Version](https://img.shields.io/badge/Rust-1.71.0+-blue)](https://releases.rs/docs/1.71.0)
![license](https://shields.io/badge/license-MIT%2FApache--2.0-blue)
[![CodeCov][codecov badge]][codecov]

<!-- Links -->
[codecov]: https://codecov.io/gh/burn-rs/burn/

<!-- Badges -->
[codecov badge]: https://codecov.io/gh/burn-rs/burn/branch/main/graph/badge.svg

This library strives to serve as a comprehensive **deep learning framework**, offering exceptional
flexibility and written in Rust. Our objective is to cater to both researchers and practitioners by
Expand Down
4 changes: 3 additions & 1 deletion xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ enum Command {
RunChecks {
/// The environment to run checks against
env: runchecks::CheckType,
#[arg(short, long)]
jobs: Option<u32>,
},
}

fn main() -> anyhow::Result<()> {
let args = Args::parse();

match args.command {
Command::RunChecks { env } => runchecks::run(env),
Command::RunChecks { env, jobs } => runchecks::run(env, jobs),
Command::Publish { name } => publish::run(name),
}
}
11 changes: 6 additions & 5 deletions xtask/src/runchecks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn burn_dataset_features_std() {
cargo_doc(["-p", "burn-dataset", "--all-features"].into());
}

fn std_checks() {
fn std_checks(jobs: Option<u32>) {
// Set RUSTDOCFLAGS environment variable to treat warnings as errors
// for the documentation build
env::set_var("RUSTDOCFLAGS", "-D warnings");
Expand All @@ -215,7 +215,8 @@ fn std_checks() {
cargo_build(["--workspace", "--exclude=xtask"].into());

// Test each workspace
cargo_test(["--workspace"].into());
let njobs = jobs.map_or(String::new(), |n| format!("--jobs={}", n));
cargo_test(["--workspace", njobs.as_str()].into());

// Check format
cargo_fmt();
Expand Down Expand Up @@ -296,7 +297,7 @@ pub enum CheckType {
Examples,
}

pub fn run(env: CheckType) -> anyhow::Result<()> {
pub fn run(env: CheckType, jobs: Option<u32>) -> anyhow::Result<()> {
// Start time measurement
let start = Instant::now();

Expand All @@ -308,14 +309,14 @@ pub fn run(env: CheckType) -> anyhow::Result<()> {
//
// If no environment has been passed, run all checks.
match env {
CheckType::Std => std_checks(),
CheckType::Std => std_checks(jobs),
CheckType::NoStd => no_std_checks(),
CheckType::Typos => check_typos(),
CheckType::Examples => check_examples(),
CheckType::All => {
/* Run all checks */
check_typos();
std_checks();
std_checks(jobs);
no_std_checks();
check_examples();
}
Expand Down
Loading