Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add some tests #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@
};

packages = {
inherit (pkgs) nix-buildkite;
inherit (pkgs) nix-buildkite nix-buildkite-unwrapped;
} // (pkgs.lib.optionalAttrs (system == "x86_64-linux") {
inherit (pkgs) nix-buildkite-docker-image;
})
// haskellNixFlake.packages;

checks = haskellNixFlake.checks;
checks = {
inherit (pkgs) nix-buildkite-tests;
} // haskellNixFlake.checks;

apps =
let
Expand Down Expand Up @@ -246,6 +248,7 @@
nodejs-18_x

nixpkgs-fmt
goldplate
]);

shellHook = ''
Expand Down Expand Up @@ -297,12 +300,41 @@
};
};

nix-buildkite-unwrapped = nixBuildkiteFlake.packages."nix-buildkite-plugin:exe:nix-buildkite";

nix-buildkite = final.stdenv.mkDerivation {
name = "nix-buildkite";
src = ./.;
nativeBuildInputs = [
final.makeWrapper
];
installPhase = ''
mkdir -p $out/bin
makeWrapper ${nix-buildkite-unwrapped}/bin/nix-buildkite $out/bin/nix-buildkite \
--suffix PATH : ${final.lib.makeBinPath [final.nix]}
'';

meta = with final.lib; {
description = "Create Buildkite pipelines from Nix attributes.";
homepage = "https://github.com/hackworthltd/nix-buildkite-plugin";
license = licenses.bsd3;
platforms = platforms.all;
mainProgram = "nix-buildkite";
};
};

nix-buildkite-tests = final.callPackage ./nix/pkgs/nix-buildkite-tests {
src = ./tests;
};
in
{
inherit nix-buildkite-unwrapped;
inherit nix-buildkite;
inherit nix-buildkite-plugin;

nix-buildkite = nixBuildkiteFlake.packages."nix-buildkite-plugin:exe:nix-buildkite";
inherit nix-buildkite-docker-image;

inherit (final.haskellPackages) goldplate;
inherit nix-buildkite-tests;
}
);

Expand Down
18 changes: 18 additions & 0 deletions nix/pkgs/nix-buildkite-tests/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ goldplate
, nix-buildkite
, runCommand
, src
}:
runCommand "nix-buildkite-tests"
{
inherit src;
nativeBuildInputs = [
goldplate
nix-buildkite
];
} ''
set -e
cd $src
goldplate -j2 --pretty-diff .
touch $out
''
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(import ./flake-compat.nix).defaultNix
9 changes: 9 additions & 0 deletions tests/flake-compat.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
inherit (lock.nodes.flake-compat.locked) owner repo rev narHash;
flake-compat = builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
};
in
import flake-compat { src = ./.; }
Loading