From 205bbd3b72a138e700adc6a84a61724fd6fc0f94 Mon Sep 17 00:00:00 2001 From: Juliano Negri Date: Mon, 11 Sep 2023 08:15:20 -0300 Subject: [PATCH 01/12] include coverage instrumentation --- .github/workflows/test.yml | 22 ++++++++++++++++++++-- xtask/src/runchecks.rs | 35 +++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8536b21b49..fa45c8d571 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: - name: install rust uses: dtolnay/rust-toolchain@master with: - components: rustfmt, clippy + components: rustfmt, clippy, llvm-tools-preview toolchain: ${{ matrix.rust }} - name: caching @@ -52,11 +52,29 @@ jobs: - name: run checks & tests run: RUST_MATRIX=${{ matrix.rust }} cargo xtask run-checks ${{ matrix.test }} + - name: Install Grcov + run: cargo install grcov + + - name: Run grcov + run: grcov . --binary-path target/debug/deps/ -s . -t cobertura --branch --ignore-not-existing --ignore 'target/**' --ignore '../**' --ignore '/*' -o coverage.xml + + - name: Code Coverage Report + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + filename: coverage.xml + badge: true + fail_below_min: false + format: markdown + hide_branch_rate: false + hide_complexity: false + indicators: true + output: both + thresholds: '60 80' + check-typos: runs-on: ubuntu-latest steps: - name: checkout uses: actions/checkout@v4 - - name: run spelling checks using typos run: cargo xtask run-checks typos diff --git a/xtask/src/runchecks.rs b/xtask/src/runchecks.rs index ecef0af2ca..d181c2de78 100644 --- a/xtask/src/runchecks.rs +++ b/xtask/src/runchecks.rs @@ -18,6 +18,7 @@ //! - `typos` to check typos in the source code //! - `examples` to check the examples compile +use std::collections::HashMap; use std::env; use std::process::{Child, Command, Stdio}; use std::str; @@ -62,6 +63,16 @@ fn rustup(target: &str) { // Define and run a cargo command fn run_cargo(command: &str, first_params: &[&str], second_params: &[&str], error: &str) { + run_cargo_with_envs(command, first_params, second_params, error, HashMap::new()); +} + +fn run_cargo_with_envs( + command: &str, + first_params: &[&str], + second_params: &[&str], + error: &str, + envs: HashMap<&str, &str>, +) { // Print cargo command println!( "\ncargo {} {} {}\n", @@ -75,6 +86,7 @@ fn run_cargo(command: &str, first_params: &[&str], second_params: &[&str], error .arg(command) .args(first_params) .args(second_params) + .envs(envs) .stdout(Stdio::inherit()) // Send stdout directly to terminal .stderr(Stdio::inherit()) // Send stderr directly to terminal .spawn() @@ -106,14 +118,21 @@ fn cargo_install(params: &[&str]) { ); } -// Run cargo test command -fn cargo_test(params: &[&str]) { +// Run cargo test command with coverage instrumentation +fn cargo_test_with_coverage(params: &[&str]) { + let envs = [ + ("RUSTFLAGS", "-Cinstrument-coverage"), + ("CARGO_INCREMENTAL", "0"), + ("LLVM_PROFILE_FILE", "coverage-%p-%s.profraw"), + ]; + // Run cargo test - run_cargo( + run_cargo_with_envs( "test", params, &["--color=always", "--", "--color=always"], "Failed to run cargo test", + envs.iter().cloned().collect(), ); } @@ -161,7 +180,7 @@ fn build_and_test_no_std(crate_name: &str) { cargo_build(&["-p", crate_name, "--no-default-features"]); // Run cargo test --no-default-features - cargo_test(&["-p", crate_name, "--no-default-features"]); + cargo_test_with_coverage(&["-p", crate_name, "--no-default-features"]); // Run cargo build --no-default-features --target wasm32-unknown-unknowns cargo_build(&[ @@ -206,10 +225,10 @@ fn burn_core_std() { println!("\n\nRun checks for burn-core crate with tch and wgpu backend"); // Run cargo test --features test-tch - cargo_test(&["-p", "burn-core", "--features", "test-tch"]); + cargo_test_with_coverage(&["-p", "burn-core", "--features", "test-tch"]); // Run cargo test --features test-wgpu - cargo_test(&["-p", "burn-core", "--features", "test-wgpu"]); + cargo_test_with_coverage(&["-p", "burn-core", "--features", "test-wgpu"]); } // Test burn-dataset features @@ -220,7 +239,7 @@ fn burn_dataset_features_std() { cargo_build(&["-p", "burn-dataset", "--all-features"]); // Run cargo test --all-features - cargo_test(&["-p", "burn-dataset", "--all-features"]); + cargo_test_with_coverage(&["-p", "burn-dataset", "--all-features"]); // Run cargo doc --all-features cargo_doc(&["-p", "burn-dataset", "--all-features"]); @@ -237,7 +256,7 @@ fn std_checks() { cargo_build(&["--workspace", "--exclude=xtask"]); // Test each workspace - cargo_test(&["--workspace"]); + cargo_test_with_coverage(&["--workspace"]); // Check format cargo_fmt(); From a4d073dd49c65e48d98815323d2b270ca7fae4cb Mon Sep 17 00:00:00 2001 From: Juliano Negri Date: Mon, 11 Sep 2023 09:04:13 -0300 Subject: [PATCH 02/12] include PR comment --- .github/workflows/test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa45c8d571..7bea3e6707 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -71,6 +71,13 @@ jobs: output: both thresholds: '60 80' + - name: Add Coverage PR Comment + uses: marocchino/sticky-pull-request-comment@v2 + if: github.event_name == 'pull_request' + with: + recreate: true + path: code-coverage-results.md + check-typos: runs-on: ubuntu-latest steps: From dbc97fbbb0dc415337b5f40e37152c8f568dc63c Mon Sep 17 00:00:00 2001 From: Juliano Negri Date: Tue, 12 Sep 2023 10:05:27 -0300 Subject: [PATCH 03/12] coverage as envvar on workflow --- .github/workflows/test.yml | 44 ++++++++++++++++++++------------------ xtask/src/runchecks.rs | 35 +++++++----------------------- 2 files changed, 31 insertions(+), 48 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7bea3e6707..f052e21b59 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,10 @@ jobs: matrix: rust: [stable, 1.71.0] test: ['std', 'no-std'] + include: + - rust: stable + test: std + rustflags: -Cinstrument-coverage steps: - name: free disk space run: | @@ -51,37 +55,35 @@ jobs: - name: run checks & tests run: RUST_MATRIX=${{ matrix.rust }} cargo xtask run-checks ${{ matrix.test }} + env: + RUSTFLAGS: ${{ matrix.rustflags }} + CARGO_INCREMENTAL: 0 + LLVM_PROFILE_FILE: coverage-%p-%s.profraw - - name: Install Grcov - run: cargo install grcov + - name: Install grcov + if: matrix.rust = 'stable' + 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 - run: grcov . --binary-path target/debug/deps/ -s . -t cobertura --branch --ignore-not-existing --ignore 'target/**' --ignore '../**' --ignore '/*' -o coverage.xml - - - name: Code Coverage Report - uses: irongut/CodeCoverageSummary@v1.3.0 - with: - filename: coverage.xml - badge: true - fail_below_min: false - format: markdown - hide_branch_rate: false - hide_complexity: false - indicators: true - output: both - thresholds: '60 80' + if: matrix.rust = 'stable' + run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore 'target/**' --ignore '../**' --ignore '/*' -o lcov.info - - name: Add Coverage PR Comment - uses: marocchino/sticky-pull-request-comment@v2 - if: github.event_name == 'pull_request' + - name: Codecov upload + if: matrix.rust = 'stable' + uses: codecov/codecov-action@v3 with: - recreate: true - path: code-coverage-results.md + files: lcov.info check-typos: runs-on: ubuntu-latest steps: - name: checkout uses: actions/checkout@v4 + - name: run spelling checks using typos run: cargo xtask run-checks typos diff --git a/xtask/src/runchecks.rs b/xtask/src/runchecks.rs index d181c2de78..ecef0af2ca 100644 --- a/xtask/src/runchecks.rs +++ b/xtask/src/runchecks.rs @@ -18,7 +18,6 @@ //! - `typos` to check typos in the source code //! - `examples` to check the examples compile -use std::collections::HashMap; use std::env; use std::process::{Child, Command, Stdio}; use std::str; @@ -63,16 +62,6 @@ fn rustup(target: &str) { // Define and run a cargo command fn run_cargo(command: &str, first_params: &[&str], second_params: &[&str], error: &str) { - run_cargo_with_envs(command, first_params, second_params, error, HashMap::new()); -} - -fn run_cargo_with_envs( - command: &str, - first_params: &[&str], - second_params: &[&str], - error: &str, - envs: HashMap<&str, &str>, -) { // Print cargo command println!( "\ncargo {} {} {}\n", @@ -86,7 +75,6 @@ fn run_cargo_with_envs( .arg(command) .args(first_params) .args(second_params) - .envs(envs) .stdout(Stdio::inherit()) // Send stdout directly to terminal .stderr(Stdio::inherit()) // Send stderr directly to terminal .spawn() @@ -118,21 +106,14 @@ fn cargo_install(params: &[&str]) { ); } -// Run cargo test command with coverage instrumentation -fn cargo_test_with_coverage(params: &[&str]) { - let envs = [ - ("RUSTFLAGS", "-Cinstrument-coverage"), - ("CARGO_INCREMENTAL", "0"), - ("LLVM_PROFILE_FILE", "coverage-%p-%s.profraw"), - ]; - +// Run cargo test command +fn cargo_test(params: &[&str]) { // Run cargo test - run_cargo_with_envs( + run_cargo( "test", params, &["--color=always", "--", "--color=always"], "Failed to run cargo test", - envs.iter().cloned().collect(), ); } @@ -180,7 +161,7 @@ fn build_and_test_no_std(crate_name: &str) { cargo_build(&["-p", crate_name, "--no-default-features"]); // Run cargo test --no-default-features - cargo_test_with_coverage(&["-p", crate_name, "--no-default-features"]); + cargo_test(&["-p", crate_name, "--no-default-features"]); // Run cargo build --no-default-features --target wasm32-unknown-unknowns cargo_build(&[ @@ -225,10 +206,10 @@ fn burn_core_std() { println!("\n\nRun checks for burn-core crate with tch and wgpu backend"); // Run cargo test --features test-tch - cargo_test_with_coverage(&["-p", "burn-core", "--features", "test-tch"]); + cargo_test(&["-p", "burn-core", "--features", "test-tch"]); // Run cargo test --features test-wgpu - cargo_test_with_coverage(&["-p", "burn-core", "--features", "test-wgpu"]); + cargo_test(&["-p", "burn-core", "--features", "test-wgpu"]); } // Test burn-dataset features @@ -239,7 +220,7 @@ fn burn_dataset_features_std() { cargo_build(&["-p", "burn-dataset", "--all-features"]); // Run cargo test --all-features - cargo_test_with_coverage(&["-p", "burn-dataset", "--all-features"]); + cargo_test(&["-p", "burn-dataset", "--all-features"]); // Run cargo doc --all-features cargo_doc(&["-p", "burn-dataset", "--all-features"]); @@ -256,7 +237,7 @@ fn std_checks() { cargo_build(&["--workspace", "--exclude=xtask"]); // Test each workspace - cargo_test_with_coverage(&["--workspace"]); + cargo_test(&["--workspace"]); // Check format cargo_fmt(); From ca9ef94c15e54e13f99a7e8606a8e497c7086192 Mon Sep 17 00:00:00 2001 From: Juliano Negri Date: Tue, 12 Sep 2023 10:05:42 -0300 Subject: [PATCH 04/12] include readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index a3dba90de4..8c8b9ba77e 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,14 @@ [![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 simplifying the process of experimenting, training, and deploying models. From cb0c50b2bd242b2716d1d267eaa2de33602e2099 Mon Sep 17 00:00:00 2001 From: Juliano Negri Date: Tue, 12 Sep 2023 11:00:23 -0300 Subject: [PATCH 05/12] include llvm only when using coverage --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f052e21b59..3edb7ef1e1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,8 +20,8 @@ jobs: test: ['std', 'no-std'] include: - rust: stable - test: std rustflags: -Cinstrument-coverage + rustcomponents: ', llvm-tools-preview' steps: - name: free disk space run: | @@ -37,7 +37,7 @@ jobs: - name: install rust uses: dtolnay/rust-toolchain@master with: - components: rustfmt, clippy, llvm-tools-preview + components: rustfmt, clippy ${{ matrix.rustcomponents }} toolchain: ${{ matrix.rust }} - name: caching From 58378f507dad2f335f3305ec16c9c23785b2ef7a Mon Sep 17 00:00:00 2001 From: Juliano Negri Date: Tue, 12 Sep 2023 11:00:33 -0300 Subject: [PATCH 06/12] blank space on readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 8c8b9ba77e..42ce7cc748 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ [![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] From 92b580820675a1555eb0f982d68290ccbd52b497 Mon Sep 17 00:00:00 2001 From: Juliano Negri Date: Tue, 12 Sep 2023 13:29:47 -0300 Subject: [PATCH 07/12] typo on condition --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3edb7ef1e1..7b8a209370 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,7 +61,7 @@ jobs: LLVM_PROFILE_FILE: coverage-%p-%s.profraw - name: Install grcov - if: matrix.rust = 'stable' + if: matrix.rust == 'stable' env: GRCOV_LINK: https://github.com/mozilla/grcov/releases/download GRCOV_VERSION: v0.8.18 @@ -70,11 +70,11 @@ jobs: tar xj -C $HOME/.cargo/bin - name: Run grcov - if: matrix.rust = 'stable' + if: matrix.rust == 'stable' 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' + if: matrix.rust == 'stable' uses: codecov/codecov-action@v3 with: files: lcov.info From bb849847b963b8767773b5746e0b097ea221ca59 Mon Sep 17 00:00:00 2001 From: Juliano Negri Date: Tue, 12 Sep 2023 22:44:59 -0300 Subject: [PATCH 08/12] profile does not work on no-std --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b8a209370..df3aaafe1c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,7 @@ jobs: test: ['std', 'no-std'] include: - rust: stable + test: std rustflags: -Cinstrument-coverage rustcomponents: ', llvm-tools-preview' steps: @@ -61,7 +62,7 @@ jobs: LLVM_PROFILE_FILE: coverage-%p-%s.profraw - name: Install grcov - if: matrix.rust == 'stable' + if: matrix.rust == 'stable' && matrix.test == 'std' env: GRCOV_LINK: https://github.com/mozilla/grcov/releases/download GRCOV_VERSION: v0.8.18 @@ -70,11 +71,11 @@ jobs: tar xj -C $HOME/.cargo/bin - name: Run grcov - if: matrix.rust == 'stable' + 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' + if: matrix.rust == 'stable' && matrix.test == 'std' uses: codecov/codecov-action@v3 with: files: lcov.info From 8619aa3312834cccc75d000ab8eed35bc86f6e58 Mon Sep 17 00:00:00 2001 From: gonzalesmk Date: Wed, 20 Sep 2023 14:06:47 -0300 Subject: [PATCH 09/12] add alloc extern crate --- burn-candle/src/lib.rs | 1 + burn-tch/src/lib.rs | 2 ++ burn-tensor/src/tests/ops/cat.rs | 9 +++++++++ burn-wgpu/src/lib.rs | 1 + 4 files changed, 13 insertions(+) diff --git a/burn-candle/src/lib.rs b/burn-candle/src/lib.rs index 3cc8ec3074..29fe72ecab 100644 --- a/burn-candle/src/lib.rs +++ b/burn-candle/src/lib.rs @@ -15,6 +15,7 @@ pub use tensor::*; #[cfg(test)] mod tests { + extern crate alloc; use super::*; pub type TestBackend = CandleBackend; diff --git a/burn-tch/src/lib.rs b/burn-tch/src/lib.rs index 008f12e0f1..1111347daf 100644 --- a/burn-tch/src/lib.rs +++ b/burn-tch/src/lib.rs @@ -14,6 +14,8 @@ pub use tensor::*; #[cfg(test)] mod tests { + extern crate alloc; + type TestBackend = crate::TchBackend; type TestTensor = burn_tensor::Tensor; type TestTensorInt = burn_tensor::Tensor; diff --git a/burn-tensor/src/tests/ops/cat.rs b/burn-tensor/src/tests/ops/cat.rs index e7b7c8ef0f..6b9a99817c 100644 --- a/burn-tensor/src/tests/ops/cat.rs +++ b/burn-tensor/src/tests/ops/cat.rs @@ -1,6 +1,7 @@ #[burn_tensor_testgen::testgen(cat)] mod tests { use super::*; + use alloc::vec::Vec; use burn_tensor::{Bool, Data, Int, Tensor}; #[test] @@ -57,4 +58,12 @@ mod tests { let data_expected = Data::from([[[1.0, 2.0, 3.0]], [[1.1, 2.1, 3.1]], [[4.0, 5.0, 6.0]]]); data_expected.assert_approx_eq(&data_actual, 3); } + + #[test] + #[should_panic] + fn should_panic_when_list_of_vectors_is_empty() { + let tensor: Vec> = vec![]; + + TestTensor::cat(tensor, 0).into_data(); + } } diff --git a/burn-wgpu/src/lib.rs b/burn-wgpu/src/lib.rs index ce43182aad..32dc2659bf 100644 --- a/burn-wgpu/src/lib.rs +++ b/burn-wgpu/src/lib.rs @@ -4,6 +4,7 @@ #[macro_use] extern crate derive_new; +extern crate alloc; mod ops; From 115d735e928166accd3a15132ca6f47442b9586e Mon Sep 17 00:00:00 2001 From: gonzalesmk Date: Wed, 20 Sep 2023 14:40:39 -0300 Subject: [PATCH 10/12] Revert "add alloc extern crate" This reverts commit 8619aa3312834cccc75d000ab8eed35bc86f6e58. --- burn-candle/src/lib.rs | 1 - burn-tch/src/lib.rs | 2 -- burn-tensor/src/tests/ops/cat.rs | 9 --------- burn-wgpu/src/lib.rs | 1 - 4 files changed, 13 deletions(-) diff --git a/burn-candle/src/lib.rs b/burn-candle/src/lib.rs index 29fe72ecab..3cc8ec3074 100644 --- a/burn-candle/src/lib.rs +++ b/burn-candle/src/lib.rs @@ -15,7 +15,6 @@ pub use tensor::*; #[cfg(test)] mod tests { - extern crate alloc; use super::*; pub type TestBackend = CandleBackend; diff --git a/burn-tch/src/lib.rs b/burn-tch/src/lib.rs index 1111347daf..008f12e0f1 100644 --- a/burn-tch/src/lib.rs +++ b/burn-tch/src/lib.rs @@ -14,8 +14,6 @@ pub use tensor::*; #[cfg(test)] mod tests { - extern crate alloc; - type TestBackend = crate::TchBackend; type TestTensor = burn_tensor::Tensor; type TestTensorInt = burn_tensor::Tensor; diff --git a/burn-tensor/src/tests/ops/cat.rs b/burn-tensor/src/tests/ops/cat.rs index 6b9a99817c..e7b7c8ef0f 100644 --- a/burn-tensor/src/tests/ops/cat.rs +++ b/burn-tensor/src/tests/ops/cat.rs @@ -1,7 +1,6 @@ #[burn_tensor_testgen::testgen(cat)] mod tests { use super::*; - use alloc::vec::Vec; use burn_tensor::{Bool, Data, Int, Tensor}; #[test] @@ -58,12 +57,4 @@ mod tests { let data_expected = Data::from([[[1.0, 2.0, 3.0]], [[1.1, 2.1, 3.1]], [[4.0, 5.0, 6.0]]]); data_expected.assert_approx_eq(&data_actual, 3); } - - #[test] - #[should_panic] - fn should_panic_when_list_of_vectors_is_empty() { - let tensor: Vec> = vec![]; - - TestTensor::cat(tensor, 0).into_data(); - } } diff --git a/burn-wgpu/src/lib.rs b/burn-wgpu/src/lib.rs index 32dc2659bf..ce43182aad 100644 --- a/burn-wgpu/src/lib.rs +++ b/burn-wgpu/src/lib.rs @@ -4,7 +4,6 @@ #[macro_use] extern crate derive_new; -extern crate alloc; mod ops; From b57d47a15144e911419dfe60f87a132d0c9141ac Mon Sep 17 00:00:00 2001 From: gonzalesmk Date: Sun, 24 Sep 2023 00:59:22 -0300 Subject: [PATCH 11/12] include option to set cargo test --jobs --- .github/workflows/test.yml | 5 +++-- xtask/src/main.rs | 4 +++- xtask/src/runchecks.rs | 11 ++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index df3aaafe1c..50379bf701 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,8 +21,9 @@ jobs: include: - rust: stable test: std - rustflags: -Cinstrument-coverage + rustflags: -Cinstrument-coverage -Clink-dead-code rustcomponents: ', llvm-tools-preview' + testflags: --jobs 6 steps: - name: free disk space run: | @@ -55,7 +56,7 @@ 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 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 ecef0af2ca..81123c0dfb 100644 --- a/xtask/src/runchecks.rs +++ b/xtask/src/runchecks.rs @@ -226,7 +226,7 @@ fn burn_dataset_features_std() { cargo_doc(&["-p", "burn-dataset", "--all-features"]); } -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"); @@ -237,7 +237,8 @@ fn std_checks() { cargo_build(&["--workspace", "--exclude=xtask"]); // Test each workspace - cargo_test(&["--workspace"]); + let njobs = jobs.map_or(String::new(), |n| format!("--jobs={}", n)); + cargo_test(&["--workspace", njobs.as_str()]); // Check format cargo_fmt(); @@ -314,7 +315,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(); @@ -325,14 +326,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(); } } From 96cb03cec42058b2764a514b93c4956fdf228c88 Mon Sep 17 00:00:00 2001 From: Juliano Decico Negri <17677891+gonzalesMK@users.noreply.github.com> Date: Fri, 6 Oct 2023 09:21:28 -0300 Subject: [PATCH 12/12] set 4 jobs --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 832d459627..5320b47a6b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: test: std rustflags: -Cinstrument-coverage -Clink-dead-code rustcomponents: ', llvm-tools-preview' - testflags: --jobs 6 + testflags: --jobs 4 cache: stable - rust: 1.71.0 cache: 1-71-0