diff --git a/flake.lock b/flake.lock index f1a0875..598eafa 100644 --- a/flake.lock +++ b/flake.lock @@ -329,6 +329,23 @@ "type": "github" } }, + "nixtest": { + "locked": { + "dir": "lib", + "lastModified": 1746388457, + "narHash": "sha256-xWAnSFxogdy47rZyGj18R9qDlLFs/PvwPpD3iAiR2Hc=", + "owner": "technofab", + "repo": "nixtest", + "rev": "0a1bbae2c30e3ba8e3b02de223e199c5dfd56572", + "type": "gitlab" + }, + "original": { + "dir": "lib", + "owner": "technofab", + "repo": "nixtest", + "type": "gitlab" + } + }, "root": { "inputs": { "devenv": "devenv", @@ -336,6 +353,7 @@ "mkdocs-material-umami": "mkdocs-material-umami", "nix-mkdocs": "nix-mkdocs", "nixpkgs": "nixpkgs_4", + "nixtest": "nixtest", "systems": "systems", "treefmt-nix": "treefmt-nix" } diff --git a/flake.nix b/flake.nix index 6753d41..2704302 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,7 @@ inputs.devenv.flakeModule inputs.treefmt-nix.flakeModule inputs.nix-mkdocs.flakeModule + inputs.nixtest.flakeModule ./lib/flakeModule.nix ]; systems = import systems; @@ -16,6 +17,7 @@ perSystem = { pkgs, config, + self', system, ... }: rec { @@ -209,6 +211,23 @@ }; }; + nixtest.suites = let + jsonFile = file: builtins.fromJSON (builtins.readFile file); + in { + "Pipeline YAMLs" = [ + { + name = "default"; + type = "snapshot"; + actual = jsonFile self'.legacyPackages."gitlab-ci:pipeline:default"; + } + { + name = "non-default"; + type = "snapshot"; + actual = jsonFile self'.legacyPackages."gitlab-ci:pipeline:non-default"; + } + ]; + }; + packages = let setupScript = pkgs.writeShellScriptBin "setup_nix_ci" (builtins.readFile ./scripts/setup_nix_ci.sh); finalizeScript = pkgs.writeShellScriptBin "finalize_nix_ci" (builtins.readFile ./scripts/finalize_nix_ci.sh); @@ -269,6 +288,7 @@ treefmt-nix.url = "github:numtide/treefmt-nix"; nix-mkdocs.url = "gitlab:technofab/nixmkdocs?dir=lib"; mkdocs-material-umami.url = "gitlab:technofab/mkdocs-material-umami"; + nixtest.url = "gitlab:technofab/nixtest?dir=lib"; }; nixConfig = { diff --git a/snapshots/default.snap.json b/snapshots/default.snap.json new file mode 100644 index 0000000..48ae054 --- /dev/null +++ b/snapshots/default.snap.json @@ -0,0 +1 @@ +{"docs":{"after_script":["finalize_nix_ci"],"artifacts":{"paths":["public"]},"before_script":["source setup_nix_ci \"gitlab-ci:pipeline:default:job-deps:docs\""],"cache":[],"image":"$NIX_CI_IMAGE","script":["nix build .#docs:default\nmkdir -p public\ncp -r result/. public/\n"],"stage":"build","variables":{}},"pages":{"artifacts":{"paths":["public"]},"image":"alpine:latest","rules":[{"if":"$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"}],"script":["true"],"stage":"deploy"},"stages":["test","build","deploy"],"test":{"after_script":["finalize_nix_ci"],"before_script":["source setup_nix_ci \"gitlab-ci:pipeline:default:job-deps:test\""],"cache":[{"key":"$CI_JOB_NAME-$CI_COMMIT_REF_SLUG","paths":[".nix-cache/"]}],"image":"$NIX_CI_IMAGE","script":["hello","curl google.de","echo $TEST $TEST_WITH_DERIVATION"],"stage":"test","variables":{"NIX_CI_CACHE_STRATEGY":"runner","TEST":"test"}},"test-default":{"after_script":["finalize_nix_ci"],"before_script":["source setup_nix_ci \"gitlab-ci:pipeline:default:job-deps:test-default\""],"cache":[],"image":"$NIX_CI_IMAGE","script":["hello"],"stage":"test","variables":{}},"test-non-nix":{"image":"alpine:latest","script":["echo \"This job will not be modified to use nix\""],"stage":"test"}} \ No newline at end of file diff --git a/snapshots/non-default.snap.json b/snapshots/non-default.snap.json new file mode 100644 index 0000000..6a613ef --- /dev/null +++ b/snapshots/non-default.snap.json @@ -0,0 +1 @@ +{"stages":["test"],"test":{"after_script":["finalize_nix_ci"],"before_script":["source setup_nix_ci \"gitlab-ci:pipeline:non-default:job-deps:test\""],"cache":[],"image":"$NIX_CI_IMAGE","script":["echo Hello from another pipeline"],"stage":"test","variables":{}}} \ No newline at end of file