mirror of https://github.com/docker/buildx.git
test: opt to avoid building the integration tests image
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
b9cf46785b
commit
74b121be66
22
hack/test
22
hack/test
|
@ -3,26 +3,18 @@
|
||||||
set -eu -o pipefail
|
set -eu -o pipefail
|
||||||
|
|
||||||
: "${BUILDX_CMD=docker buildx}"
|
: "${BUILDX_CMD=docker buildx}"
|
||||||
: "${CACHE_FROM=}"
|
|
||||||
: "${CACHE_TO=}"
|
: "${TEST_IMAGE_BUILD=1}"
|
||||||
|
: "${TEST_IMAGE_ID=buildx-tests}"
|
||||||
|
|
||||||
: "${TEST_REPORT_SUFFIX=}"
|
: "${TEST_REPORT_SUFFIX=}"
|
||||||
: "${TEST_KEEP_CACHE=}"
|
: "${TEST_KEEP_CACHE=}"
|
||||||
: "${TEST_DOCKERD=}"
|
: "${TEST_DOCKERD=}"
|
||||||
: "${TEST_BUILDKIT_IMAGE=}"
|
: "${TEST_BUILDKIT_IMAGE=}"
|
||||||
|
|
||||||
if [ -n "$CACHE_FROM" ]; then
|
if [ "$TEST_IMAGE_BUILD" = "1" ]; then
|
||||||
for cfrom in $CACHE_FROM; do
|
${BUILDX_CMD} bake integration-test --set "*.output=type=docker,name=$TEST_IMAGE_ID"
|
||||||
setFlags+=(--set "*.cache-from=$cfrom")
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
if [ -n "$CACHE_TO" ]; then
|
|
||||||
for cto in $CACHE_TO; do
|
|
||||||
setFlags+=(--set "*.cache-to=$cto")
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
iid="buildx-tests"
|
|
||||||
|
|
||||||
testReportsDir="$(pwd)/bin/testreports"
|
testReportsDir="$(pwd)/bin/testreports"
|
||||||
mkdir -p "$testReportsDir"
|
mkdir -p "$testReportsDir"
|
||||||
|
@ -30,8 +22,6 @@ 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"
|
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"
|
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"
|
cacheVolume="buildx-test-cache"
|
||||||
if ! docker container inspect "$cacheVolume" >/dev/null 2>/dev/null; then
|
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
|
docker create -v /root/.cache -v /root/.cache/registry -v /go/pkg/mod --name "$cacheVolume" alpine
|
||||||
|
@ -40,5 +30,5 @@ if [ "$TEST_KEEP_CACHE" != "1" ]; then
|
||||||
trap 'docker rm -v $cacheVolume' EXIT
|
trap 'docker rm -v $cacheVolume' EXIT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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})
|
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 $TEST_IMAGE_ID gotestsum $gotestsumArgs --packages="${TESTPKGS:-./...}" -- $gotestArgs ${TESTFLAGS:--v})
|
||||||
docker start -a -i $cid
|
docker start -a -i $cid
|
||||||
|
|
Loading…
Reference in New Issue