From 871dc3155b97afc2c51871bda26ecdfa7b7ac1c9 Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Tue, 23 Apr 2024 16:16:53 +0800 Subject: [PATCH] ci: update codecov with nix --- .github/workflows/codecov.yml | 31 ++++++------------------------- .gitignore | 1 + flake.nix | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index ddc16646..f9dd5382 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -14,35 +14,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rustfmt, llvm-tools-preview + - name: Install Nix + uses: cachix/install-nix-action@v26 - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release - env: - CARGO_INCREMENTAL: "0" - RUSTFLAGS: "-Cinstrument-coverage" - RUSTDOCFLAGS: "-Cinstrument-coverage" + run: nix develop .#codecov -c cargo build --release - name: Test - uses: actions-rs/cargo@v1 - with: - command: test - args: --all-features --no-fail-fast - env: - CARGO_INCREMENTAL: "0" - RUSTFLAGS: "-Cinstrument-coverage" - RUSTDOCFLAGS: "-Cinstrument-coverage" + run: nix develop .#codecov -c cargo test --all-features --no-fail-fast - name: Install grcov - run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi + run: nix develop .#codecov -c cargo install grcov - name: Generate coverage - run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov + run: nix develop .#codecov -c grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov - name: Upload coverage uses: codecov/codecov-action@v4 with: diff --git a/.gitignore b/.gitignore index e8ab911e..abf32c92 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ *.swp /dep_test +default*.profraw diff --git a/flake.nix b/flake.nix index 4b2159f1..9b5dd319 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,11 @@ extensions = [ ]; targets = [ "wasm32-unknown-unknown" ]; }; + + stableWithLlvm = pkgs.rust-bin.nightly.latest.default.override { + extensions = [ "rustfmt" "llvm-tools-preview" ]; + targets = [ ]; + }; in with pkgs; { @@ -61,6 +66,15 @@ wasm-pack ]; }; + + codecov = mkShell { + buildInputs = [ + stableWithLlvm + ]; + CARGO_INCREMENTAL = "0"; + RUSTFLAGS = "-Cinstrument-coverage"; + RUSTDOCFLAGS = "-Cinstrument-coverage"; + }; }; } );