Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit cd29953

Browse files
authored
Merge pull request #22 from aiming/fix-disable-retry
リトライが正常に働かなかった現象の修正
2 parents c0dac25 + 34ebb8c commit cd29953

3 files changed

Lines changed: 45 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,45 @@ jobs:
110110
- name: Check .gitconfig
111111
run: |
112112
cat ~/.gitconfig
113+
114+
- name: Test do not retry if command successfull
115+
run: |
116+
source try.sh
117+
118+
before=$(date +%s)
119+
try_till_success ls
120+
after=$(date +%s)
121+
122+
# コマンド呼び出しに時間がかかっているかでリトライ判定をしています
123+
if [ $(($after - $before)) -gt 1 ]; then
124+
echo "::error:: 成功時にもリトライしています after = ${after}, before = ${before}"
125+
exit 1
126+
fi
127+
128+
- name: Test do retry if command failure
129+
shell: bash +e -x {0}
130+
run: |
131+
source try.sh
132+
133+
before=$(date +%s)
134+
try_till_success false
135+
after=$(date +%s)
136+
137+
# コマンド呼び出しに時間がかかっているかでリトライ判定をしています
138+
if [ $(expr $after - $before) -lt 2 ]; then
139+
echo "::error:: 失敗時にリトライしていません after = ${after}, before = ${before}"
140+
exit 1
141+
fi
142+
143+
- name: Setup github.com connection
144+
continue-on-error: true
145+
run: |
146+
# disable connect to github.com
147+
echo '127.0.0.1 github.com' | sudo tee -a /etc/hosts
148+
149+
- name: Test retry checkout
150+
continue-on-error: true
151+
uses: ./
152+
with:
153+
depth: ''
154+
checkout_dir: step7

action.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ runs:
4040
- shell: bash
4141
if: ${{ !env.ACT }}
4242
run: |
43-
set -x
44-
4543
echo $GITHUB_ACTION_PATH
4644
source $GITHUB_ACTION_PATH/try.sh
4745

try.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ function try_till_success {
1616

1717
while [[ $attempt < $max_attempts ]]
1818
do
19+
oldopt=$-
20+
set +e
1921
"$@"
2022
exitCode=$?
23+
set -$oldopt
2124

2225
if [[ $exitCode == 0 ]]
2326
then

0 commit comments

Comments
 (0)