mirror of
https://github.com/Mic92/sops-nix.git
synced 2026-07-17 14:35:25 +08:00
unit-test: convert to shell app
I saw the exit status in ci was actually ignored.
This commit is contained in:
parent
39c667d73c
commit
0809aa0ae7
3 changed files with 17 additions and 26 deletions
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
|
@ -15,4 +15,4 @@ jobs:
|
||||||
- name: Add keys group (needed for go tests)
|
- name: Add keys group (needed for go tests)
|
||||||
run: sudo groupadd keys
|
run: sudo groupadd keys
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: nix develop .#unit-tests --command "true"
|
run: nix run .#unit-tests
|
||||||
|
|
|
||||||
|
|
@ -147,13 +147,16 @@
|
||||||
nix --extra-experimental-features "nix-command flakes" hash path ./dev/private | tr -d '\n' > ./dev/private.narHash
|
nix --extra-experimental-features "nix-command flakes" hash path ./dev/private | tr -d '\n' > ./dev/private.narHash
|
||||||
''}";
|
''}";
|
||||||
};
|
};
|
||||||
|
unit-tests = {
|
||||||
|
type = "app";
|
||||||
|
program = "${pkgs.callPackage ./pkgs/unit-tests.nix { }}/bin/unit-tests";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
devShells = eachSystem (
|
devShells = eachSystem (
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
unit-tests = pkgs.callPackage ./pkgs/unit-tests.nix { };
|
|
||||||
default = pkgs.callPackage ./shell.nix { };
|
default = pkgs.callPackage ./shell.nix { };
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -4,30 +4,18 @@
|
||||||
let
|
let
|
||||||
sopsPkgs = import ../. { inherit pkgs; };
|
sopsPkgs = import ../. { inherit pkgs; };
|
||||||
in
|
in
|
||||||
pkgs.stdenv.mkDerivation {
|
pkgs.writeShellApplication {
|
||||||
name = "env";
|
name = "unit-tests";
|
||||||
nativeBuildInputs =
|
runtimeInputs = [
|
||||||
with pkgs;
|
pkgs.gnupg
|
||||||
[
|
pkgs.nix
|
||||||
bashInteractive
|
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
|
||||||
gnupg
|
pkgs.util-linux
|
||||||
util-linux
|
];
|
||||||
nix
|
text = ''
|
||||||
sopsPkgs.sops-pgp-hook-test
|
NIX_PATH=nixpkgs=${pkgs.path} TEST_ASSETS="$PWD/pkgs/sops-pgp-hook/test-assets" ${sopsPkgs.sops-pgp-hook-test}/bin/sops-pgp-hook.test -test.v
|
||||||
]
|
${pkgs.lib.optionalString pkgs.stdenv.isLinux ''
|
||||||
++ pkgs.lib.optional (pkgs.stdenv.isLinux) sopsPkgs.sops-install-secrets.unittest;
|
sudo TEST_ASSETS="$PWD/pkgs/sops-install-secrets/test-assets" unshare --mount --fork ${sopsPkgs.sops-install-secrets.unittest}/bin/sops-install-secrets.test -test.v
|
||||||
# allow to prefetch shell dependencies in build phase
|
|
||||||
dontUnpack = true;
|
|
||||||
installPhase = ''
|
|
||||||
echo $nativeBuildInputs > $out
|
|
||||||
'';
|
|
||||||
shellHook = ''
|
|
||||||
set -x
|
|
||||||
NIX_PATH=nixpkgs=${toString pkgs.path} TEST_ASSETS=$(realpath ./pkgs/sops-pgp-hook/test-assets) \
|
|
||||||
sops-pgp-hook.test
|
|
||||||
${pkgs.lib.optionalString (pkgs.stdenv.isLinux) ''
|
|
||||||
sudo TEST_ASSETS=$(realpath ./pkgs/sops-install-secrets/test-assets) \
|
|
||||||
unshare --mount --fork sops-install-secrets.test
|
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue