mirror of
https://github.com/moby/buildkit.git
synced 2026-08-09 09:11:45 +00:00
This allows running Dockerfile tests so that the Dockerfile version and the BuildKit version are from different commits so that we can test that old Dockerfile releases remain compatible with the latest BuildKit. The tests are based on the commit of the Dockerfile frontend as we can't expect that new test would work on old frontends. In future we might consider doing it the other way as well but then we need a way to mark tests that can be ignored if they are not expected to pass because of a new feature dependency. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
74 lines
1.9 KiB
Bash
Executable File
74 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
: "${BUILDX_CMD=docker buildx}"
|
|
: "${BUILDX_BUILDER=}"
|
|
|
|
: "${GITHUB_ACTIONS=}"
|
|
: "${GITHUB_REPOSITORY=}"
|
|
: "${GITHUB_RUN_ID=}"
|
|
: "${GITHUB_TOKEN=}"
|
|
|
|
: "${CONTEXT=}"
|
|
: "${CACHE_FROM=}"
|
|
: "${CACHE_TO=}"
|
|
|
|
dockerCmd() {
|
|
(
|
|
set -x
|
|
docker "$@"
|
|
)
|
|
}
|
|
|
|
buildxCmd() {
|
|
(
|
|
set -x
|
|
BUILDX_NO_DEFAULT_LOAD=true BUILDX_BUILDER="${BUILDX_BUILDER}" ${BUILDX_CMD} "$@"
|
|
)
|
|
}
|
|
|
|
buildAttestFlags() {
|
|
if ${BUILDX_CMD} build --help 2>&1 | grep -- '--attest' >/dev/null; then
|
|
prvattrs="mode=max"
|
|
if [ "$GITHUB_ACTIONS" = "true" ]; then
|
|
prvattrs="$prvattrs,builder-id=https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
|
|
fi
|
|
echo "--attest=type=sbom --attest=type=provenance,$prvattrs"
|
|
fi
|
|
}
|
|
|
|
currentcontext="."
|
|
cacheFromFlags=""
|
|
cacheToFlags=""
|
|
if [ "$GITHUB_ACTIONS" = "true" ] && [ "$GITHUB_REPOSITORY" = "moby/buildkit" ]; then
|
|
currentcontext="https://github.com/$GITHUB_REPOSITORY.git#$GITHUB_REF"
|
|
if [ -n "$CACHE_FROM" ]; then
|
|
for cfrom in $CACHE_FROM; do
|
|
if [[ $cfrom == *"type=gha"* ]]; then
|
|
if [[ -n "$GITHUB_REPOSITORY" ]] && [[ $cfrom != *"repository="* ]]; then
|
|
cfrom="${cfrom},repository=${GITHUB_REPOSITORY}"
|
|
fi
|
|
if [[ -n "$GITHUB_TOKEN" ]] && [[ $cfrom != *"ghtoken="* ]]; then
|
|
cfrom="${cfrom},ghtoken=${GITHUB_TOKEN}"
|
|
fi
|
|
fi
|
|
cacheFromFlags="${cacheFromFlags}--cache-from=$cfrom "
|
|
done
|
|
fi
|
|
if [ -n "$CACHE_TO" ]; then
|
|
for cto in $CACHE_TO; do
|
|
if [[ $cto == *"type=gha"* ]]; then
|
|
if [[ -n "$GITHUB_REPOSITORY" ]] && [[ $cto != *"repository="* ]]; then
|
|
cto="${cto},repository=${GITHUB_REPOSITORY}"
|
|
fi
|
|
if [[ -n "$GITHUB_TOKEN" ]] && [[ $cto != *"ghtoken="* ]]; then
|
|
cto="${cto},ghtoken=${GITHUB_TOKEN}"
|
|
fi
|
|
fi
|
|
cacheToFlags="${cacheToFlags}--cache-to=$cto "
|
|
done
|
|
fi
|
|
fi
|
|
if [ -n "$CONTEXT" ]; then
|
|
currentcontext=$CONTEXT
|
|
fi
|