fix(nixfmt) Formatted modified files to default style

The style of files modified in this branch has been corrected.
This commit is contained in:
Skryta Istota 2025-12-02 15:15:15 +01:00
parent fc79dd5120
commit d8e55a05b2
No known key found for this signature in database
2 changed files with 121 additions and 107 deletions

View file

@ -11,28 +11,32 @@ in
pipelineName,
nixConfig,
}:
if ! nixConfig.enable then 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)
// (let
variables = job.variables or {} //
optionalAttrs nixConfig.enableRunnerCache {
NIX_CI_CACHE_STRATEGY = "runner";
};
in
# filter empty variables
optionalAttrs (variables != {}) {
inherit variables;
})
// (let
cache = (toList (job.cache or [])) ++
(optional nixConfig.enableRunnerCache {
key = nixConfig.runnerCacheKey;
paths = [ ".nix-cache/" ];
});
in
# filter empty cache
optionalAttrs (cache != []) {
inherit cache;
})
if ! nixConfig.enable
then 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)
// (let
variables =
job.variables or {}
// optionalAttrs nixConfig.enableRunnerCache {
NIX_CI_CACHE_STRATEGY = "runner";
};
in
# filter empty variables
optionalAttrs (variables != {}) {
inherit variables;
})
// (let
cache =
(toList (job.cache or []))
++ (optional nixConfig.enableRunnerCache {
key = nixConfig.runnerCacheKey;
paths = [".nix-cache/"];
});
in
# filter empty cache
optionalAttrs (cache != []) {
inherit cache;
})

View file

@ -59,7 +59,7 @@
expected = {
cache = {
name = "some";
paths = [ "this" ];
paths = ["this"];
};
variables = {
BASH = toString pkgs.bash;
@ -72,7 +72,7 @@
job = {
cache = {
name = "some";
paths = [ "this" ];
paths = ["this"];
};
variables = {
BASH = toString pkgs.bash;
@ -85,16 +85,18 @@
{
name = "jobPatched without runner cache";
expected = {
after_script = [ "finalize_nix_ci" ];
before_script = [ "source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\"" ];
after_script = ["finalize_nix_ci"];
before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\""];
variables = {
BASH = toString pkgs.bash;
TEST = "work";
};
cache = [{
name = "some";
paths = [ "this" ];
}];
cache = [
{
name = "some";
paths = ["this"];
}
];
};
actual = mkJobPatched {
key = "test";
@ -102,7 +104,7 @@
job = {
cache = {
name = "some";
paths = [ "this" ];
paths = ["this"];
};
variables = {
BASH = toString pkgs.bash;
@ -118,15 +120,18 @@
{
name = "jobPatched with runner cache";
expected = {
after_script = [ "finalize_nix_ci" ];
before_script = [ "source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\"" ];
cache = [{
name = "some";
paths = [ "this" ];
}{
key = "test";
paths = [ ".nix-cache/" ];
}];
after_script = ["finalize_nix_ci"];
before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\""];
cache = [
{
name = "some";
paths = ["this"];
}
{
key = "test";
paths = [".nix-cache/"];
}
];
variables = {
NIX_CI_CACHE_STRATEGY = "runner";
BASH = toString pkgs.bash;
@ -139,7 +144,7 @@
job = {
cache = {
name = "some";
paths = [ "this" ];
paths = ["this"];
};
variables = {
BASH = toString pkgs.bash;
@ -196,19 +201,19 @@
{
name = "handle store paths in variables without nix config";
expected = {
stages = [ "test" ];
stages = ["test"];
variables = {
EXAMPLE = "empty";
CURL = toString pkgs.curl;
};
test = {
stage = "test";
before_script = [ "./init" ];
script = [ "echo Hello World!" ];
after_script = [ "./clean" ];
before_script = ["./init"];
script = ["echo Hello World!"];
after_script = ["./clean"];
cache = {
key = "simple";
paths = [ "~/random/" ];
paths = ["~/random/"];
};
variables = {
SAMPLE = "working";
@ -216,52 +221,56 @@
};
};
};
actual = (mkPipeline {
name = "test";
nixConfig.enable = false;
pipeline = {
stages = [ "test" ];
variables = {
EXAMPLE = "empty";
CURL = toString pkgs.curl;
};
jobs.test = {
stage = "test";
before_script = [ "./init" ];
script = [ "echo Hello World!" ];
after_script = [ "./clean" ];
cache = {
key = "simple";
paths = [ "~/random/" ];
};
actual =
(mkPipeline {
name = "test";
nixConfig.enable = false;
pipeline = {
stages = ["test"];
variables = {
SAMPLE = "working";
HELLO = toString pkgs.hello;
EXAMPLE = "empty";
CURL = toString pkgs.curl;
};
jobs.test = {
stage = "test";
before_script = ["./init"];
script = ["echo Hello World!"];
after_script = ["./clean"];
cache = {
key = "simple";
paths = ["~/random/"];
};
variables = {
SAMPLE = "working";
HELLO = toString pkgs.hello;
};
};
};
};
}).finalConfig;
}).finalConfig;
}
{
name = "handle store paths in variables with nix config";
expected = {
stages = [ "test" ];
stages = ["test"];
variables = {
EXAMPLE = "empty";
CURL = toString pkgs.curl;
};
test = {
stage = "test";
before_script = [ "source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\"" "./init" ];
script = [ "echo Hello World!" ];
after_script = [ "./clean" "finalize_nix_ci" ];
cache = [{
key = "simple";
paths = [ "~/random/" ];
}{
key = "random";
paths = [ ".nix-cache/" ];
}];
before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\"" "./init"];
script = ["echo Hello World!"];
after_script = ["./clean" "finalize_nix_ci"];
cache = [
{
key = "simple";
paths = ["~/random/"];
}
{
key = "random";
paths = [".nix-cache/"];
}
];
variables = {
SAMPLE = "working";
HELLO = toString pkgs.hello;
@ -269,35 +278,36 @@
};
};
};
actual = (mkPipeline {
name = "test";
nixConfig = {
enable = true;
enableRunnerCache = true;
runnerCacheKey = "random";
};
pipeline = {
stages = [ "test" ];
variables = {
EXAMPLE = "empty";
CURL = toString pkgs.curl;
actual =
(mkPipeline {
name = "test";
nixConfig = {
enable = true;
enableRunnerCache = true;
runnerCacheKey = "random";
};
jobs.test = {
stage = "test";
before_script = [ "./init" ];
script = [ "echo Hello World!" ];
after_script = [ "./clean" ];
cache = {
key = "simple";
paths = [ "~/random/" ];
};
pipeline = {
stages = ["test"];
variables = {
SAMPLE = "working";
HELLO = toString pkgs.hello;
EXAMPLE = "empty";
CURL = toString pkgs.curl;
};
jobs.test = {
stage = "test";
before_script = ["./init"];
script = ["echo Hello World!"];
after_script = ["./clean"];
cache = {
key = "simple";
paths = ["~/random/"];
};
variables = {
SAMPLE = "working";
HELLO = toString pkgs.hello;
};
};
};
};
}).finalConfig;
}).finalConfig;
}
];
};