Skip to content

chore(ci): retry on failed test #1335

chore(ci): retry on failed test

chore(ci): retry on failed test #1335

Workflow file for this run

name: Run Unit Tests
on:
pull_request:
# Ensures that only a single workflow per PR will run at a time. Cancels in-progress jobs if new commit is pushed.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
# -short flag purposefully omitted because there are some longer unit tests
COMMAND: go test -race -timeout 10m -failfast -p 2 $(go list ./... | grep -v /cmd | grep -v /examples)
GO_VERSION: 1.21
jobs:
test-unit:
continue-on-error: true
name: unit-tests
runs-on: ubuntu-latest
steps:
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
# Install and setup go
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: checkout interchaintest
uses: actions/checkout@v4
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Download Go Dependencies
run: |
go mod tidy
go mod download
cd local-interchain && go mod tidy && go mod download
- name: run unit tests
id: run_test
run: ${{ env.COMMAND }}
- name: Retry Failed Test
if: steps.run_test.outcome == 'failure'
run: |
for i in 1 2; do
echo "Retry attempt $i"
if ${{ env.COMMAND }}; then
echo "Test passed on retry"
exit 0
fi
done
echo "Test failed after retries"
exit 1