mirror of
https://github.com/dhall-lang/dhall-kubernetes.git
synced 2024-09-10 23:15:30 +03:00
Improve coverage for ./scripts/generate.sh
(#100)
`./scripts/generate.sh` will now also auto-update the `./examples/*.dhall` files and `./package.dhall`, too
This commit is contained in:
parent
89e7c8ed0b
commit
1c6397ccde
23
Makefile
23
Makefile
@ -1,23 +0,0 @@
|
||||
.PHONY: install build check default
|
||||
|
||||
default: build
|
||||
README.md: docs/README.md.dhall
|
||||
./scripts/build-readme.sh
|
||||
|
||||
build: README.md
|
||||
mkdir -p types defaults
|
||||
dhall-kubernetes-generator "${OPENAPI_SPEC}"
|
||||
|
||||
dhall freeze --all --inplace ./types.dhall
|
||||
dhall freeze --all --inplace ./typesUnion.dhall
|
||||
dhall freeze --all --inplace ./defaults.dhall
|
||||
dhall freeze --all --inplace ./schemas.dhall
|
||||
check: build
|
||||
LC_ALL=en_US.UTF-8 ./scripts/check-source.py
|
||||
mkdir -p tmp
|
||||
LC_ALL=en_US.UTF-8 ./scripts/build-examples.py tmp
|
||||
install: build
|
||||
cp -r types defaults schemas "${out}"
|
||||
cp types.dhall defaults.dhall typesUnion.dhall schemas.dhall "${out}"
|
||||
cp README.md "${out}"
|
||||
|
@ -53,7 +53,7 @@ In the following example, we:
|
||||
-- examples/deploymentSimple.dhall
|
||||
|
||||
let kubernetes =
|
||||
../package.dhall sha256:0a6949aabfb5a1250f08c4e3a533024d4705bea98ace08d8d107417e54a9648a
|
||||
../package.dhall sha256:63eb2e2bb9a50632801b673e67e666740c09c89deb0a0d0592d165178b5eba53
|
||||
|
||||
let deployment =
|
||||
kubernetes.Deployment::{
|
||||
@ -144,14 +144,15 @@ Things to note in the following example:
|
||||
```dhall
|
||||
-- examples/ingress.dhall
|
||||
|
||||
let Prelude = ../Prelude.dhall
|
||||
let Prelude =
|
||||
../Prelude.dhall sha256:771c7131fc87e13eb18f770a27c59f9418879f7e230ba2a50e46f4461f43ec69
|
||||
|
||||
let map = Prelude.List.map
|
||||
|
||||
let kv = Prelude.JSON.keyText
|
||||
|
||||
let kubernetes =
|
||||
../package.dhall sha256:0a6949aabfb5a1250f08c4e3a533024d4705bea98ace08d8d107417e54a9648a
|
||||
../package.dhall sha256:63eb2e2bb9a50632801b673e67e666740c09c89deb0a0d0592d165178b5eba53
|
||||
|
||||
let Service = { name : Text, host : Text, version : Text }
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
let Prelude =
|
||||
../Prelude.dhall sha256:771c7131fc87e13eb18f770a27c59f9418879f7e230ba2a50e46f4461f43ec69
|
||||
|
||||
let kubernetes =
|
||||
../package.dhall sha256:0a6949aabfb5a1250f08c4e3a533024d4705bea98ace08d8d107417e54a9648a
|
||||
|
||||
let kv = (../Prelude.dhall).JSON.keyText
|
||||
let kv = Prelude.JSON.keyText
|
||||
|
||||
let deployment =
|
||||
kubernetes.Deployment::{
|
||||
|
@ -1,4 +1,5 @@
|
||||
let Prelude = ../Prelude.dhall
|
||||
let Prelude =
|
||||
../Prelude.dhall sha256:771c7131fc87e13eb18f770a27c59f9418879f7e230ba2a50e46f4461f43ec69
|
||||
|
||||
let map = Prelude.List.map
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
let Prelude =
|
||||
../Prelude.dhall sha256:771c7131fc87e13eb18f770a27c59f9418879f7e230ba2a50e46f4461f43ec69
|
||||
|
||||
let kubernetes =
|
||||
../package.dhall sha256:0a6949aabfb5a1250f08c4e3a533024d4705bea98ace08d8d107417e54a9648a
|
||||
|
||||
let kv = (../Prelude.dhall).JSON.keyText
|
||||
let kv = Prelude.JSON.keyText
|
||||
|
||||
let spec =
|
||||
{ selector = [ kv "app" "nginx" ]
|
||||
|
@ -1,4 +1,5 @@
|
||||
{ dhall
|
||||
{ coreutils
|
||||
, dhall
|
||||
, dhall-json
|
||||
, dhallPackages
|
||||
, glibcLocales
|
||||
@ -8,22 +9,75 @@
|
||||
, python3
|
||||
, stdenv
|
||||
}:
|
||||
|
||||
let
|
||||
# Ignore generated files
|
||||
ignoreOutputs = name: type: !(lib.elem name (map toString [../README.md ../types ../defaults ../schemas ../defaults.dhall ../types.dhall ../typesUnion.dhall ../schemas.dhall ]));
|
||||
ignoreOutputs =
|
||||
name: type:
|
||||
!(lib.elem name
|
||||
(map toString
|
||||
[ ../README.md
|
||||
../types
|
||||
../defaults
|
||||
../schemas
|
||||
../defaults.dhall
|
||||
../types.dhall
|
||||
../typesUnion.dhall
|
||||
../schemas.dhall
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "dhall-kubernetes";
|
||||
DHALL_PRELUDE = "${dhallPackages.prelude}/package.dhall";
|
||||
OPENAPI_SPEC = "${kubernetes-openapi-spec}";
|
||||
doCheck = true;
|
||||
buildInputs = [ haskellPackages.dhall-kubernetes-generator dhall dhall-json python3 glibcLocales ];
|
||||
preBuild = ''
|
||||
patchShebangs ./scripts/build-readme.sh
|
||||
'';
|
||||
preCheck = ''
|
||||
patchShebangs ./scripts/build-examples.py
|
||||
patchShebangs ./scripts/check-source.py
|
||||
'';
|
||||
src = lib.cleanSourceWith {filter = ignoreOutputs; src = lib.cleanSource ./..;};
|
||||
stdenv.mkDerivation {
|
||||
name = "dhall-kubernetes";
|
||||
|
||||
DHALL_PRELUDE = "${dhallPackages.prelude}/package.dhall";
|
||||
|
||||
XDG_CACHE_HOME = ".";
|
||||
|
||||
buildInputs =
|
||||
[ dhall
|
||||
dhall-json
|
||||
python3
|
||||
glibcLocales
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
patchShebangs ./scripts/build-readme.sh
|
||||
|
||||
./scripts/build-readme.sh
|
||||
|
||||
${coreutils}/bin/mkdir -p types defaults
|
||||
|
||||
${haskellPackages.dhall-kubernetes-generator}/bin/dhall-kubernetes-generator '${kubernetes-openapi-spec}'
|
||||
|
||||
for file in ./types.dhall ./typesUnion.dhall ./defaults.dhall ./schemas.dhall ./package.dhall ./examples/*.dhall; do
|
||||
echo "Freezing file '$file'"
|
||||
|
||||
${dhall}/bin/dhall freeze --all --inplace "$file"
|
||||
done
|
||||
'';
|
||||
|
||||
checkPhase = ''
|
||||
patchShebangs ./scripts/build-examples.py
|
||||
|
||||
patchShebangs ./scripts/check-source.py
|
||||
|
||||
LC_ALL=en_US.UTF-8 ./scripts/check-source.py
|
||||
|
||||
mkdir -p tmp
|
||||
|
||||
LC_ALL=en_US.UTF-8 ./scripts/build-examples.py tmp
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
${coreutils}/bin/mkdir --parents "$out"
|
||||
|
||||
cp -r types defaults schemas examples types.dhall defaults.dhall typesUnion.dhall schemas.dhall package.dhall README.md "$out"
|
||||
'';
|
||||
|
||||
src =
|
||||
lib.cleanSourceWith
|
||||
{ filter = ignoreOutputs; src = lib.cleanSource ./..; };
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
if dir=$(nix-build release.nix -A dhall-kubernetes --no-out-link); then
|
||||
if dir=$(nix-build release.nix --attr dhall-kubernetes --no-out-link); then
|
||||
rm -rf ./defaults ./types
|
||||
cp -r "$dir"/defaults .
|
||||
chmod u+w ./defaults
|
||||
@ -7,10 +7,10 @@ if dir=$(nix-build release.nix -A dhall-kubernetes --no-out-link); then
|
||||
chmod u+w ./types
|
||||
cp -r "$dir"/schemas .
|
||||
chmod u+w ./schemas
|
||||
cp "$dir"/types.dhall "$dir"/typesUnion.dhall "$dir"/defaults.dhall "$dir"/schemas.dhall .
|
||||
chmod u+w ./types.dhall ./typesUnion.dhall ./defaults.dhall ./schemas.dhall
|
||||
cp -r "$dir"/examples .
|
||||
chmod u+w ./examples
|
||||
cp "$dir"/types.dhall "$dir"/typesUnion.dhall "$dir"/defaults.dhall "$dir"/schemas.dhall "$dir"/package.dhall .
|
||||
chmod u+w ./types.dhall ./typesUnion.dhall ./defaults.dhall ./schemas.dhall ./package.dhall
|
||||
cp "$dir/README.md" README.md
|
||||
chmod u+w ./README.md
|
||||
fi
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user