mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-03 17:43:42 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			54 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env bash
 | 
						|
 | 
						|
. $(dirname $0)/util
 | 
						|
set -eu -o pipefail
 | 
						|
 | 
						|
: ${CONTINUOUS_INTEGRATION=}
 | 
						|
: ${BUILDX_NOCACHE=}
 | 
						|
 | 
						|
progressFlag=""
 | 
						|
if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi
 | 
						|
 | 
						|
iid="buildx-tests"
 | 
						|
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
 | 
						|
set -x
 | 
						|
 | 
						|
case $buildmode in
 | 
						|
"buildkit")
 | 
						|
  tmpfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
 | 
						|
  buildctl build $progressFlag --frontend=dockerfile.v0 \
 | 
						|
    --local context=. --local dockerfile=. \
 | 
						|
    --frontend-opt target=integration-tests \
 | 
						|
    --output type=docker,name=$iid,dest=$tmpfile
 | 
						|
  docker load -i $tmpfile
 | 
						|
  rm $tmpfile
 | 
						|
  ;;
 | 
						|
"docker-buildkit")
 | 
						|
  export DOCKER_BUILDKIT=1
 | 
						|
  docker build --iidfile $iidfile --target integration-tests --force-rm .
 | 
						|
  iid=$(cat $iidfile)
 | 
						|
  ;;
 | 
						|
*)
 | 
						|
  echo "docker with buildkit support is required"
 | 
						|
  exit 1
 | 
						|
  ;;
 | 
						|
esac
 | 
						|
 | 
						|
cacheVolume="buildx-cache"
 | 
						|
if ! docker inspect "$cacheVolume" 2>&1 >/dev/null ; then
 | 
						|
cacheVolume=$(docker create --name=buildx-cache -v /root/.cache -v /go/pkg/mod alpine)
 | 
						|
fi
 | 
						|
 | 
						|
docker run --rm -v /tmp --volumes-from=$cacheVolume --privileged $iid go test ${TESTFLAGS:--v} ${TESTPKGS:-./...}
 | 
						|
 | 
						|
if [ -n "$BUILDX_NOCACHE" ]; then
 | 
						|
  docker rm -v $cacheVolume
 | 
						|
fi
 | 
						|
 | 
						|
case $buildmode in
 | 
						|
"docker-buildkit")
 | 
						|
  rm "$iidfile"
 | 
						|
  docker rmi $iid
 | 
						|
  ;;
 | 
						|
esac
 |