nix: pure Rust check/fmt/clippy/test (#2525)
Runs the tests in a Nix build sandbox.
This commit is contained in:
parent
38fcafcf96
commit
71e4268600
|
@ -38,4 +38,4 @@ jobs:
|
|||
env:
|
||||
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
||||
- name: Rust tests.
|
||||
run: nix develop .#test --command cargo test
|
||||
run: nix build .#checks.$(nix eval --impure --raw --expr 'builtins.currentSystem').rust -L
|
||||
|
|
22
flake.nix
22
flake.nix
|
@ -69,7 +69,29 @@
|
|||
server = pkgs.python3.pkgs.callPackage ./nix/server.nix { inherit nix-filter; };
|
||||
in
|
||||
{
|
||||
checks = {
|
||||
rust = with pkgs; rustPlatform.buildRustPackage {
|
||||
name = "rust-checks";
|
||||
src = ./.;
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
buildInputs = [ openssl.dev ];
|
||||
nativeBuildInputs = [ clippy pkg-config protobuf python3 rustfmt ];
|
||||
buildPhase = ''
|
||||
cargo check
|
||||
'';
|
||||
checkPhase = ''
|
||||
cargo fmt -- --check
|
||||
cargo test -j $NIX_BUILD_CORES
|
||||
cargo clippy
|
||||
'';
|
||||
installPhase = "touch $out";
|
||||
} ;
|
||||
};
|
||||
|
||||
formatter = pkgs.nixfmt-rfc-style;
|
||||
|
||||
devShells = with pkgs; rec {
|
||||
default = pure;
|
||||
|
||||
|
|
Loading…
Reference in New Issue