mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-12 02:00:13 +01:00
fix(nixfmt) Formatted modified files to default style
The style of files modified in this branch has been corrected.
This commit is contained in:
parent
fc79dd5120
commit
d8e55a05b2
2 changed files with 121 additions and 107 deletions
|
|
@ -11,28 +11,32 @@ in
|
||||||
pipelineName,
|
pipelineName,
|
||||||
nixConfig,
|
nixConfig,
|
||||||
}:
|
}:
|
||||||
if ! nixConfig.enable then job else
|
if ! nixConfig.enable
|
||||||
(builtins.removeAttrs job [ "variables" "cache" ])
|
then job
|
||||||
// (prependToBeforeScript [ "source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\"" ] job)
|
else
|
||||||
// (appendToAfterScript [ "finalize_nix_ci" ] job)
|
(builtins.removeAttrs job ["variables" "cache"])
|
||||||
// (let
|
// (prependToBeforeScript ["source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\""] job)
|
||||||
variables = job.variables or {} //
|
// (appendToAfterScript ["finalize_nix_ci"] job)
|
||||||
optionalAttrs nixConfig.enableRunnerCache {
|
// (let
|
||||||
NIX_CI_CACHE_STRATEGY = "runner";
|
variables =
|
||||||
};
|
job.variables or {}
|
||||||
in
|
// optionalAttrs nixConfig.enableRunnerCache {
|
||||||
# filter empty variables
|
NIX_CI_CACHE_STRATEGY = "runner";
|
||||||
optionalAttrs (variables != {}) {
|
};
|
||||||
inherit variables;
|
in
|
||||||
})
|
# filter empty variables
|
||||||
// (let
|
optionalAttrs (variables != {}) {
|
||||||
cache = (toList (job.cache or [])) ++
|
inherit variables;
|
||||||
(optional nixConfig.enableRunnerCache {
|
})
|
||||||
key = nixConfig.runnerCacheKey;
|
// (let
|
||||||
paths = [ ".nix-cache/" ];
|
cache =
|
||||||
});
|
(toList (job.cache or []))
|
||||||
in
|
++ (optional nixConfig.enableRunnerCache {
|
||||||
# filter empty cache
|
key = nixConfig.runnerCacheKey;
|
||||||
optionalAttrs (cache != []) {
|
paths = [".nix-cache/"];
|
||||||
inherit cache;
|
});
|
||||||
})
|
in
|
||||||
|
# filter empty cache
|
||||||
|
optionalAttrs (cache != []) {
|
||||||
|
inherit cache;
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
expected = {
|
expected = {
|
||||||
cache = {
|
cache = {
|
||||||
name = "some";
|
name = "some";
|
||||||
paths = [ "this" ];
|
paths = ["this"];
|
||||||
};
|
};
|
||||||
variables = {
|
variables = {
|
||||||
BASH = toString pkgs.bash;
|
BASH = toString pkgs.bash;
|
||||||
|
|
@ -72,7 +72,7 @@
|
||||||
job = {
|
job = {
|
||||||
cache = {
|
cache = {
|
||||||
name = "some";
|
name = "some";
|
||||||
paths = [ "this" ];
|
paths = ["this"];
|
||||||
};
|
};
|
||||||
variables = {
|
variables = {
|
||||||
BASH = toString pkgs.bash;
|
BASH = toString pkgs.bash;
|
||||||
|
|
@ -85,16 +85,18 @@
|
||||||
{
|
{
|
||||||
name = "jobPatched without runner cache";
|
name = "jobPatched without runner cache";
|
||||||
expected = {
|
expected = {
|
||||||
after_script = [ "finalize_nix_ci" ];
|
after_script = ["finalize_nix_ci"];
|
||||||
before_script = [ "source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\"" ];
|
before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\""];
|
||||||
variables = {
|
variables = {
|
||||||
BASH = toString pkgs.bash;
|
BASH = toString pkgs.bash;
|
||||||
TEST = "work";
|
TEST = "work";
|
||||||
};
|
};
|
||||||
cache = [{
|
cache = [
|
||||||
name = "some";
|
{
|
||||||
paths = [ "this" ];
|
name = "some";
|
||||||
}];
|
paths = ["this"];
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
actual = mkJobPatched {
|
actual = mkJobPatched {
|
||||||
key = "test";
|
key = "test";
|
||||||
|
|
@ -102,7 +104,7 @@
|
||||||
job = {
|
job = {
|
||||||
cache = {
|
cache = {
|
||||||
name = "some";
|
name = "some";
|
||||||
paths = [ "this" ];
|
paths = ["this"];
|
||||||
};
|
};
|
||||||
variables = {
|
variables = {
|
||||||
BASH = toString pkgs.bash;
|
BASH = toString pkgs.bash;
|
||||||
|
|
@ -118,15 +120,18 @@
|
||||||
{
|
{
|
||||||
name = "jobPatched with runner cache";
|
name = "jobPatched with runner cache";
|
||||||
expected = {
|
expected = {
|
||||||
after_script = [ "finalize_nix_ci" ];
|
after_script = ["finalize_nix_ci"];
|
||||||
before_script = [ "source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\"" ];
|
before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\""];
|
||||||
cache = [{
|
cache = [
|
||||||
name = "some";
|
{
|
||||||
paths = [ "this" ];
|
name = "some";
|
||||||
}{
|
paths = ["this"];
|
||||||
key = "test";
|
}
|
||||||
paths = [ ".nix-cache/" ];
|
{
|
||||||
}];
|
key = "test";
|
||||||
|
paths = [".nix-cache/"];
|
||||||
|
}
|
||||||
|
];
|
||||||
variables = {
|
variables = {
|
||||||
NIX_CI_CACHE_STRATEGY = "runner";
|
NIX_CI_CACHE_STRATEGY = "runner";
|
||||||
BASH = toString pkgs.bash;
|
BASH = toString pkgs.bash;
|
||||||
|
|
@ -139,7 +144,7 @@
|
||||||
job = {
|
job = {
|
||||||
cache = {
|
cache = {
|
||||||
name = "some";
|
name = "some";
|
||||||
paths = [ "this" ];
|
paths = ["this"];
|
||||||
};
|
};
|
||||||
variables = {
|
variables = {
|
||||||
BASH = toString pkgs.bash;
|
BASH = toString pkgs.bash;
|
||||||
|
|
@ -196,19 +201,19 @@
|
||||||
{
|
{
|
||||||
name = "handle store paths in variables without nix config";
|
name = "handle store paths in variables without nix config";
|
||||||
expected = {
|
expected = {
|
||||||
stages = [ "test" ];
|
stages = ["test"];
|
||||||
variables = {
|
variables = {
|
||||||
EXAMPLE = "empty";
|
EXAMPLE = "empty";
|
||||||
CURL = toString pkgs.curl;
|
CURL = toString pkgs.curl;
|
||||||
};
|
};
|
||||||
test = {
|
test = {
|
||||||
stage = "test";
|
stage = "test";
|
||||||
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";
|
||||||
|
|
@ -216,52 +221,56 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
actual = (mkPipeline {
|
actual =
|
||||||
name = "test";
|
(mkPipeline {
|
||||||
nixConfig.enable = false;
|
name = "test";
|
||||||
pipeline = {
|
nixConfig.enable = false;
|
||||||
stages = [ "test" ];
|
pipeline = {
|
||||||
variables = {
|
stages = ["test"];
|
||||||
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 = {
|
variables = {
|
||||||
SAMPLE = "working";
|
EXAMPLE = "empty";
|
||||||
HELLO = toString pkgs.hello;
|
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";
|
name = "handle store paths in variables with nix config";
|
||||||
expected = {
|
expected = {
|
||||||
stages = [ "test" ];
|
stages = ["test"];
|
||||||
variables = {
|
variables = {
|
||||||
EXAMPLE = "empty";
|
EXAMPLE = "empty";
|
||||||
CURL = toString pkgs.curl;
|
CURL = toString pkgs.curl;
|
||||||
};
|
};
|
||||||
test = {
|
test = {
|
||||||
stage = "test";
|
stage = "test";
|
||||||
before_script = [ "source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\"" "./init" ];
|
before_script = ["source setup_nix_ci \"gitlab-ci:pipeline:test:job-deps:test\"" "./init"];
|
||||||
script = [ "echo Hello World!" ];
|
script = ["echo Hello World!"];
|
||||||
after_script = [ "./clean" "finalize_nix_ci" ];
|
after_script = ["./clean" "finalize_nix_ci"];
|
||||||
cache = [{
|
cache = [
|
||||||
key = "simple";
|
{
|
||||||
paths = [ "~/random/" ];
|
key = "simple";
|
||||||
}{
|
paths = ["~/random/"];
|
||||||
key = "random";
|
}
|
||||||
paths = [ ".nix-cache/" ];
|
{
|
||||||
}];
|
key = "random";
|
||||||
|
paths = [".nix-cache/"];
|
||||||
|
}
|
||||||
|
];
|
||||||
variables = {
|
variables = {
|
||||||
SAMPLE = "working";
|
SAMPLE = "working";
|
||||||
HELLO = toString pkgs.hello;
|
HELLO = toString pkgs.hello;
|
||||||
|
|
@ -269,35 +278,36 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
actual = (mkPipeline {
|
actual =
|
||||||
name = "test";
|
(mkPipeline {
|
||||||
nixConfig = {
|
name = "test";
|
||||||
enable = true;
|
nixConfig = {
|
||||||
enableRunnerCache = true;
|
enable = true;
|
||||||
runnerCacheKey = "random";
|
enableRunnerCache = true;
|
||||||
};
|
runnerCacheKey = "random";
|
||||||
pipeline = {
|
|
||||||
stages = [ "test" ];
|
|
||||||
variables = {
|
|
||||||
EXAMPLE = "empty";
|
|
||||||
CURL = toString pkgs.curl;
|
|
||||||
};
|
};
|
||||||
jobs.test = {
|
pipeline = {
|
||||||
stage = "test";
|
stages = ["test"];
|
||||||
before_script = [ "./init" ];
|
|
||||||
script = [ "echo Hello World!" ];
|
|
||||||
after_script = [ "./clean" ];
|
|
||||||
cache = {
|
|
||||||
key = "simple";
|
|
||||||
paths = [ "~/random/" ];
|
|
||||||
};
|
|
||||||
variables = {
|
variables = {
|
||||||
SAMPLE = "working";
|
EXAMPLE = "empty";
|
||||||
HELLO = toString pkgs.hello;
|
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;
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue