fix(jobPatched): handle non-nix jobs correctly

fix mkJobPatched removing `cache` and `variables` from non-nix jobs

See !15 for more
This commit is contained in:
technofab 2025-12-02 15:10:00 +01:00
parent 1c9e7c77c5
commit 97fb4fafc3
No known key found for this signature in database
2 changed files with 27 additions and 9 deletions

View file

@ -11,13 +11,13 @@ in
pipelineName, pipelineName,
nixConfig, nixConfig,
}: }:
(builtins.removeAttrs job ["variables" "cache"]) if ! nixConfig.enable
// (optionalAttrs nixConfig.enable ( then job
(prependToBeforeScript ["source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\""] job) else
(builtins.removeAttrs job ["variables" "cache"])
// (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 (
(let
variables = variables =
(filterJobVariables false job) (filterJobVariables false job)
// optionalAttrs nixConfig.enableRunnerCache { // optionalAttrs nixConfig.enableRunnerCache {
@ -40,4 +40,3 @@ in
optionalAttrs (cache != []) { optionalAttrs (cache != []) {
inherit cache; inherit cache;
}) })
)

View file

@ -64,6 +64,22 @@
nixConfig.enable = false; nixConfig.enable = false;
}; };
} }
{
name = "jobPatched nix disabled with variables and cache";
expected = {
variables."HELLO" = "world";
cache = [{key = "example";}];
};
actual = mkJobPatched {
key = "test";
pipelineName = "test";
job = {
variables."HELLO" = "world";
cache = [{key = "example";}];
};
nixConfig.enable = false;
};
}
{ {
name = "jobPatched without runner cache"; name = "jobPatched without runner cache";
expected = { expected = {
@ -145,10 +161,13 @@
''; '';
} }
{ {
name = "handle store paths in variables"; name = "ignore store paths in variables with nix disabled";
expected = { expected = {
stages = ["test"]; stages = ["test"];
test.stage = "test"; test = {
stage = "test";
variables."TEST" = "${pkgs.hello}";
};
}; };
actual = actual =
(mkPipeline { (mkPipeline {