Skip to content

Commit 44c00c1

Browse files
authored
Github push failure should not prevent rebasing and trying again (#252)
1 parent e55c467 commit 44c00c1

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

.github/workflows/apps-deps.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ jobs:
4848
- name: Update apps' package deps
4949
shell: Rscript {0}
5050
run: |
51+
# Resolves error of ` trying to use CRAN without setting a mirror`
52+
# https://github.com/r-lib/actions/blob/5e080d8d4241b4e7ed3834b113a6fa643d3f1351/setup-r/src/installer.ts#L600
53+
options(repos = c(CRAN="https://cran.rstudio.com/"))
5154
source("inst/gha/data-apps-deps-update.R")
5255
update_apps_deps()
5356

.github/workflows/apps-test-os.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,20 +273,25 @@ jobs:
273273
git add __test_results/
274274
git commit -m "Add test results for ${{steps.gha_branch.outputs.name}}"
275275
276-
# attempt to push until success. Allow for 15 attempts
276+
# Attempt to push until success. Allow for 15 attempts
277277
counter=0
278-
git pull origin _test_results
279-
until git push "https://$GITHUB_ACTOR:${{secrets.GITHUB_TOKEN}}@github.com/rstudio/shinycoreci.git" _test_results
280-
do
281-
# wait 5-15 seconds to avoid deadlock
282-
sleep $[ ($RANDOM % 10) + 5 ]s
278+
while true; do
279+
git pull --rebase origin _test_results
283280
284-
[[ counter -gt 15 ]] && echo "Too many attempts!" && exit 1
281+
# Capture push status and do not exit action
282+
PUSH_STATUS=0
283+
output=$(git push "https://$GITHUB_ACTOR:${{secrets.GITHUB_TOKEN}}@github.com/rstudio/shinycoreci.git" _test_results) && PUSH_STATUS=$? || PUSH_STATUS=$?
284+
285+
# If push was successful, exit loop
286+
if [ "$PUSH_STATUS" = 0 ]; then
287+
break; # break `while true` loop
288+
fi
289+
290+
# Wait 5-15 seconds to avoid deadlock
291+
sleep $[ ($RANDOM % 10) + 5 ]s
285292
((counter++))
293+
[[ counter -gt 15 ]] && echo "Too many attempts!" && exit 1
286294
echo "Push failed. Trying again. Try #$counter"
287-
288-
# pull again to have the latest
289-
git pull origin _test_results
290295
done
291296
292297
git checkout ${{ steps.current_branch.outputs.name }}

inst/apps/002-text/app.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ server <- function(input, output) {
6060

6161
}
6262

63+
6364
# Create Shiny app ----
6465
shinyApp(ui = ui, server = server)

0 commit comments

Comments
 (0)