From 20943dadb2b7edf91bee19481ede14a96d25f7dd Mon Sep 17 00:00:00 2001 From: Junichiro Kasuya Date: Fri, 18 Aug 2023 14:32:03 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=97=E6=99=82=E3=81=AB=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=82=92=E7=84=A1=E8=A6=96=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=81=9F=E3=82=81+e=E3=82=92=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 42 ++++++++++++++++++++++++++++++++++++++ action.yml | 2 -- try.sh | 3 +++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6a76309..1ff8a66 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -110,3 +110,45 @@ jobs: - name: Check .gitconfig run: | cat ~/.gitconfig + + - name: Test do not retry if command successfull + run: | + source try.sh + + before=$(date +%s) + try_till_success ls + after=$(date +%s) + + # コマンド呼び出しに時間がかかっているかでリトライ判定をしています + if [ $(expr $after - $before) -gt 1 ]; then + echo "::error:: 成功時にもリトライしています after = ${after}, before = ${before}" + exit 1 + fi + + - name: Test do retry if command failure + shell: bash +e -x {0} + run: | + source try.sh + + before=$(date +%s) + try_till_success false + after=$(date +%s) + + # コマンド呼び出しに時間がかかっているかでリトライ判定をしています + if [ $(expr $after - $before) -lt 2 ]; then + echo "::error:: 失敗時にリトライしていません after = ${after}, before = ${before}" + exit 1 + fi + + - name: Setup github.com connection + continue-on-error: true + run: | + # disable connect to github.com + echo '127.0.0.1 github.com' | sudo tee -a /etc/hosts + + - name: Test retry checkout + continue-on-error: true + uses: ./ + with: + depth: '' + checkout_dir: step7 diff --git a/action.yml b/action.yml index 458c1ca..1ae7207 100644 --- a/action.yml +++ b/action.yml @@ -40,8 +40,6 @@ runs: - shell: bash if: ${{ !env.ACT }} run: | - set -x - echo $GITHUB_ACTION_PATH source $GITHUB_ACTION_PATH/try.sh diff --git a/try.sh b/try.sh index f54c9ca..dac4c63 100644 --- a/try.sh +++ b/try.sh @@ -16,8 +16,11 @@ function try_till_success { while [[ $attempt < $max_attempts ]] do + oldopt=$- + set +e "$@" exitCode=$? + set -$oldopt if [[ $exitCode == 0 ]] then From 34ebb8ccb5a0c2540c2f8c12242cda04fc37e967 Mon Sep 17 00:00:00 2001 From: Junichiro Kasuya <108387548+jkasuya-aim@users.noreply.github.com> Date: Fri, 18 Aug 2023 15:19:20 +0900 Subject: [PATCH 2/2] Update .github/workflows/test.yml Co-authored-by: takesato --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ff8a66..1a6993e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -120,7 +120,7 @@ jobs: after=$(date +%s) # コマンド呼び出しに時間がかかっているかでリトライ判定をしています - if [ $(expr $after - $before) -gt 1 ]; then + if [ $(($after - $before)) -gt 1 ]; then echo "::error:: 成功時にもリトライしています after = ${after}, before = ${before}" exit 1 fi