Skip to content

Commit cef6151

Browse files
committed
ci: update codecov with nix
1 parent 16318c6 commit cef6151

2 files changed

Lines changed: 25 additions & 27 deletions

File tree

.github/workflows/codecov.yml

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,22 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17-
- name: Set up toolchain
18-
uses: actions-rs/toolchain@v1
19-
with:
20-
profile: minimal
21-
toolchain: stable
22-
override: true
23-
components: rustfmt, llvm-tools-preview
17+
- name: Install Nix
18+
uses: cachix/install-nix-action@v26
2419
- name: Build
25-
uses: actions-rs/cargo@v1
26-
with:
27-
command: build
28-
args: --release
29-
env:
30-
CARGO_INCREMENTAL: "0"
31-
RUSTFLAGS: "-Cinstrument-coverage"
32-
RUSTDOCFLAGS: "-Cinstrument-coverage"
20+
run: nix develop .#codecov -c cargo build --release
3321
- name: Test
34-
uses: actions-rs/cargo@v1
35-
with:
36-
command: test
37-
args: --all-features --no-fail-fast
38-
env:
39-
CARGO_INCREMENTAL: "0"
40-
RUSTFLAGS: "-Cinstrument-coverage"
41-
RUSTDOCFLAGS: "-Cinstrument-coverage"
22+
run: nix develop .#codecov -c cargo test --all-features --no-fail-fast --tests
4223
- name: Install grcov
43-
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
24+
run: nix develop .#codecov -c cargo install grcov
4425
- name: Generate coverage
45-
run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov
26+
run: nix develop .#codecov -c grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov
4627
- name: Upload coverage to Codecov
47-
uses: codecov/codecov-action@v3
28+
uses: codecov/codecov-action@v4
4829
with:
4930
files: ./coverage.lcov
5031
flags: rust
51-
fail_ci_if_error: true
32+
# TODO: set true when CODECOV_TOKEN is set
33+
fail_ci_if_error: false
34+
env:
35+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

flake.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
pkg-config
2424
];
2525
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
26+
27+
stableWithLlvm = pkgs.rust-bin.nightly.latest.default.override {
28+
extensions = [ "rustfmt" "llvm-tools-preview" ];
29+
targets = [ ];
30+
};
2631
in
2732
with pkgs;
2833
{
@@ -52,6 +57,15 @@
5257
rust-bin.nightly.latest.default
5358
];
5459
};
60+
61+
codecov = mkShell {
62+
buildInputs = commonPackages ++ [
63+
stableWithLlvm
64+
];
65+
CARGO_INCREMENTAL = "0";
66+
RUSTFLAGS = "-Cinstrument-coverage";
67+
RUSTDOCFLAGS = "-Cinstrument-coverage";
68+
};
5569
};
5670
}
5771
);

0 commit comments

Comments
 (0)