mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2026-06-19 08:39:26 +02:00
fix: pipelines can have either trigger or script
They canno thave both, so here I add assertions support and use them to avoid this case.
This commit is contained in:
parent
097f775cff
commit
70dc878112
8 changed files with 107 additions and 19 deletions
|
|
@ -98,6 +98,59 @@
|
|||
assert_file_contains ${package} 'export EXAMPLE="/nix/store/.*-hello-.*"'
|
||||
'';
|
||||
}
|
||||
{
|
||||
name = "trigger job without script is valid";
|
||||
expected = {
|
||||
trigger = "some/project";
|
||||
stage = "test";
|
||||
image = "$NIX_CI_IMAGE";
|
||||
};
|
||||
actual =
|
||||
(cilib.mkCI {
|
||||
pipelines."test" = {
|
||||
stages = ["test"];
|
||||
jobs."trigger_job" = {
|
||||
stage = "test";
|
||||
trigger = "some/project";
|
||||
nix.enable = false;
|
||||
};
|
||||
};
|
||||
}).pipelines."test".finalConfig."trigger_job";
|
||||
}
|
||||
{
|
||||
name = "script job without trigger is valid";
|
||||
expected = {
|
||||
stage = "test";
|
||||
image = "$NIX_CI_IMAGE";
|
||||
before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\""];
|
||||
script = ["echo hello"];
|
||||
after_script = ["finalize_nix_ci"];
|
||||
};
|
||||
actual =
|
||||
(cilib.mkCI {
|
||||
pipelines."test" = {
|
||||
stages = ["test"];
|
||||
jobs."test" = {
|
||||
stage = "test";
|
||||
script = ["echo hello"];
|
||||
};
|
||||
};
|
||||
}).pipelines."test".finalConfig."test";
|
||||
}
|
||||
{
|
||||
name = "job cannot have both script and trigger";
|
||||
expected = false;
|
||||
actual = (builtins.tryEval (cilib.mkCI {
|
||||
pipelines."test" = {
|
||||
stages = ["test"];
|
||||
jobs."bad" = {
|
||||
stage = "test";
|
||||
script = ["echo bad"];
|
||||
trigger = "some/project";
|
||||
};
|
||||
};
|
||||
})).success;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue