2019-08-08 00:50:00 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-11-22 03:03:55 +00:00
|
|
|
TYP=$1
|
2019-08-08 00:50:00 +00:00
|
|
|
|
2020-11-22 03:03:55 +00:00
|
|
|
. $(dirname $0)/util
|
2019-08-08 00:50:00 +00:00
|
|
|
set -e
|
|
|
|
|
2020-11-22 03:03:55 +00:00
|
|
|
usage() {
|
2020-11-23 18:27:49 +00:00
|
|
|
echo "usage: ./hack/build_ci_first_pass <binaries|integration-tests>"
|
2020-11-22 03:03:55 +00:00
|
|
|
exit 1
|
|
|
|
}
|
2019-08-08 00:50:00 +00:00
|
|
|
|
2020-11-22 03:03:55 +00:00
|
|
|
if [ -z "$TYP" ]; then
|
|
|
|
usage
|
|
|
|
fi
|
2019-08-21 00:26:48 +00:00
|
|
|
|
2020-11-22 03:03:55 +00:00
|
|
|
importCacheFlags=""
|
2019-08-08 00:50:00 +00:00
|
|
|
exportCacheFlags=""
|
|
|
|
exportFlags=""
|
|
|
|
|
2020-11-22 03:03:55 +00:00
|
|
|
if [ "$TRAVIS" = "true" ]; then
|
|
|
|
if [ -z "$TRAVIS_COMMIT" ]; then
|
|
|
|
echo "Travis commit required"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
if [ -f /tmp/buildkit-ci-cache-repo ]; then
|
|
|
|
exportCacheFlags="--cache-to=type=inline"
|
|
|
|
exportFlags="--output=type=image,push=true,name=$(cat /tmp/buildkit-ci-cache-repo)"
|
|
|
|
fi
|
|
|
|
if [ "$TYP" = "binaries" ]; then
|
|
|
|
importCacheFlags="--cache-from=type=registry,ref=cicache.buildk.it/moby/buildkit/master:binaries --cache-from=type=registry,ref=cicache.buildk.it/moby/buildkit/master:integration-tests"
|
|
|
|
exportFlags="$exportFlags:binaries"
|
|
|
|
elif [ "$TYP" = "integration-tests" ]; then
|
|
|
|
importCacheFlags="--cache-from=type=registry,ref=cicache.buildk.it/moby/buildkit/master:integration-tests"
|
|
|
|
exportFlags="$exportFlags:integration-tests"
|
|
|
|
fi
|
|
|
|
elif [ "$GITHUB_ACTIONS" = "true" ]; then
|
|
|
|
if [ -n "$cacheref" ]; then
|
|
|
|
importCacheFlags="--cache-from=type=local,src=$cacheref"
|
|
|
|
exportCacheFlags="--cache-to=type=local,dest=$cacheref"
|
|
|
|
fi
|
2019-08-08 00:50:00 +00:00
|
|
|
fi
|
|
|
|
|
2020-11-22 03:03:55 +00:00
|
|
|
case $TYP in
|
|
|
|
"binaries")
|
|
|
|
buildxCmd build $importCacheFlags $exportCacheFlags $exportFlags \
|
|
|
|
--target "binaries" \
|
|
|
|
$currentcontext
|
|
|
|
;;
|
|
|
|
"integration-tests")
|
|
|
|
buildxCmd build $importCacheFlags $exportCacheFlags $exportFlags \
|
|
|
|
--target "integration-tests-base" \
|
|
|
|
$currentcontext
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo >&2 "Unknown type $TYP"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|