diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99cbc5e09c..5320b47a6b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 @@ -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 diff --git a/README.md b/README.md index a3dba90de4..42ce7cc748 100644 --- a/README.md +++ b/README.md @@ -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] + + +[codecov]: https://codecov.io/gh/burn-rs/burn/ + + +[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 diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 9658a66bb9..9e4571d010 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -21,6 +21,8 @@ enum Command { RunChecks { /// The environment to run checks against env: runchecks::CheckType, + #[arg(short, long)] + jobs: Option, }, } @@ -28,7 +30,7 @@ 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), } } diff --git a/xtask/src/runchecks.rs b/xtask/src/runchecks.rs index 777dd15f41..bdba03c65d 100644 --- a/xtask/src/runchecks.rs +++ b/xtask/src/runchecks.rs @@ -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) { // Set RUSTDOCFLAGS environment variable to treat warnings as errors // for the documentation build env::set_var("RUSTDOCFLAGS", "-D warnings"); @@ -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(); @@ -296,7 +297,7 @@ pub enum CheckType { Examples, } -pub fn run(env: CheckType) -> anyhow::Result<()> { +pub fn run(env: CheckType, jobs: Option) -> anyhow::Result<()> { // Start time measurement let start = Instant::now(); @@ -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(); }