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,13 +11,16 @@ 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"])
// (prependToBeforeScript ["source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\""] job)
// (appendToAfterScript ["finalize_nix_ci"] job)
// (let // (let
variables = job.variables or {} // variables =
optionalAttrs nixConfig.enableRunnerCache { job.variables or {}
// optionalAttrs nixConfig.enableRunnerCache {
NIX_CI_CACHE_STRATEGY = "runner"; NIX_CI_CACHE_STRATEGY = "runner";
}; };
in in
@ -26,10 +29,11 @@ in
inherit variables; inherit variables;
}) })
// (let // (let
cache = (toList (job.cache or [])) ++ cache =
(optional nixConfig.enableRunnerCache { (toList (job.cache or []))
++ (optional nixConfig.enableRunnerCache {
key = nixConfig.runnerCacheKey; key = nixConfig.runnerCacheKey;
paths = [ ".nix-cache/" ]; paths = [".nix-cache/"];
}); });
in in
# filter empty cache # filter empty cache

View file

@ -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"; name = "some";
paths = [ "this" ]; 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"; name = "some";
paths = [ "this" ]; paths = ["this"];
}{ }
{
key = "test"; key = "test";
paths = [ ".nix-cache/" ]; 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,23 +221,24 @@
}; };
}; };
}; };
actual = (mkPipeline { actual =
(mkPipeline {
name = "test"; name = "test";
nixConfig.enable = false; nixConfig.enable = false;
pipeline = { pipeline = {
stages = [ "test" ]; stages = ["test"];
variables = { variables = {
EXAMPLE = "empty"; EXAMPLE = "empty";
CURL = toString pkgs.curl; CURL = toString pkgs.curl;
}; };
jobs.test = { jobs.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";
@ -245,23 +251,26 @@
{ {
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"; key = "simple";
paths = [ "~/random/" ]; paths = ["~/random/"];
}{ }
{
key = "random"; key = "random";
paths = [ ".nix-cache/" ]; paths = [".nix-cache/"];
}]; }
];
variables = { variables = {
SAMPLE = "working"; SAMPLE = "working";
HELLO = toString pkgs.hello; HELLO = toString pkgs.hello;
@ -269,7 +278,8 @@
}; };
}; };
}; };
actual = (mkPipeline { actual =
(mkPipeline {
name = "test"; name = "test";
nixConfig = { nixConfig = {
enable = true; enable = true;
@ -277,19 +287,19 @@
runnerCacheKey = "random"; runnerCacheKey = "random";
}; };
pipeline = { pipeline = {
stages = [ "test" ]; stages = ["test"];
variables = { variables = {
EXAMPLE = "empty"; EXAMPLE = "empty";
CURL = toString pkgs.curl; CURL = toString pkgs.curl;
}; };
jobs.test = { jobs.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";