mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-12 10:10:06 +01:00
test: add basic test for flakeModule functionality
This commit is contained in:
parent
0952ab4145
commit
e074d716c4
7 changed files with 73 additions and 6 deletions
|
|
@ -21,14 +21,14 @@
|
||||||
cellBlocks = with ren.blocks; [
|
cellBlocks = with ren.blocks; [
|
||||||
(simple "devShells")
|
(simple "devShells")
|
||||||
(simple "pkgs")
|
(simple "pkgs")
|
||||||
# (simple "tests")
|
(simple "tests")
|
||||||
# (simple "docs")
|
# (simple "docs")
|
||||||
(simple "ci")
|
(simple "ci")
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
packages = ren.select self [
|
packages = ren.select self [
|
||||||
# ["repo" "tests"]
|
["repo" "tests"]
|
||||||
# ["repo" "docs"]
|
# ["repo" "docs"]
|
||||||
["repo" "ci" "packages"]
|
["repo" "ci" "packages"]
|
||||||
["packages" "pkgs"]
|
["packages" "pkgs"]
|
||||||
|
|
|
||||||
18
nix/repo/flake.lock
generated
18
nix/repo/flake.lock
generated
|
|
@ -17,9 +17,27 @@
|
||||||
"type": "gitlab"
|
"type": "gitlab"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixtest-lib": {
|
||||||
|
"locked": {
|
||||||
|
"dir": "lib",
|
||||||
|
"lastModified": 1753957623,
|
||||||
|
"narHash": "sha256-kdImwKx57N0QL8HPUUb5ADwXFgSjaNOk39b/eKlzyTo=",
|
||||||
|
"owner": "TECHNOFAB",
|
||||||
|
"repo": "nixtest",
|
||||||
|
"rev": "22b43c9fe83be73c3f0648bbb54bc3c1cf7f96df",
|
||||||
|
"type": "gitlab"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"dir": "lib",
|
||||||
|
"owner": "TECHNOFAB",
|
||||||
|
"repo": "nixtest",
|
||||||
|
"type": "gitlab"
|
||||||
|
}
|
||||||
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"devshell-lib": "devshell-lib",
|
"devshell-lib": "devshell-lib",
|
||||||
|
"nixtest-lib": "nixtest-lib",
|
||||||
"treefmt-nix": "treefmt-nix"
|
"treefmt-nix": "treefmt-nix"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
devshell-lib.url = "gitlab:rensa-nix/devshell?dir=lib";
|
devshell-lib.url = "gitlab:rensa-nix/devshell?dir=lib";
|
||||||
|
nixtest-lib.url = "gitlab:TECHNOFAB/nixtest?dir=lib";
|
||||||
treefmt-nix = {
|
treefmt-nix = {
|
||||||
url = "github:numtide/treefmt-nix";
|
url = "github:numtide/treefmt-nix";
|
||||||
flake = false;
|
flake = false;
|
||||||
|
|
@ -10,6 +11,7 @@
|
||||||
i
|
i
|
||||||
// {
|
// {
|
||||||
devshell = i.devshell-lib.lib {inherit (i.parent) pkgs;};
|
devshell = i.devshell-lib.lib {inherit (i.parent) pkgs;};
|
||||||
|
ntlib = i.nixtest-lib.lib {inherit (i.parent) pkgs;};
|
||||||
cilib = import "${i.parent.self}/lib" {inherit (i.parent) pkgs;};
|
cilib = import "${i.parent.self}/lib" {inherit (i.parent) pkgs;};
|
||||||
treefmt = import i.treefmt-nix;
|
treefmt = import i.treefmt-nix;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
10
nix/repo/tests.nix
Normal file
10
nix/repo/tests.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{inputs, ...}: let
|
||||||
|
inherit (inputs) pkgs ntlib cilib;
|
||||||
|
in {
|
||||||
|
tests = ntlib.mkNixtest {
|
||||||
|
modules = ntlib.autodiscover {dir = "${inputs.self}/tests";};
|
||||||
|
args = {
|
||||||
|
inherit pkgs ntlib cilib;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
0
flakeModuleTest/flake.lock → tests/fixtures/flake_parts/flake.lock
generated
vendored
0
flakeModuleTest/flake.lock → tests/fixtures/flake_parts/flake.lock
generated
vendored
|
|
@ -6,13 +6,11 @@
|
||||||
} @ inputs:
|
} @ inputs:
|
||||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||||
imports = [
|
imports = [
|
||||||
../lib/flakeModule.nix
|
"@repo_path@/lib/flakeModule.nix"
|
||||||
];
|
];
|
||||||
systems = import systems;
|
systems = import systems;
|
||||||
flake = {};
|
flake = {};
|
||||||
perSystem = {
|
perSystem = _: {
|
||||||
...
|
|
||||||
}: {
|
|
||||||
ci = {
|
ci = {
|
||||||
config = {
|
config = {
|
||||||
# true is already default, just for testing
|
# true is already default, just for testing
|
||||||
39
tests/flake_parts_test.nix
Normal file
39
tests/flake_parts_test.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
ntlib,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
suites."flake-parts" = {
|
||||||
|
pos = __curPos;
|
||||||
|
tests = [
|
||||||
|
{
|
||||||
|
name = "flakeModule";
|
||||||
|
type = "script";
|
||||||
|
script =
|
||||||
|
# sh
|
||||||
|
''
|
||||||
|
${ntlib.helpers.scriptHelpers}
|
||||||
|
${ntlib.helpers.path (with pkgs; [coreutils nix gnused gnugrep jq])}
|
||||||
|
repo_path=${../.}
|
||||||
|
|
||||||
|
dir=$(mktemp -d)
|
||||||
|
trap "rm -rf $dir" EXIT
|
||||||
|
cd $dir
|
||||||
|
cp ${./fixtures/flake_parts}/* .
|
||||||
|
# import from the absolute path above, is easier than trying to figure out the repo path etc.
|
||||||
|
sed -i -e "s|@repo_path@|$repo_path|" flake.nix
|
||||||
|
|
||||||
|
# NOTE: --impure is required since importing modules from absolute paths is not allowed in pure mode
|
||||||
|
nix build --impure .#gitlab-ci:pipeline:default
|
||||||
|
assert "-f result" "should exist"
|
||||||
|
assert_file_contains "result" "finalize_nix_ci"
|
||||||
|
jq '.' result # check if valid json just to be sure
|
||||||
|
|
||||||
|
nix build --impure .#gitlab-ci:pipeline:default:pretty
|
||||||
|
assert "-f result" "should exist"
|
||||||
|
assert_file_contains "result" " - finalize_nix_ci"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue