Skip to content

Commit

Permalink
Github push failure should not prevent rebasing and trying again (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke authored Dec 4, 2023
1 parent e55c467 commit 44c00c1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/apps-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ jobs:
- name: Update apps' package deps
shell: Rscript {0}
run: |
# Resolves error of ` trying to use CRAN without setting a mirror`
# https://github.com/r-lib/actions/blob/5e080d8d4241b4e7ed3834b113a6fa643d3f1351/setup-r/src/installer.ts#L600
options(repos = c(CRAN="https://cran.rstudio.com/"))
source("inst/gha/data-apps-deps-update.R")
update_apps_deps()
Expand Down
25 changes: 15 additions & 10 deletions .github/workflows/apps-test-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,20 +273,25 @@ jobs:
git add __test_results/
git commit -m "Add test results for ${{steps.gha_branch.outputs.name}}"
# attempt to push until success. Allow for 15 attempts
# Attempt to push until success. Allow for 15 attempts
counter=0
git pull origin _test_results
until git push "https://$GITHUB_ACTOR:${{secrets.GITHUB_TOKEN}}@github.com/rstudio/shinycoreci.git" _test_results
do
# wait 5-15 seconds to avoid deadlock
sleep $[ ($RANDOM % 10) + 5 ]s
while true; do
git pull --rebase origin _test_results
[[ counter -gt 15 ]] && echo "Too many attempts!" && exit 1
# Capture push status and do not exit action
PUSH_STATUS=0
output=$(git push "https://$GITHUB_ACTOR:${{secrets.GITHUB_TOKEN}}@github.com/rstudio/shinycoreci.git" _test_results) && PUSH_STATUS=$? || PUSH_STATUS=$?
# If push was successful, exit loop
if [ "$PUSH_STATUS" = 0 ]; then
break; # break `while true` loop
fi
# Wait 5-15 seconds to avoid deadlock
sleep $[ ($RANDOM % 10) + 5 ]s
((counter++))
[[ counter -gt 15 ]] && echo "Too many attempts!" && exit 1
echo "Push failed. Trying again. Try #$counter"
# pull again to have the latest
git pull origin _test_results
done
git checkout ${{ steps.current_branch.outputs.name }}
Expand Down
1 change: 1 addition & 0 deletions inst/apps/002-text/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ server <- function(input, output) {

}


# Create Shiny app ----
shinyApp(ui = ui, server = server)

0 comments on commit 44c00c1

Please sign in to comment.