Nix flake checks now do ci-checks (#88)

* Nix flake checks now do ci-checks

* Make sure checks actually run
This commit is contained in:
Ana Hobden 2022-12-05 10:27:12 -08:00 committed by GitHub
parent 898d053c70
commit 444a9fd8f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 59 deletions

View file

@ -22,13 +22,13 @@ jobs:
path: ~/.ci-store
key: lint-store-x86_64-linux-${{ hashFiles('**/Cargo.lock', '**/flake.lock') }}-v1
- name: Check rustfmt
run: nix develop --store ~/.ci-store --command ci-check-rustfmt
run: nix develop --store ~/.ci-store --command check-rustfmt
- name: Check Spelling
run: nix develop --store ~/.ci-store --command ci-check-spelling
run: nix develop --store ~/.ci-store --command check-spelling
- name: Check nixpkgs-fmt formatting
run: nix develop --store ~/.ci-store --command ci-check-nixpkgs-fmt
run: nix develop --store ~/.ci-store --command check-nixpkgs-fmt
- name: Check EditorConfig conformance
run: nix develop --store ~/.ci-store --command ci-check-editorconfig
run: nix develop --store ~/.ci-store --command check-editorconfig
build-x86_64-linux:
name: Build x86_64 Linux

View file

@ -50,15 +50,8 @@
devShells = forAllSystems ({ system, pkgs, ... }:
let
toolchain = fenixToolchain system;
ci = import ./nix/ci.nix { inherit pkgs; };
eclint = import ./nix/eclint.nix { inherit pkgs; };
spellcheck = pkgs.writeScriptBin "spellcheck" ''
${pkgs.codespell}/bin/codespell \
--ignore-words-list crate,pullrequest,pullrequests,ser \
--skip target \
.
'';
check = import ./nix/check.nix { inherit pkgs eclint toolchain; };
in
{
default = pkgs.mkShell {
@ -82,8 +75,11 @@
git
nixpkgs-fmt
eclint
check.check-rustfmt
check.check-spelling
check.check-nixpkgs-fmt
check.check-editorconfig
]
++ ci
++ lib.optionals (pkgs.stdenv.isDarwin) (with pkgs; [ libiconv darwin.apple_sdk.frameworks.Security ]);
};
});
@ -93,14 +89,30 @@
pkgs = import nixpkgs {
inherit system;
};
toolchain = fenixToolchain system;
eclint = import ./nix/eclint.nix { inherit pkgs; };
check = import ./nix/check.nix { inherit pkgs eclint toolchain; };
in
{
format = pkgs.runCommand "check-format"
{
buildInputs = with pkgs; [ rustfmt cargo ];
} ''
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.}
touch $out # it worked!
check-rustfmt = pkgs.runCommand "check-rustfmt" { buildInputs = [ check.check-rustfmt ]; } ''
cd ${./.}
check-rustfmt
touch $out
'';
check-spelling = pkgs.runCommand "check-spelling" { buildInputs = [ check.check-spelling ]; } ''
cd ${./.}
check-spelling
touch $out
'';
check-nixpkgs-fmt = pkgs.runCommand "check-nixpkgs-fmt" { buildInputs = [ check.check-nixpkgs-fmt ]; } ''
cd ${./.}
check-nixpkgs-fmt
touch $out
'';
check-editorconfig = pkgs.runCommand "check-editorconfig" { buildInputs = [ pkgs.git check.check-editorconfig ]; } ''
cd ${./.}
check-editorconfig
touch $out
'';
});
@ -130,7 +142,7 @@
doDoc = true;
doDocFail = true;
RUSTFLAGS = "--cfg tracing_unstable --cfg tokio_unstable";
cargoTestOptions = f: f ++ ["--all"];
cargoTestOptions = f: f ++ [ "--all" ];
override = { preBuild ? "", ... }: {
preBuild = preBuild + ''

44
nix/check.nix Normal file
View file

@ -0,0 +1,44 @@
{ pkgs, eclint, toolchain }:
let
inherit (pkgs) writeShellApplication;
in
{
# Format
check-rustfmt = (writeShellApplication {
name = "check-rustfmt";
runtimeInputs = [ toolchain ];
text = "cargo fmt --check";
});
# Spelling
check-spelling = (writeShellApplication {
name = "check-spelling";
runtimeInputs = with pkgs; [ git codespell ];
text = ''
codespell \
--ignore-words-list ba,sur,crate,pullrequest,pullrequests,ser \
--skip target \
.
'';
});
# NixFormatting
check-nixpkgs-fmt = (writeShellApplication {
name = "check-nixpkgs-fmt";
runtimeInputs = with pkgs; [ git nixpkgs-fmt findutils ];
text = ''
nixpkgs-fmt --check .
'';
});
# EditorConfig
check-editorconfig = (writeShellApplication {
name = "check-editorconfig";
runtimeInputs = with pkgs; [ eclint ];
text = ''
eclint .
'';
});
}

View file

@ -1,39 +0,0 @@
{ pkgs }:
let
inherit (pkgs) writeScriptBin;
in
[
# Format
(writeScriptBin "ci-check-rustfmt" "cargo fmt --check")
# Test
(writeScriptBin "ci-test-rust" "cargo test")
# Spelling
(writeScriptBin "ci-check-spelling" ''
codespell \
--ignore-words-list ba,sur,crate,pullrequest,pullrequests,ser \
--skip target \
.
'')
# NixFormatting
(writeScriptBin "ci-check-nixpkgs-fmt" ''
git ls-files '*.nix' | xargs | nixpkgs-fmt --check
'')
# EditorConfig
(writeScriptBin "ci-check-editorconfig" ''
eclint
'')
(writeScriptBin "ci-all" ''
ci-check-rustfmt
ci-test-rust
ci-check-spelling
ci-check-nixpkgs-fmt
ci-check-editorconfig
'')
]