Move validate step into Nix script

This commit is contained in:
Greg Hellings
2024-06-24 23:13:53 -05:00
parent f138e5af3e
commit 2d124c652a
2 changed files with 20 additions and 6 deletions
+3 -6
View File
@@ -34,6 +34,8 @@ distros:
validate: validate:
stage: lint stage: lint
tags:
- nix
needs: needs:
- generate - generate
cache: cache:
@@ -42,12 +44,7 @@ validate:
- sources/build.pkr.hcl - sources/build.pkr.hcl
paths: paths:
- ./packer_config/ - ./packer_config/
script: |- script: nix run ".#validate"
set -exo pipefail
packer init sources
for vars in $(find distros/ -name '*.pkrvars.hcl'); do
packer validate -except=upload -var-file=${vars} sources/
done
shellcheck: shellcheck:
stage: lint stage: lint
+17
View File
@@ -43,6 +43,10 @@
package = self'.packages.shellcheck; package = self'.packages.shellcheck;
category = "utils"; category = "utils";
help = "Run shellchecks"; help = "Run shellchecks";
} {
package = self'.packages.validate;
category = "utils";
help = "Validate all the files";
} ]; } ];
}; };
@@ -80,6 +84,19 @@
shellcheck -e SC2239 "''${scripts[@]}" shellcheck -e SC2239 "''${scripts[@]}"
''; '';
}; };
validate = pkgs.writeShellApplication {
name = "validate";
runtimeInputs = with pkgs; [
packer
];
text = ''
shopt -s globstar
packer init sources
for vars in distros/**/*.pkrvars.hcl; do
packer validate -except=upload "-var-file=''${vars}" sources/
done
'';
};
}; };
# https://numtide.github.io/treefmt/ # https://numtide.github.io/treefmt/