mirror of
https://github.com/docker/buildx.git
synced 2024-11-22 15:37:16 +08:00
6d5823beb1
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
56 lines
1.7 KiB
Bash
Executable File
56 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -eu -o pipefail
|
|
|
|
: "${BUILDX_CMD=docker buildx}"
|
|
|
|
: "${TEST_COVERAGE=}"
|
|
: "${TEST_IMAGE_BUILD=1}"
|
|
: "${TEST_IMAGE_ID=buildx-tests}"
|
|
|
|
: "${TEST_REPORT_SUFFIX=}"
|
|
: "${TEST_KEEP_CACHE=}"
|
|
: "${TEST_DOCKERD=}"
|
|
: "${TEST_BUILDKIT_TAG=}"
|
|
: "${TEST_BUILDKIT_IMAGE=}"
|
|
: "${TEST_BUILDX_EXPERIMENTAL=}"
|
|
|
|
if [ "$TEST_IMAGE_BUILD" = "1" ]; then
|
|
${BUILDX_CMD} bake integration-test --set "*.output=type=docker,name=$TEST_IMAGE_ID"
|
|
fi
|
|
|
|
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"
|
|
|
|
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 /root/.cache/undock -v /go/pkg/mod --name "$cacheVolume" alpine
|
|
fi
|
|
if [ "$TEST_KEEP_CACHE" != "1" ]; then
|
|
trap 'docker rm -v $cacheVolume' EXIT
|
|
fi
|
|
|
|
if [ "$TEST_COVERAGE" = "1" ]; then
|
|
export GO_TEST_COVERPROFILE="/testreports/coverage-report$TEST_REPORT_SUFFIX.txt"
|
|
fi
|
|
|
|
cid=$(docker create --rm --privileged \
|
|
-v /tmp $testReportsVol \
|
|
--volumes-from=$cacheVolume \
|
|
-e GITHUB_REF \
|
|
-e TEST_DOCKERD \
|
|
-e TEST_BUILDKIT_IMAGE \
|
|
-e TEST_BUILDKIT_TAG \
|
|
-e TEST_BUILDX_EXPERIMENTAL \
|
|
-e SKIP_INTEGRATION_TESTS \
|
|
-e GOTESTSUM_FORMAT \
|
|
-e GO_TEST_COVERPROFILE \
|
|
${BUILDKIT_INTEGRATION_SNAPSHOTTER:+"-eBUILDKIT_INTEGRATION_SNAPSHOTTER"} \
|
|
-e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry \
|
|
$TEST_IMAGE_ID gotestsumandcover $gotestsumArgs --packages="${TESTPKGS:-./...}" -- $gotestArgs ${TESTFLAGS:--v})
|
|
|
|
docker start -a -i $cid
|