Skip to content

Commit

Permalink
Retry cargo test when failed in CI. (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmjoy committed Jan 13, 2023
1 parent 847af8a commit c14f903
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,47 @@ jobs:
command: build
args: --release --workspace

- name: Composer install
run: composer install --working-dir=tests/php

# Build mixture for cargo test.
- name: Docker compose
if: matrix.os == 'ubuntu-20.04'
run: docker compose up -d

# Build mixture for cargo test.
- name: Vagrant up for docker compose
if: matrix.os == 'macos-12'
run: vagrant up

- name: Composer install
run: composer install --working-dir=tests/php
# Try cargo test.
- name: Cargo test
id: cargo-test-step
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}
command: test
args: --release --workspace
continue-on-error: true

# Rebuild the mixture when cargo test failed.
- name: Docker compose restart
if: matrix.os == 'ubuntu-20.04' && steps.cargo-test-step.outcome != 'success'
run: docker compose restart

# Rebuild the mixture when cargo test failed.
- name: Vagrant reload for docker compose
if: matrix.os == 'macos-12' && steps.cargo-test-step.outcome != 'success'
run: vagrant reload

# Delay before retry.
- name: Delay
if: steps.cargo-test-step.outcome != 'success'
run: sleep 20

# Retry cargo test.
- name: Cargo test
if: steps.cargo-test-step.outcome != 'success'
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}
Expand Down

0 comments on commit c14f903

Please sign in to comment.