Skip to content

Commit

Permalink
Retry build if failed
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha0552 authored Aug 7, 2024
1 parent 07e31ec commit 9c3c012
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 16 deletions.
37 changes: 35 additions & 2 deletions .ci/template/gh-build-iso.yml.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,41 @@ jobs:
.ci/configure.py {{ platform }} {{ type }}
popd

# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Number of retries
MAX_RETRIES=5

# Try to build image
for ((i=1; i<=MAX_RETRIES; i++)); do
# Do not exit on error
set +e

# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace

# Capture exit code
STATUS=$?

# Exit on error
set -e

# Check if build succeeded
if [ $STATUS -eq 0 ]; then
echo "Build succeeded"
break
fi

# Print failure message and retry
echo "Build failed. Retry $i/$MAX_RETRIES"

# Remove build directory
rm -rf /_work
done

# Check if maximum retries were exhausted
if [ $STATUS -ne 0 ]; then
echo "Build failed after $MAX_RETRIES attempts"
exit 1
fi

- name: Create summary
run: |
Expand Down
37 changes: 35 additions & 2 deletions .ci/template/sh-build-iso.yml.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,41 @@ jobs:
.ci/configure.py {{ platform }} {{ type }}
popd

# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Number of retries
MAX_RETRIES=5

# Try to build image
for ((i=1; i<=MAX_RETRIES; i++)); do
# Do not exit on error
set +e

# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace

# Capture exit code
STATUS=$?

# Exit on error
set -e

# Check if build succeeded
if [ $STATUS -eq 0 ]; then
echo "Build succeeded"
break
fi

# Print failure message and retry
echo "Build failed. Retry $i/$MAX_RETRIES"

# Remove build directory
rm -rf /_work
done

# Check if maximum retries were exhausted
if [ $STATUS -ne 0 ]; then
echo "Build failed after $MAX_RETRIES attempts"
exit 1
fi

- name: Create summary
run: |
Expand Down
37 changes: 35 additions & 2 deletions .github/workflows/gh-build-iso-cuda-empty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,41 @@ jobs:
.ci/configure.py cuda empty
popd
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Number of retries
MAX_RETRIES=5
# Try to build image
for ((i=1; i<=MAX_RETRIES; i++)); do
# Do not exit on error
set +e
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Capture exit code
STATUS=$?
# Exit on error
set -e
# Check if build succeeded
if [ $STATUS -eq 0 ]; then
echo "Build succeeded"
break
fi
# Print failure message and retry
echo "Build failed. Retry $i/$MAX_RETRIES"
# Remove build directory
rm -rf /_work
done
# Check if maximum retries were exhausted
if [ $STATUS -ne 0 ]; then
echo "Build failed after $MAX_RETRIES attempts"
exit 1
fi
- name: Create summary
run: |
Expand Down
37 changes: 35 additions & 2 deletions .github/workflows/gh-build-iso-cuda-gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,41 @@ jobs:
.ci/configure.py cuda gui
popd
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Number of retries
MAX_RETRIES=5
# Try to build image
for ((i=1; i<=MAX_RETRIES; i++)); do
# Do not exit on error
set +e
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Capture exit code
STATUS=$?
# Exit on error
set -e
# Check if build succeeded
if [ $STATUS -eq 0 ]; then
echo "Build succeeded"
break
fi
# Print failure message and retry
echo "Build failed. Retry $i/$MAX_RETRIES"
# Remove build directory
rm -rf /_work
done
# Check if maximum retries were exhausted
if [ $STATUS -ne 0 ]; then
echo "Build failed after $MAX_RETRIES attempts"
exit 1
fi
- name: Create summary
run: |
Expand Down
37 changes: 35 additions & 2 deletions .github/workflows/gh-build-iso-cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,41 @@ jobs:
.ci/configure.py cuda normal
popd
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Number of retries
MAX_RETRIES=5
# Try to build image
for ((i=1; i<=MAX_RETRIES; i++)); do
# Do not exit on error
set +e
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Capture exit code
STATUS=$?
# Exit on error
set -e
# Check if build succeeded
if [ $STATUS -eq 0 ]; then
echo "Build succeeded"
break
fi
# Print failure message and retry
echo "Build failed. Retry $i/$MAX_RETRIES"
# Remove build directory
rm -rf /_work
done
# Check if maximum retries were exhausted
if [ $STATUS -ne 0 ]; then
echo "Build failed after $MAX_RETRIES attempts"
exit 1
fi
- name: Create summary
run: |
Expand Down
37 changes: 35 additions & 2 deletions .github/workflows/gh-build-iso-rocm-empty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,41 @@ jobs:
.ci/configure.py rocm empty
popd
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Number of retries
MAX_RETRIES=5
# Try to build image
for ((i=1; i<=MAX_RETRIES; i++)); do
# Do not exit on error
set +e
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Capture exit code
STATUS=$?
# Exit on error
set -e
# Check if build succeeded
if [ $STATUS -eq 0 ]; then
echo "Build succeeded"
break
fi
# Print failure message and retry
echo "Build failed. Retry $i/$MAX_RETRIES"
# Remove build directory
rm -rf /_work
done
# Check if maximum retries were exhausted
if [ $STATUS -ne 0 ]; then
echo "Build failed after $MAX_RETRIES attempts"
exit 1
fi
- name: Create summary
run: |
Expand Down
37 changes: 35 additions & 2 deletions .github/workflows/sh-build-iso-rocm-gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,41 @@ jobs:
.ci/configure.py rocm gui
popd
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Number of retries
MAX_RETRIES=5
# Try to build image
for ((i=1; i<=MAX_RETRIES; i++)); do
# Do not exit on error
set +e
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Capture exit code
STATUS=$?
# Exit on error
set -e
# Check if build succeeded
if [ $STATUS -eq 0 ]; then
echo "Build succeeded"
break
fi
# Print failure message and retry
echo "Build failed. Retry $i/$MAX_RETRIES"
# Remove build directory
rm -rf /_work
done
# Check if maximum retries were exhausted
if [ $STATUS -ne 0 ]; then
echo "Build failed after $MAX_RETRIES attempts"
exit 1
fi
- name: Create summary
run: |
Expand Down
37 changes: 35 additions & 2 deletions .github/workflows/sh-build-iso-rocm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,41 @@ jobs:
.ci/configure.py rocm normal
popd
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Number of retries
MAX_RETRIES=5
# Try to build image
for ((i=1; i<=MAX_RETRIES; i++)); do
# Do not exit on error
set +e
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
# Capture exit code
STATUS=$?
# Exit on error
set -e
# Check if build succeeded
if [ $STATUS -eq 0 ]; then
echo "Build succeeded"
break
fi
# Print failure message and retry
echo "Build failed. Retry $i/$MAX_RETRIES"
# Remove build directory
rm -rf /_work
done
# Check if maximum retries were exhausted
if [ $STATUS -ne 0 ]; then
echo "Build failed after $MAX_RETRIES attempts"
exit 1
fi
- name: Create summary
run: |
Expand Down

0 comments on commit 9c3c012

Please sign in to comment.