Skip to content

Commit df851ff

Browse files
authored
feat: Added retry mechanism for test stage (#114)
* feat: Added retry mechanism for `test` stage * chore: Default only one attempt
1 parent b28cac9 commit df851ff

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

.github/workflows/cicd-dotnet.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ on:
4848
solution:
4949
required: true
5050
type: string
51+
retry-max-attempts:
52+
required: false
53+
type: number
54+
default: 1
55+
retry-timeout:
56+
required: false
57+
type: number
58+
default: 15
5159
secrets:
5260
FETCH_TOKEN:
5361
required: false
@@ -118,6 +126,8 @@ jobs:
118126
runs-on: ${{ inputs.runs-on-tests || inputs.runs-on-build || 'ubuntu-latest' }}
119127
solution: ${{ inputs.solution }}
120128
solution-version: ${{ needs.version.outputs.solution-version }}
129+
retry-max-attempts: ${{ inputs.retry-max-attempts || 3 }}
130+
retry-timeout: ${{ inputs.retry-timeout || 15 }}
121131
secrets: inherit
122132

123133
build:

.github/workflows/step-dotnet-tests.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ on:
3535
solution-version:
3636
required: true
3737
type: string
38+
retry-max-attempts:
39+
required: false
40+
type: number
41+
default: 3
42+
retry-timeout:
43+
required: false
44+
type: number
45+
default: 15
3846
secrets:
3947
CODECOV_TOKEN:
4048
required: false
@@ -113,10 +121,15 @@ jobs:
113121
- name: Build
114122
run: dotnet build ${{ inputs.solution }} -c Release -v ${{ inputs.dotnet-logging || 'quiet' }} --no-restore /p:GeneratePackageOnBuild=false
115123

116-
- name: Test
124+
- name: Retry Step
117125
id: test
118-
run: |
119-
dotnet test ${{ inputs.solution }} -c Release -v ${{ inputs.dotnet-logging }} --no-build --no-restore --collect:"XPlat Code Coverage;Format=cobertura,opencover" /p:GeneratePackageOnBuild=false -- --coverage --coverage-output-format cobertura
126+
uses: nick-fields/retry@v3.0.0
127+
with:
128+
timeout_minutes: ${{ inputs.retry-timeout || 15 }}
129+
max_attempts: ${{ inputs.retry-max-attempts || 1 }}
130+
shell: pwsh
131+
command: |
132+
dotnet test ${{ inputs.solution }} -c Release -v ${{ inputs.dotnet-logging }} --no-build --no-restore --collect:"XPlat Code Coverage;Format=cobertura,opencover" /p:GeneratePackageOnBuild=false -- --coverage --coverage-output-format cobertura
120133
121134
- name: Stop SonarQube Analysis
122135
if: ${{ inputs.enableSonarQube == true && (success() || steps.test.conclusion == 'failure') }}

0 commit comments

Comments
 (0)