mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-12 02:00:13 +01:00
tests(modules_test) Extended test definition for modules
Extended the definition of tests for the continuous integration modules, allowing for more in-depth testing of odd behavior of some configuration generators.
This commit is contained in:
parent
0ef6f4d2ff
commit
8336e6d083
1 changed files with 42 additions and 5 deletions
|
|
@ -10,9 +10,17 @@
|
||||||
simplePipeline = cilib.mkCI {
|
simplePipeline = cilib.mkCI {
|
||||||
pipelines."test" = {
|
pipelines."test" = {
|
||||||
stages = ["test"];
|
stages = ["test"];
|
||||||
|
variables = {
|
||||||
|
EXAMPLE = "empty";
|
||||||
|
CURL = toString pkgs.curl;
|
||||||
|
};
|
||||||
jobs."test" = {
|
jobs."test" = {
|
||||||
stage = "test";
|
stage = "test";
|
||||||
script = ["echo hello world"];
|
script = ["echo hello world"];
|
||||||
|
variables = {
|
||||||
|
SAMPLE = "working";
|
||||||
|
HELLO = toString pkgs.hello;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -30,21 +38,29 @@
|
||||||
(cilib.mkCI {}).packages;
|
(cilib.mkCI {}).packages;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "simple pipeline";
|
name = "simple pipeline final config";
|
||||||
expected = {
|
expected = {
|
||||||
stages = [".pre" "test" ".post"];
|
stages = [".pre" "test" ".post"];
|
||||||
|
variables = {
|
||||||
|
EXAMPLE = "empty";
|
||||||
|
CURL = toString pkgs.curl;
|
||||||
|
};
|
||||||
"test" = {
|
"test" = {
|
||||||
image = "$NIX_CI_IMAGE";
|
image = "$NIX_CI_IMAGE";
|
||||||
stage = "test";
|
stage = "test";
|
||||||
before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\""];
|
before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\""];
|
||||||
script = ["echo hello world"];
|
script = ["echo hello world"];
|
||||||
after_script = ["finalize_nix_ci"];
|
after_script = ["finalize_nix_ci"];
|
||||||
|
variables = {
|
||||||
|
SAMPLE = "working";
|
||||||
|
#HELLO = toString pkgs.hello;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
actual = simplePipeline.pipelines."test".finalConfig;
|
actual = simplePipeline.pipelines."test".finalConfig;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "simple pipeline yaml";
|
name = "simple pipeline json";
|
||||||
type = "script";
|
type = "script";
|
||||||
script = let
|
script = let
|
||||||
package = simplePipeline.packages."gitlab-ci:pipeline:test";
|
package = simplePipeline.packages."gitlab-ci:pipeline:test";
|
||||||
|
|
@ -56,16 +72,36 @@
|
||||||
assert_file_contains ${package} 'gitlab-ci:pipeline:test:job-deps:test'
|
assert_file_contains ${package} 'gitlab-ci:pipeline:test:job-deps:test'
|
||||||
assert_file_contains ${package} 'finalize_nix_ci'
|
assert_file_contains ${package} 'finalize_nix_ci'
|
||||||
assert_file_contains ${package} 'echo hello world'
|
assert_file_contains ${package} 'echo hello world'
|
||||||
|
assert_file_contains ${package} '"EXAMPLE":"empty"'
|
||||||
|
assert_file_contains ${package} '"SAMPLE":"working"'
|
||||||
|
assert_file_contains ${package} '"CURL":"/nix/store/.*-curl-.*"'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "dont fail on store paths";
|
name = "simple pipeline deps drv";
|
||||||
|
type = "script";
|
||||||
|
script = let
|
||||||
|
package = simplePipeline.packages."gitlab-ci:pipeline:test:job-deps:test";
|
||||||
|
in
|
||||||
|
# sh
|
||||||
|
''
|
||||||
|
${ntlib.helpers.path [pkgs.gnugrep]}
|
||||||
|
${ntlib.helpers.scriptHelpers}
|
||||||
|
assert_file_contains ${package} ':$PATH'
|
||||||
|
assert_file_contains ${package} 'HELLO="/nix/store/.*-hello-.*"'
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "do not fail on store paths";
|
||||||
type = "script";
|
type = "script";
|
||||||
script = let
|
script = let
|
||||||
package =
|
package =
|
||||||
(cilib.mkCI {
|
(cilib.mkCI {
|
||||||
pipelines."test" = {
|
pipelines."test" = {
|
||||||
variables.EXAMPLE = "${pkgs.hello}";
|
variables = {
|
||||||
|
HELLO = "${pkgs.hello}";
|
||||||
|
SAMPLE = "empty";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}).packages."gitlab-ci:pipeline:test";
|
}).packages."gitlab-ci:pipeline:test";
|
||||||
in
|
in
|
||||||
|
|
@ -74,7 +110,8 @@
|
||||||
${ntlib.helpers.path [pkgs.gnugrep]}
|
${ntlib.helpers.path [pkgs.gnugrep]}
|
||||||
${ntlib.helpers.scriptHelpers}
|
${ntlib.helpers.scriptHelpers}
|
||||||
assert_file_contains ${package} '[".pre",".post"]'
|
assert_file_contains ${package} '[".pre",".post"]'
|
||||||
assert_file_contains ${package} '"EXAMPLE":"/nix/store/.*-hello-.*"'
|
assert_file_contains ${package} '"HELLO":"/nix/store/.*-hello-.*"'
|
||||||
|
assert_file_contains ${package} '"SAMPLE":"empty"'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue