Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9f729c7

Browse files
authoredFeb 8, 2024
feat: auto-retry commands twice and improve support for multiline programs (#517)
1 parent 53d5824 commit 9f729c7

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed
 

‎.github/workflows/test.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ jobs:
5353
- uses: ./action
5454
with:
5555
build-command: ./gradlew tasks
56-
check-command: true
56+
check-command: |
57+
for x in 1 2 3; do
58+
echo $x
59+
done
5760
working-directory: target
5861
should-run-codecov: false
5962
clean-command: ./gradlew clean

‎action.yml

+22-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ inputs:
2323
required: false
2424
retries-on-failure:
2525
description: 'How many times every command should be retried before giving up'
26-
default: '1'
26+
default: '2'
2727
required: false
2828
wait-between-retries:
2929
description: 'How many seconds to wait after a step failure before attempting a new run'
@@ -152,14 +152,20 @@ runs:
152152
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
153153
restore-keys: |
154154
${{ runner.os }}-gradle-
155+
- name: Compute the heredoc id
156+
id: hd-id
157+
shell: bash
158+
run: echo heredoc=${{ github.sha }} >> $GITHUB_OUTPUT
155159
- name: Pre-build
156160
working-directory: ${{ inputs.working-directory }}
157161
shell: bash
158162
run: |
159-
echo "::group::Pre-build"
160-
COMMAND='${{ inputs.pre-build-command }}'
163+
echo "::group::Pre-Build"
161164
for attempt in $(seq 1 "${{ inputs.retries-on-failure}}"); do
162-
$(echo $COMMAND) && break || sleep "${{ inputs.wait-between-retries }}"
165+
echo "Attempt $attempt/${{ inputs.retries-on-failure }}"
166+
{
167+
${{ inputs.pre-build-command }}
168+
} && break || sleep "${{ inputs.wait-between-retries }}"
163169
done
164170
echo "::endgroup::"
165171
- name: Build
@@ -169,17 +175,22 @@ runs:
169175
echo "::group::Build"
170176
COMMAND='${{ inputs.build-command }}'
171177
for attempt in $(seq 1 "${{ inputs.retries-on-failure}}"); do
172-
$(echo $COMMAND) && break || sleep "${{ inputs.wait-between-retries }}"
178+
echo "Attempt $attempt/${{ inputs.retries-on-failure }}"
179+
{
180+
${{ inputs.build-command }}
181+
} && break || sleep "${{ inputs.wait-between-retries }}"
173182
done
174183
echo "::endgroup::"
175184
- name: Check
176185
shell: bash
177186
working-directory: ${{ inputs.working-directory }}
178187
run: |
179188
echo "::group::Check"
180-
COMMAND='${{ inputs.check-command }}'
181189
for attempt in $(seq 1 "${{ inputs.retries-on-failure}}"); do
182-
$(echo $COMMAND) && break || sleep "${{ inputs.wait-between-retries }}"
190+
echo "Attempt $attempt/${{ inputs.retries-on-failure }}"
191+
{
192+
${{ inputs.check-command }}
193+
} && break || sleep "${{ inputs.wait-between-retries }}"
183194
done
184195
echo "::endgroup::"
185196
- name: CodeCov
@@ -216,9 +227,11 @@ runs:
216227
ORG_GRADLE_PROJECT_npmToken: ${{ inputs.npm-token }}
217228
run: |
218229
echo "::group::Deploy"
219-
COMMAND='${{ inputs.deploy-command }}'
220230
for attempt in $(seq 1 "${{ inputs.retries-on-failure}}"); do
221-
$(echo $COMMAND) && break || sleep "${{ inputs.wait-between-retries }}"
231+
echo "Attempt $attempt/${{ inputs.retries-on-failure }}"
232+
{
233+
${{ inputs.deploy-command }}
234+
} && break || sleep "${{ inputs.wait-between-retries }}"
222235
done
223236
echo "::endgroup::"
224237
- name: Cleanup

0 commit comments

Comments
 (0)
Please sign in to comment.