You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.9 KiB
Plaintext
63 lines
1.9 KiB
Plaintext
2 years ago
|
#!/usr/bin/env bash
|
||
|
|
||
|
set -eu -o pipefail
|
||
|
|
||
|
: "${BUILDX_CMD=docker buildx}"
|
||
|
: "${CACHE_FROM=}"
|
||
|
: "${CACHE_TO=}"
|
||
|
|
||
|
: ${TEST_INTEGRATION=}
|
||
|
: ${TEST_REPORT_SUFFIX=}
|
||
|
: ${TEST_KEEP_CACHE=}
|
||
|
: ${TEST_DOCKERD=}
|
||
|
: ${TEST_BUILDKIT_IMAGE=}
|
||
|
|
||
|
if [ -n "$CACHE_FROM" ]; then
|
||
|
for cfrom in $CACHE_FROM; do
|
||
|
setFlags+=(--set "*.cache-from=$cfrom")
|
||
|
done
|
||
|
fi
|
||
|
if [ -n "$CACHE_TO" ]; then
|
||
|
for cto in $CACHE_TO; do
|
||
|
setFlags+=(--set "*.cache-to=$cto")
|
||
|
done
|
||
|
fi
|
||
|
|
||
|
if [ "$#" == 0 ]; then TEST_INTEGRATION=1; fi
|
||
|
|
||
|
while test $# -gt 0; do
|
||
|
case "$1" in
|
||
|
integration)
|
||
|
TEST_INTEGRATION=1
|
||
|
;;
|
||
|
*)
|
||
|
echo "unknown arg $1"
|
||
|
;;
|
||
|
esac
|
||
|
shift
|
||
|
done
|
||
|
|
||
|
iid="buildx-tests"
|
||
|
|
||
|
testReportsDir="$(pwd)/bin/testreports"
|
||
|
mkdir -p "$testReportsDir"
|
||
|
testReportsVol="-v $testReportsDir:/testreports"
|
||
|
gotestsumArgs="--format=standard-verbose --jsonfile=/testreports/go-test-report$TEST_REPORT_SUFFIX.json --junitfile=/testreports/junit-report$TEST_REPORT_SUFFIX.xml"
|
||
|
gotestArgs="-mod=vendor -coverprofile=/testreports/coverage-report$TEST_REPORT_SUFFIX.txt -covermode=atomic"
|
||
|
|
||
|
${BUILDX_CMD} bake integration-test "${setFlags[@]}" --set "*.output=type=docker,name=$iid"
|
||
|
|
||
|
cacheVolume="buildx-test-cache"
|
||
|
if ! docker container inspect "$cacheVolume" >/dev/null 2>/dev/null; then
|
||
|
docker create -v /root/.cache -v /root/.cache/registry -v /go/pkg/mod --name "$cacheVolume" alpine
|
||
|
fi
|
||
|
|
||
|
if [ "$TEST_INTEGRATION" == 1 ]; then
|
||
|
cid=$(docker create --rm -v /tmp $testReportsVol --volumes-from=$cacheVolume -e GITHUB_REF -e TEST_DOCKERD -e TEST_BUILDKIT_IMAGE -e SKIP_INTEGRATION_TESTS -e GOTESTSUM_FORMAT ${BUILDKIT_INTEGRATION_SNAPSHOTTER:+"-eBUILDKIT_INTEGRATION_SNAPSHOTTER"} -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry --privileged $iid gotestsum $gotestsumArgs --packages="${TESTPKGS:-./...}" -- $gotestArgs ${TESTFLAGS:--v})
|
||
|
docker start -a -i $cid
|
||
|
fi
|
||
|
|
||
|
if [ "$TEST_KEEP_CACHE" != "1" ]; then
|
||
|
docker rm -v $cacheVolume
|
||
|
fi
|