Skip to content

Commit a5985a3

Browse files
Vivek Miglanifacebook-github-bot
authored andcommitted
Add auto retries for Captum OSS GitHub Actions (#1408)
Summary: We frequently see sporadic failures in Captum GitHub actions test workflows, often related to package download, http errors, conda environment setup, etc. We add auto-retries to automatically retry failed workflows rather than needing to do this manually. Differential Revision: D64693773
1 parent ed5daa3 commit a5985a3

File tree

5 files changed

+85
-6
lines changed

5 files changed

+85
-6
lines changed

.github/workflows/retry.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Retry Test
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
run_id:
6+
required: true
7+
jobs:
8+
rerun-on-failure:
9+
permissions: write-all
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: rerun ${{ inputs.run_id }}
13+
env:
14+
GH_REPO: ${{ github.repository }}
15+
GH_TOKEN: ${{ github.token }}
16+
GH_DEBUG: api
17+
run: |
18+
gh run watch ${{ inputs.run_id }} > /dev/null 2>&1
19+
gh run rerun ${{ inputs.run_id }} --failed

.github/workflows/test-conda-cpu.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name: Unit-tests for Conda install
22

33
on:
4-
pull_request:
5-
push:
6-
branches:
7-
- master
4+
pull_request:
5+
push:
6+
branches:
7+
- master
88

9-
workflow_dispatch:
9+
workflow_dispatch:
1010

1111
env:
12-
CHANNEL: "nightly"
12+
CHANNEL: "nightly"
1313

1414
jobs:
1515
tests:
@@ -32,3 +32,18 @@ jobs:
3232
3333
# Run Tests
3434
python3 -m pytest -ra --cov=. --cov-report term-missing
35+
36+
auto-retry:
37+
name: Auto retry on failure
38+
needs: tests
39+
if: failure() && fromJSON(github.run_attempt) < 2
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Start rerun workflow
43+
env:
44+
GH_REPO: ${{ github.repository }}
45+
GH_TOKEN: ${{ github.token }}
46+
GH_DEBUG: api
47+
run: |
48+
gh workflow run retry.yml \
49+
-F run_id=${{ github.run_id }}

.github/workflows/test-pip-cpu-with-mypy.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,18 @@ jobs:
2525
./scripts/run_mypy.sh
2626
# Run Tests
2727
python3 -m pytest -ra --cov=. --cov-report term-missing
28+
29+
auto-retry:
30+
name: Auto retry on failure
31+
needs: tests
32+
if: failure() && fromJSON(github.run_attempt) < 2
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Start rerun workflow
36+
env:
37+
GH_REPO: ${{ github.repository }}
38+
GH_TOKEN: ${{ github.token }}
39+
GH_DEBUG: api
40+
run: |
41+
gh workflow run retry.yml \
42+
-F run_id=${{ github.run_id }}

.github/workflows/test-pip-cpu.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,18 @@ jobs:
3535
./scripts/install_via_pip.sh ${{ matrix.pytorch_args }} ${{ matrix.transformers_args }}
3636
# Run Tests
3737
python3 -m pytest -ra --cov=. --cov-report term-missing
38+
39+
auto-retry:
40+
name: Auto retry on failure
41+
needs: tests
42+
if: failure() && fromJSON(github.run_attempt) < 2
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Start rerun workflow
46+
env:
47+
GH_REPO: ${{ github.repository }}
48+
GH_TOKEN: ${{ github.token }}
49+
GH_DEBUG: api
50+
run: |
51+
gh workflow run retry.yml \
52+
-F run_id=${{ github.run_id }}

.github/workflows/test-pip-gpu.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,18 @@ jobs:
3030
3131
# Run Tests
3232
python3 -m pytest -ra --cov=. --cov-report term-missing
33+
34+
auto-retry:
35+
name: Auto retry on failure
36+
needs: tests
37+
if: failure() && fromJSON(github.run_attempt) < 2
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Start rerun workflow
41+
env:
42+
GH_REPO: ${{ github.repository }}
43+
GH_TOKEN: ${{ github.token }}
44+
GH_DEBUG: api
45+
run: |
46+
gh workflow run retry.yml \
47+
-F run_id=${{ github.run_id }}

0 commit comments

Comments
 (0)