From d8e55a05b2d5eaad335c5c038dc729c342a8e81f Mon Sep 17 00:00:00 2001 From: Skryta Istota <6970043-hidden-being@users.noreply.gitlab.com> Date: Tue, 2 Dec 2025 15:15:15 +0100 Subject: [PATCH] fix(nixfmt) Formatted modified files to default style The style of files modified in this branch has been corrected. --- lib/impl/jobPatched.nix | 54 +++++++------ tests/cilib_test.nix | 174 +++++++++++++++++++++------------------- 2 files changed, 121 insertions(+), 107 deletions(-) diff --git a/lib/impl/jobPatched.nix b/lib/impl/jobPatched.nix index 73adb38..2467ae6 100644 --- a/lib/impl/jobPatched.nix +++ b/lib/impl/jobPatched.nix @@ -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; + }) diff --git a/tests/cilib_test.nix b/tests/cilib_test.nix index 6de4ed6..a46d24a 100644 --- a/tests/cilib_test.nix +++ b/tests/cilib_test.nix @@ -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; } ]; };