mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-12 02:00:13 +01:00
feat: add assertion to check if a job's stage exists
This commit is contained in:
parent
e3b35ec8ae
commit
533bd2eef5
2 changed files with 21 additions and 19 deletions
|
|
@ -54,6 +54,7 @@
|
|||
};
|
||||
stage = mkOption {
|
||||
type = types.str;
|
||||
default = "test";
|
||||
};
|
||||
image = mkOption {
|
||||
type = types.str;
|
||||
|
|
@ -171,25 +172,26 @@
|
|||
jobsPatched =
|
||||
mapAttrs (key: job: {
|
||||
name = key;
|
||||
value = builtins.removeAttrs (
|
||||
(prependToBeforeScript [
|
||||
"source setup_nix_ci ${key}"
|
||||
]
|
||||
(prependToAfterScript [
|
||||
"finalize_nix_ci"
|
||||
value = assert lib.assertMsg (builtins.elem job.stage (rest.stages or [])) "stage '${job.stage}' of job '${key}' does not exist";
|
||||
builtins.removeAttrs (
|
||||
(prependToBeforeScript [
|
||||
"source setup_nix_ci ${key}"
|
||||
]
|
||||
job))
|
||||
// lib.optionalAttrs job.nix {
|
||||
image = job.image;
|
||||
variables = lib.concatMapAttrs (name: value:
|
||||
if lib.hasInfix "/nix/store/" value
|
||||
then {}
|
||||
else {
|
||||
${name} = value;
|
||||
})
|
||||
(job.variables or {});
|
||||
}
|
||||
) ["nix" "deps"];
|
||||
(prependToAfterScript [
|
||||
"finalize_nix_ci"
|
||||
]
|
||||
job))
|
||||
// lib.optionalAttrs job.nix {
|
||||
image = job.image;
|
||||
variables = lib.concatMapAttrs (name: value:
|
||||
if lib.hasInfix "/nix/store/" value
|
||||
then {}
|
||||
else {
|
||||
${name} = value;
|
||||
})
|
||||
(job.variables or {});
|
||||
}
|
||||
) ["nix" "deps"];
|
||||
})
|
||||
jobs;
|
||||
in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue