Skip to content

Commit 86ba834

Browse files
crazy-maxiQQBot
authored andcommitted
hack(test): opt to avoid building the integration tests image
Signed-off-by: CrazyMax <[email protected]>
1 parent 974e9bc commit 86ba834

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

hack/test

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ set -eu -o pipefail
88
: "${HTTPS_PROXY=}"
99
: "${NO_PROXY=}"
1010

11+
: "${TEST_IMAGE_BUILD=1}"
12+
: "${TEST_IMAGE_ID=buildkit-tests}"
1113
: "${TEST_INTEGRATION=}"
1214
: "${TEST_GATEWAY=}"
1315
: "${TEST_DOCKERFILE=}"
@@ -57,9 +59,6 @@ while test $# -gt 0; do
5759
shift
5860
done
5961

60-
iid="buildkit-tests"
61-
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
62-
6362
testReportsDir="$(pwd)/bin/testreports"
6463
mkdir -p "$testReportsDir"
6564
testReportsVol="-v $testReportsDir:/testreports"
@@ -76,18 +75,20 @@ if [[ "$GOBUILDFLAGS" == *"-race"* ]]; then
7675
export VERIFYFLAGS="" # prevent -static verification
7776
fi
7877

79-
buildxCmd build $cacheFromFlags \
80-
--build-arg GO_VERSION \
81-
--build-arg BUILDKITD_TAGS \
82-
--build-arg HTTP_PROXY \
83-
--build-arg HTTPS_PROXY \
84-
--build-arg NO_PROXY \
85-
--build-arg GOBUILDFLAGS \
86-
--build-arg VERIFYFLAGS \
87-
--build-arg CGO_ENABLED \
88-
--target "integration-tests" \
89-
--output "type=docker,name=$iid" \
90-
$currentcontext
78+
if [ "$TEST_IMAGE_BUILD" = "1" ]; then
79+
buildxCmd build $cacheFromFlags \
80+
--build-arg GO_VERSION \
81+
--build-arg BUILDKITD_TAGS \
82+
--build-arg HTTP_PROXY \
83+
--build-arg HTTPS_PROXY \
84+
--build-arg NO_PROXY \
85+
--build-arg GOBUILDFLAGS \
86+
--build-arg VERIFYFLAGS \
87+
--build-arg CGO_ENABLED \
88+
--target "integration-tests" \
89+
--output "type=docker,name=$TEST_IMAGE_ID" \
90+
$currentcontext
91+
fi
9192

9293
cacheVolume="buildkit-test-cache"
9394
if ! docker container inspect "$cacheVolume" >/dev/null 2>/dev/null; then
@@ -98,7 +99,7 @@ if [ "$TEST_KEEP_CACHE" != "1" ]; then
9899
fi
99100

100101
if [ "$TEST_INTEGRATION" == 1 ]; then
101-
cid=$(docker create --rm -v /tmp $testReportsVol --volumes-from=$cacheVolume -e CGO_ENABLED -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e SKIP_INTEGRATION_TESTS -e BUILDKIT_TEST_ENABLE_FEATURES -e BUILDKIT_TEST_DISABLE_FEATURES -e GOTESTSUM_FORMAT ${BUILDKIT_INTEGRATION_SNAPSHOTTER:+"-eBUILDKIT_INTEGRATION_SNAPSHOTTER"} -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry -e BUILDKIT_INTEGRATION_DOCKERD_FLAGS -e GORACE --privileged $iid gotestsum $gotestsumArgs --packages="${TESTPKGS:-./...}" -- $gotestArgs ${TESTFLAGS:--v})
102+
cid=$(docker create --rm -v /tmp $testReportsVol --volumes-from=$cacheVolume -e CGO_ENABLED -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e SKIP_INTEGRATION_TESTS -e BUILDKIT_TEST_ENABLE_FEATURES -e BUILDKIT_TEST_DISABLE_FEATURES -e GOTESTSUM_FORMAT ${BUILDKIT_INTEGRATION_SNAPSHOTTER:+"-eBUILDKIT_INTEGRATION_SNAPSHOTTER"} -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry -e BUILDKIT_INTEGRATION_DOCKERD_FLAGS -e GORACE --privileged $TEST_IMAGE_ID gotestsum $gotestsumArgs --packages="${TESTPKGS:-./...}" -- $gotestArgs ${TESTFLAGS:--v})
102103
if [ "$TEST_DOCKERD" = "1" ]; then
103104
docker cp "$TEST_DOCKERD_BINARY" $cid:/usr/bin/dockerd
104105
fi
@@ -107,8 +108,8 @@ fi
107108

108109
if [ "$TEST_GATEWAY" == 1 ]; then
109110
# Build-test "github.com/moby/buildkit/frontend/gateway/client", which isn't otherwise built by CI
110-
# It really only needs buildkit-base. We have integration-tests in $iid, which is a direct child of buildkit-base.
111-
cid=$(docker create --rm --volumes-from=$cacheVolume --entrypoint="" $iid go build -v ./frontend/gateway/client)
111+
# It really only needs buildkit-base. We have integration-tests in $TEST_IMAGE_ID, which is a direct child of buildkit-base.
112+
cid=$(docker create --rm --volumes-from=$cacheVolume --entrypoint="" $TEST_IMAGE_ID go build -v ./frontend/gateway/client)
112113
docker start -a $cid
113114
fi
114115

@@ -138,8 +139,7 @@ if [ "$TEST_DOCKERFILE" == 1 ]; then
138139

139140
if [ -s $tarout ]; then
140141
if [ "$release" = "mainline" ] || [ "$release" = "labs" ] || [ -n "$DOCKERFILE_RELEASES_CUSTOM" ] || [ "$GITHUB_ACTIONS" = "true" ]; then
141-
cid=$(docker create -v /tmp $testReportsVol --rm --privileged --volumes-from=$cacheVolume -e CGO_ENABLED -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e BUILDKIT_TEST_ENABLE_FEATURES -e BUILDKIT_TEST_DISABLE_FEATURES -e GOTESTSUM_FORMAT -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry -e BUILDKIT_WORKER_RANDOM -e BUILDKIT_INTEGRATION_DOCKERD_FLAGS -e FRONTEND_GATEWAY_ONLY=local:/$release.tar -e EXTERNAL_DF_FRONTEND=/dockerfile-frontend -e GORACE $iid gotestsum $gotestsumArgs --packages=./frontend/dockerfile -- $gotestArgs --count=1 -tags "$buildtags" ${TESTFLAGS:--v})
142-
docker cp $tarout $cid:/$release.tar
142+
cid=$(docker create -v /tmp $testReportsVol --rm --privileged --volumes-from=$cacheVolume -e CGO_ENABLED -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e BUILDKIT_TEST_ENABLE_FEATURES -e BUILDKIT_TEST_DISABLE_FEATURES -e GOTESTSUM_FORMAT -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry -e BUILDKIT_WORKER_RANDOM -e BUILDKIT_INTEGRATION_DOCKERD_FLAGS -e FRONTEND_GATEWAY_ONLY=local:/$release.tar -e EXTERNAL_DF_FRONTEND=/dockerfile-frontend -e GORACE $TEST_IMAGE_ID gotestsum $gotestsumArgs --packages=./frontend/dockerfile -- $gotestArgs --count=1 -tags "$buildtags" ${TESTFLAGS:--v})
143143
if [ "$TEST_DOCKERD" = "1" ]; then
144144
docker cp "$TEST_DOCKERD_BINARY" $cid:/usr/bin/dockerd
145145
fi

0 commit comments

Comments
 (0)