Skip to content

Commit c14f903

Browse files
authored
Retry cargo test when failed in CI. (#44)
1 parent 847af8a commit c14f903

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

.github/workflows/rust.yml

+31-2
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,47 @@ jobs:
143143
command: build
144144
args: --release --workspace
145145

146+
- name: Composer install
147+
run: composer install --working-dir=tests/php
148+
149+
# Build mixture for cargo test.
146150
- name: Docker compose
147151
if: matrix.os == 'ubuntu-20.04'
148152
run: docker compose up -d
149153

154+
# Build mixture for cargo test.
150155
- name: Vagrant up for docker compose
151156
if: matrix.os == 'macos-12'
152157
run: vagrant up
153158

154-
- name: Composer install
155-
run: composer install --working-dir=tests/php
159+
# Try cargo test.
160+
- name: Cargo test
161+
id: cargo-test-step
162+
uses: actions-rs/cargo@v1
163+
with:
164+
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}
165+
command: test
166+
args: --release --workspace
167+
continue-on-error: true
168+
169+
# Rebuild the mixture when cargo test failed.
170+
- name: Docker compose restart
171+
if: matrix.os == 'ubuntu-20.04' && steps.cargo-test-step.outcome != 'success'
172+
run: docker compose restart
173+
174+
# Rebuild the mixture when cargo test failed.
175+
- name: Vagrant reload for docker compose
176+
if: matrix.os == 'macos-12' && steps.cargo-test-step.outcome != 'success'
177+
run: vagrant reload
178+
179+
# Delay before retry.
180+
- name: Delay
181+
if: steps.cargo-test-step.outcome != 'success'
182+
run: sleep 20
156183

184+
# Retry cargo test.
157185
- name: Cargo test
186+
if: steps.cargo-test-step.outcome != 'success'
158187
uses: actions-rs/cargo@v1
159188
with:
160189
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}

0 commit comments

Comments
 (0)