Skip to content

Commit 8389630

Browse files
vbreussvbtig
andauthored
refactor: use retry action for failed tests (#349)
Use [retry action](https://github.com/marketplace/actions/retry-action) to retry a failed test step once in the build pipeline. Co-authored-by: Valentin Breuß <[email protected]>
1 parent e5a16b7 commit 8389630

File tree

3 files changed

+50
-12
lines changed

3 files changed

+50
-12
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ jobs:
7777
- name: Build solution
7878
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
7979
- name: Run tests
80-
run: dotnet test --no-build --collect:"XPlat Code Coverage"
80+
uses: Wandalen/[email protected]
81+
with:
82+
command: dotnet test --no-build --collect:"XPlat Code Coverage"
83+
attempt_limit: 2
8184
- name: Upload coverage
8285
uses: actions/upload-artifact@v3
8386
with:
@@ -101,7 +104,10 @@ jobs:
101104
- name: Build solution
102105
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
103106
- name: Run tests
104-
run: dotnet test --no-build --collect:"XPlat Code Coverage"
107+
uses: Wandalen/[email protected]
108+
with:
109+
command: dotnet test --no-build --collect:"XPlat Code Coverage"
110+
attempt_limit: 2
105111
- name: Upload coverage
106112
uses: actions/upload-artifact@v3
107113
with:
@@ -125,7 +131,10 @@ jobs:
125131
- name: Build solution
126132
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
127133
- name: Run tests
128-
run: dotnet test --no-build --collect:"XPlat Code Coverage"
134+
uses: Wandalen/[email protected]
135+
with:
136+
command: dotnet test --no-build --collect:"XPlat Code Coverage"
137+
attempt_limit: 2
129138
- name: Upload coverage
130139
uses: actions/upload-artifact@v3
131140
with:
@@ -176,7 +185,10 @@ jobs:
176185
- name: Build example solution
177186
run: dotnet build Examples /p:UseFileReferenceToTestablyLibraries=True
178187
- name: Run example tests
179-
run: dotnet test Examples --no-build
188+
uses: Wandalen/[email protected]
189+
with:
190+
command: dotnet test Examples --no-build
191+
attempt_limit: 2
180192

181193
upload-coverage:
182194
name: Upload coverage to Codacy

.github/workflows/ci.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ jobs:
2323
- name: Build solution
2424
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
2525
- name: Run tests
26-
run: dotnet test --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory "TestResults"
26+
uses: Wandalen/[email protected]
27+
with:
28+
command: dotnet test --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory "TestResults"
29+
attempt_limit: 2
2730
- name: Upload test results (MacOS)
2831
if: ${{ always() }}
2932
uses: actions/upload-artifact@v3
@@ -53,7 +56,10 @@ jobs:
5356
- name: Build solution
5457
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
5558
- name: Run tests
56-
run: dotnet test --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory "TestResults"
59+
uses: Wandalen/[email protected]
60+
with:
61+
command: dotnet test --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory "TestResults"
62+
attempt_limit: 2
5763
- name: Upload test results (Ubuntu)
5864
if: ${{ always() }}
5965
uses: actions/upload-artifact@v3
@@ -83,7 +89,10 @@ jobs:
8389
- name: Build solution
8490
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
8591
- name: Run tests
86-
run: dotnet test --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory "TestResults"
92+
uses: Wandalen/[email protected]
93+
with:
94+
command: dotnet test --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory "TestResults"
95+
attempt_limit: 2
8796
- name: Upload test results (Windows)
8897
if: ${{ always() }}
8998
uses: actions/upload-artifact@v3
@@ -130,8 +139,10 @@ jobs:
130139
with:
131140
fetch-depth: 0
132141
- name: Save PR number to file
142+
if: github.event_name == 'pull_request'
133143
run: echo ${{ github.event.number }} > PR_NUMBER.txt
134144
- name: Archive PR number
145+
if: github.event_name == 'pull_request'
135146
uses: actions/upload-artifact@v3
136147
with:
137148
name: PR_NUMBER
@@ -147,4 +158,7 @@ jobs:
147158
- name: Build example solution
148159
run: dotnet build Examples /p:UseFileReferenceToTestablyLibraries=True
149160
- name: Run example tests
150-
run: dotnet test Examples --no-build
161+
uses: Wandalen/[email protected]
162+
with:
163+
command: dotnet test Examples --no-build
164+
attempt_limit: 2

.github/workflows/release.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ jobs:
8888
- name: Build solution
8989
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
9090
- name: Run tests
91-
run: dotnet test --no-build
91+
uses: Wandalen/[email protected]
92+
with:
93+
command: dotnet test --no-build
94+
attempt_limit: 2
9295

9396
test-ubuntu:
9497
name: Test (Ubuntu)
@@ -112,7 +115,10 @@ jobs:
112115
- name: Build solution
113116
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
114117
- name: Run tests
115-
run: dotnet test --no-build
118+
uses: Wandalen/[email protected]
119+
with:
120+
command: dotnet test --no-build
121+
attempt_limit: 2
116122

117123
test-windows:
118124
name: Test (Windows)
@@ -136,7 +142,10 @@ jobs:
136142
- name: Build solution
137143
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
138144
- name: Run tests
139-
run: dotnet test --no-build
145+
uses: Wandalen/[email protected]
146+
with:
147+
command: dotnet test --no-build
148+
attempt_limit: 2
140149

141150
test-net-framework:
142151
name: Test (.NET Framework)
@@ -186,7 +195,10 @@ jobs:
186195
- name: Build example solution
187196
run: dotnet build Examples /p:UseFileReferenceToTestablyLibraries=True --configuration "Release"
188197
- name: Run example tests
189-
run: dotnet test Examples --no-build
198+
uses: Wandalen/[email protected]
199+
with:
200+
command: dotnet test Examples --no-build
201+
attempt_limit: 2
190202

191203
stryker-ubuntu:
192204
name: Analyze quality of unit test coverage with .NET Stryker (Ubuntu)

0 commit comments

Comments
 (0)