Skip to content

Commit

Permalink
ci(buildkit): fix timeout for image job
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Dec 16, 2023
1 parent b642b72 commit c11cf91
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/buildkit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ env:
IMAGE_NAME: "moby/buildkit"
PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le,linux/riscv64"
DESTDIR: "./bin"
BUILD_TIMEOUT: "900" # 15 minutes
IMAGE_BUILD_TIMEOUT: "900" # 15 minutes

jobs:
prepare:
Expand Down Expand Up @@ -177,12 +177,22 @@ jobs:
-
name: Build ${{ needs.prepare.outputs.tag }}
run: |
timeout ${BUILD_TIMEOUT} ./hack/images "${{ needs.prepare.outputs.tag }}" "$IMAGE_NAME" "${{ needs.prepare.outputs.push }}"
if [ $? -eq 124 ]; then
echo "::error::Build timed out after ${BUILD_TIMEOUT} seconds"
docker kill --signal=SIGQUIT buildx_buildkit_${{ steps.buildx.outputs.name }}
exit 1
fi
./hack/images "${{ needs.prepare.outputs.tag }}" "$IMAGE_NAME" "${{ needs.prepare.outputs.push }}" &
bpid=$!
sleepinter=10
iter=$(( ${{ env.IMAGE_BUILD_TIMEOUT }} / $sleepinter ))
for ((i = 0; i < iter; i++)); do
if ! kill -0 $bpid 2>/dev/null; then
exit 0
fi
sleep $sleepinter
done
echo "::error::Build timed out after ${IMAGE_BUILD_TIMEOUT} seconds"
set -x
docker kill --signal=SIGQUIT buildx_buildkit_${{ steps.buildx.outputs.name }}0
kill -15 $bpid
wait $bpid
exit 1
env:
BUILDX_CMD: docker --debug buildx
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
Expand Down

0 comments on commit c11cf91

Please sign in to comment.