Skip to content

Commit

Permalink
ci: update codecov with nix
Browse files Browse the repository at this point in the history
  • Loading branch information
yanganto committed Apr 23, 2024
1 parent 16318c6 commit 9027740
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
38 changes: 11 additions & 27 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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 to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: ./coverage.lcov
flags: rust
fail_ci_if_error: true
# TODO: set true when CODECOV_TOKEN is set
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
14 changes: 14 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
pkg-config
];
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);

stableWithLlvm = pkgs.rust-bin.nightly.latest.default.override {
extensions = [ "rustfmt" "llvm-tools-preview" ];
targets = [ ];
};
in
with pkgs;
{
Expand Down Expand Up @@ -52,6 +57,15 @@
rust-bin.nightly.latest.default
];
};

codecov = mkShell {
buildInputs = commonPackages ++ [
stableWithLlvm
];
CARGO_INCREMENTAL = "0";
RUSTFLAGS = "-Cinstrument-coverage";
RUSTDOCFLAGS = "-Cinstrument-coverage";
};
};
}
);
Expand Down

0 comments on commit 9027740

Please sign in to comment.