From 748439f055bbfc46078903b56be97398d1e3d44a Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Wed, 6 May 2020 23:20:21 +0200 Subject: [PATCH] add retry command for packaging, since linux screenshare has about a 50% chance to fail a build --- .github/workflows/pr_build.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index f5104dbe43..4b3d66da50 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -120,7 +120,30 @@ jobs: - name: Build Installer working-directory: ${{runner.workspace}}/build shell: bash - run: cmake --build . --config $BUILD_TYPE --target package $CMAKE_BUILD_EXTRA + run: | + echo "Retry code from https://unix.stackexchange.com/a/137639" + function fail { + echo $1 >&2 + exit 1 + } + + function retry { + local n=1 + local max=5 + local delay=15 + while true; do + "$@" && break || { + if [[ $n -lt $max ]]; then + ((n++)) + echo "Command failed. Attempt $n/$max:" + sleep $delay; + else + fail "The command has failed after $n attempts." + fi + } + done + } + retry cmake --build . --config $BUILD_TYPE --target package $CMAKE_BUILD_EXTRA - name: Output system stats if: ${{ always() }} working-directory: ${{runner.workspace}}/build