Refactor validate for GitHub Actions

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2020-11-30 08:14:23 +01:00
parent 1ccf0bd7d8
commit d66d3a2d09
8 changed files with 120 additions and 83 deletions

View File

@ -1,40 +1,20 @@
#!/usr/bin/env sh
set -eu
: ${CONTINUOUS_INTEGRATION=}
: ${DOCKER_BUILDKIT=}
progressFlag=""
if [ "$CONTINUOUS_INTEGRATION" = "true" ]; then progressFlag="--progress=plain"; fi
case ${1:-} in
'')
. $(dirname $0)/util
case $buildmode in
"buildkit")
buildctl build $progressFlag --frontend=dockerfile.v0 --local context=. --local dockerfile=. --frontend-opt filename=./hack/dockerfiles/vendor.Dockerfile --frontend-opt target=validate
'')
. $(dirname $0)/util
buildxCmd build \
--target validate \
--file ./hack/dockerfiles/vendor.Dockerfile \
.
;;
"docker-buildkit")
export DOCKER_BUILDKIT=1
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
docker build --iidfile $iidfile -f ./hack/dockerfiles/vendor.Dockerfile --target validate --force-rm . || exit 1
iid=$(cat $iidfile)
docker rmi $iid
rm -f $iidfile
;;
*)
echo "buildkit support is required"
exit 1
;;
esac
;;
check)
status="$(git status --porcelain -- go.mod go.sum vendor 2>/dev/null)"
diffs=$(echo "$status" | grep -v '^[RAD] ' || true)
if [ "$diffs" ]; then
check)
status="$(git status --porcelain -- go.mod go.sum vendor 2>/dev/null)"
diffs=$(echo "$status" | grep -v '^[RAD] ' || true)
if [ "$diffs" ]; then
{
set +x
set +x
echo 'The result of "make vendor" differs'
echo
echo "$diffs"
@ -43,7 +23,7 @@ check)
echo
} >&2
exit 1
fi
echo 'Congratulations! All vendoring changes are done the right way.'
;;
fi
echo 'Congratulations! All vendoring changes are done the right way.'
;;
esac