Merge pull request 'Run tests when building the nix package' (#3) from run-tests-in-nix into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/3
This commit is contained in:
commit
218f812012
3 changed files with 55 additions and 5 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/result
|
||||
53
default.nix
Normal file
53
default.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
stdenv,
|
||||
lib,
|
||||
shellcheck-minimal,
|
||||
bats,
|
||||
gitMinimal,
|
||||
}:
|
||||
|
||||
let
|
||||
fs = lib.fileset;
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "git-check-assertions";
|
||||
version = "0.0.1";
|
||||
|
||||
src = fs.toSource {
|
||||
root = ./.;
|
||||
fileset = fs.unions [
|
||||
./git-check-assertions
|
||||
./test.bats
|
||||
];
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs .
|
||||
'';
|
||||
|
||||
nativeCheckInputs = [
|
||||
shellcheck-minimal
|
||||
bats
|
||||
gitMinimal
|
||||
];
|
||||
|
||||
checkPhase = ''
|
||||
shellcheck git-check-assertions test.bats
|
||||
git init
|
||||
git config user.email test
|
||||
git config user.name test
|
||||
git checkout -b main
|
||||
git commit --allow-empty -m "initial"
|
||||
./test.bats
|
||||
'';
|
||||
|
||||
doCheck = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp $src/git-check-assertions $out/bin/git-check-assertions
|
||||
chmod +x $out/bin/git-check-assertions
|
||||
'';
|
||||
|
||||
meta.mainProgram = "git-check-assertions";
|
||||
}
|
||||
|
|
@ -14,11 +14,7 @@
|
|||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
packages.default = pkgs.writeShellApplication {
|
||||
name = "git-check-assertions";
|
||||
runtimeInputs = [ pkgs.git ];
|
||||
text = builtins.readFile ./git-check-assertions;
|
||||
};
|
||||
packages.default = pkgs.callPackage ./default.nix { };
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = with pkgs; [ bats ];
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue