mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-12 02:00:13 +01:00
fix(jobPatched) Fixed some attributes not being passed into ci
Fixed modifying continuous integration settings attributes only when the job is configured via nix, plus improved tests for this functionality.
This commit is contained in:
parent
d2f8a70675
commit
0f9d0aae60
2 changed files with 29 additions and 33 deletions
|
|
@ -11,32 +11,28 @@ in
|
||||||
pipelineName,
|
pipelineName,
|
||||||
nixConfig,
|
nixConfig,
|
||||||
}:
|
}:
|
||||||
(builtins.removeAttrs job ["variables" "cache"])
|
if ! nixConfig.enable then job else
|
||||||
// (optionalAttrs nixConfig.enable (
|
(builtins.removeAttrs job [ "variables" "cache" ])
|
||||||
(prependToBeforeScript ["source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\""] job)
|
// (prependToBeforeScript [ "source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\"" ] job)
|
||||||
// (appendToAfterScript ["finalize_nix_ci"] job)
|
// (appendToAfterScript [ "finalize_nix_ci" ] job)
|
||||||
))
|
// (let
|
||||||
// optionalAttrs nixConfig.enable (
|
variables = job.variables or {} //
|
||||||
(let
|
optionalAttrs nixConfig.enableRunnerCache {
|
||||||
variables = job.variables or {} //
|
NIX_CI_CACHE_STRATEGY = "runner";
|
||||||
optionalAttrs nixConfig.enableRunnerCache {
|
};
|
||||||
NIX_CI_CACHE_STRATEGY = "runner";
|
in
|
||||||
};
|
# filter empty variables
|
||||||
in
|
optionalAttrs (variables != {}) {
|
||||||
# filter empty variables
|
inherit variables;
|
||||||
optionalAttrs (variables != {}) {
|
})
|
||||||
inherit variables;
|
// (let
|
||||||
})
|
cache = (toList (job.cache or [])) ++
|
||||||
// (let
|
(optional nixConfig.enableRunnerCache {
|
||||||
cache =
|
key = nixConfig.runnerCacheKey;
|
||||||
(toList (job.cache or []))
|
paths = [ ".nix-cache/" ];
|
||||||
++ (optional nixConfig.enableRunnerCache {
|
});
|
||||||
key = nixConfig.runnerCacheKey;
|
in
|
||||||
paths = [".nix-cache/"];
|
# filter empty cache
|
||||||
});
|
optionalAttrs (cache != []) {
|
||||||
in
|
inherit cache;
|
||||||
# filter empty cache
|
})
|
||||||
optionalAttrs (cache != []) {
|
|
||||||
inherit cache;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -57,14 +57,14 @@
|
||||||
{
|
{
|
||||||
name = "jobPatched nix disabled";
|
name = "jobPatched nix disabled";
|
||||||
expected = {
|
expected = {
|
||||||
/*cache = [{
|
cache = [{
|
||||||
name = "some";
|
name = "some";
|
||||||
paths = [ "this" ];
|
paths = [ "this" ];
|
||||||
}];
|
}];
|
||||||
variables = {
|
variables = {
|
||||||
BASH = toString pkgs.bash;
|
BASH = toString pkgs.bash;
|
||||||
TEST = "work";
|
TEST = "work";
|
||||||
};*/
|
};
|
||||||
};
|
};
|
||||||
actual = mkJobPatched {
|
actual = mkJobPatched {
|
||||||
key = "test";
|
key = "test";
|
||||||
|
|
@ -206,14 +206,14 @@
|
||||||
before_script = [ "./init" ];
|
before_script = [ "./init" ];
|
||||||
script = [ "echo Hello World!" ];
|
script = [ "echo Hello World!" ];
|
||||||
after_script = [ "./clean" ];
|
after_script = [ "./clean" ];
|
||||||
/*cache = [{
|
cache = [{
|
||||||
key = "simple";
|
key = "simple";
|
||||||
paths = [ "~/random/" ];
|
paths = [ "~/random/" ];
|
||||||
}];
|
}];
|
||||||
variables = {
|
variables = {
|
||||||
SAMPLE = "working";
|
SAMPLE = "working";
|
||||||
HELLO = toString pkgs.hello;
|
HELLO = toString pkgs.hello;
|
||||||
};*/
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
actual = (mkPipeline {
|
actual = (mkPipeline {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue