tests: perform code formatting test in test suite
This should improve visibility when CI job fails due to bad formatting.
This commit is contained in:
parent
3a80ece9fa
commit
8bbefa77f7
|
@ -11,7 +11,6 @@ stages:
|
||||||
Run tests:
|
Run tests:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- ./format -c && echo Format is OK
|
|
||||||
- nix-shell --pure tests -A run.files-text
|
- nix-shell --pure tests -A run.files-text
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH == "master"
|
- if: $CI_COMMIT_BRANCH == "master"
|
||||||
|
|
|
@ -5,6 +5,5 @@ os:
|
||||||
- osx
|
- osx
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- ./format -c
|
|
||||||
- nix-shell . -A install
|
- nix-shell . -A install
|
||||||
- nix-shell --pure --max-jobs 10 tests -A run.all
|
- nix-shell --pure --max-jobs 10 tests -A run.all
|
||||||
|
|
|
@ -59,6 +59,7 @@ import nmt {
|
||||||
./modules/programs/zsh
|
./modules/programs/zsh
|
||||||
./modules/xresources
|
./modules/xresources
|
||||||
] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
|
] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
|
||||||
|
./meta # Suffices to run on one platform.
|
||||||
./modules/misc/debug
|
./modules/misc/debug
|
||||||
./modules/misc/pam
|
./modules/misc/pam
|
||||||
./modules/misc/xdg
|
./modules/misc/xdg
|
||||||
|
|
1
tests/meta/default.nix
Normal file
1
tests/meta/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ meta-formatting = ./formatting.nix; }
|
27
tests/meta/formatting.nix
Normal file
27
tests/meta/formatting.nix
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
pinnedNixpkgs = builtins.fetchTarball {
|
||||||
|
url =
|
||||||
|
"https://github.com/NixOS/nixpkgs/archive/05f0934825c2a0750d4888c4735f9420c906b388.tar.gz";
|
||||||
|
sha256 = "1g8c2w0661qn89ajp44znmwfmghbbiygvdzq0rzlvlpdiz28v6gy";
|
||||||
|
};
|
||||||
|
|
||||||
|
pinnedPkgs = import pinnedNixpkgs { };
|
||||||
|
|
||||||
|
in {
|
||||||
|
config = {
|
||||||
|
nmt.script = ''
|
||||||
|
PATH="${with pinnedPkgs; lib.makeBinPath [ findutils nixfmt ]}:$PATH"
|
||||||
|
cd ${../..}
|
||||||
|
if ! ${pkgs.runtimeShell} format -c; then
|
||||||
|
fail "${''
|
||||||
|
Expected source code to be formatted with nixfmt but it was not.
|
||||||
|
This error can be resolved by running the './format' in the project root directory.''}"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue