@@ -13,6 +13,9 @@ set -eu -o pipefail
13
13
: ${TEST_DOCKERD_BINARY=$(which dockerd)}
14
14
: ${TEST_REPORT_SUFFIX=}
15
15
: ${TEST_KEEP_CACHE=}
16
+ : ${GOBUILDFLAGS=}
17
+ : ${VERIFYFLAGS=}
18
+ : ${CGO_ENABLED=}
16
19
: ${DOCKERFILE_RELEASES=}
17
20
: ${BUILDKIT_WORKER_RANDOM=}
18
21
: ${BUILDKITD_TAGS=}
@@ -60,11 +63,24 @@ testReportsVol="-v $testReportsDir:/testreports"
60
63
gotestsumArgs=" --format=standard-verbose --jsonfile=/testreports/go-test-report$TEST_REPORT_SUFFIX .json --junitfile=/testreports/junit-report$TEST_REPORT_SUFFIX .xml"
61
64
gotestArgs=" -mod=vendor -coverprofile=/testreports/coverage-report$TEST_REPORT_SUFFIX .txt -covermode=atomic"
62
65
66
+ if [[ " $GOBUILDFLAGS " == * " -race" * ]]; then
67
+ if [ " $CGO_ENABLED " != " 1" ]; then
68
+ echo >&2 " go race detector requires CGO_ENABLED=1"
69
+ exit 1
70
+ fi
71
+ # force buildkitd to halt on detected race conditions, which will cause the tests to fail
72
+ export GORACE=" halt_on_error=1"
73
+ export VERIFYFLAGS=" " # prevent -static verification
74
+ fi
75
+
63
76
buildxCmd build $cacheFromFlags \
64
77
--build-arg BUILDKITD_TAGS \
65
78
--build-arg HTTP_PROXY \
66
79
--build-arg HTTPS_PROXY \
67
80
--build-arg NO_PROXY \
81
+ --build-arg GOBUILDFLAGS \
82
+ --build-arg VERIFYFLAGS \
83
+ --build-arg CGO_ENABLED \
68
84
--target " integration-tests" \
69
85
--output " type=docker,name=$iid " \
70
86
$currentcontext
@@ -75,7 +91,7 @@ if ! docker container inspect "$cacheVolume" >/dev/null 2>/dev/null; then
75
91
fi
76
92
77
93
if [ " $TEST_INTEGRATION " == 1 ]; then
78
- cid=$( docker create --rm -v /tmp $testReportsVol --volumes-from=$cacheVolume -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e SKIP_INTEGRATION_TESTS -e BUILDKIT_TEST_ENABLE_FEATURES -e GOTESTSUM_FORMAT ${BUILDKIT_INTEGRATION_SNAPSHOTTER: +" -eBUILDKIT_INTEGRATION_SNAPSHOTTER" } -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry -e BUILDKIT_INTEGRATION_DOCKERD_FLAGS --privileged $iid gotestsum $gotestsumArgs --packages=" ${TESTPKGS:- ./ ...} " -- $gotestArgs ${TESTFLAGS:- -v} )
94
+ cid=$( docker create --rm -v /tmp $testReportsVol --volumes-from=$cacheVolume -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e SKIP_INTEGRATION_TESTS -e BUILDKIT_TEST_ENABLE_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} )
79
95
if [ " $TEST_DOCKERD " = " 1" ]; then
80
96
docker cp " $TEST_DOCKERD_BINARY " $cid :/usr/bin/dockerd
81
97
fi
@@ -115,7 +131,7 @@ if [ "$TEST_DOCKERFILE" == 1 ]; then
115
131
116
132
if [ -s $tarout ]; then
117
133
if [ " $release " = " mainline" ] || [ " $release " = " labs" ] || [ -n " $DOCKERFILE_RELEASES_CUSTOM " ] || [ " $GITHUB_ACTIONS " = " true" ]; then
118
- cid=$( docker create -v /tmp $testReportsVol --rm --privileged --volumes-from=$cacheVolume -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e BUILDKIT_TEST_ENABLE_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 $iid gotestsum $gotestsumArgs --packages=./frontend/dockerfile -- $gotestArgs --count=1 -tags " $buildtags " ${TESTFLAGS:- -v} )
134
+ cid=$( docker create -v /tmp $testReportsVol --rm --privileged --volumes-from=$cacheVolume -e GITHUB_REF -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e TEST_DOCKERD -e BUILDKIT_TEST_ENABLE_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} )
119
135
docker cp $tarout $cid :/$release .tar
120
136
if [ " $TEST_DOCKERD " = " 1" ]; then
121
137
docker cp " $TEST_DOCKERD_BINARY " $cid :/usr/bin/dockerd
0 commit comments