Skip to content

Commit e2cb74f

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Add automatic retry of failed workflows to improve E2E stability
Summary: This cdhanges are inspired by https://stackoverflow.com/a/78314483 and they should help with the stability of E2E tests on main. Most of the time, those tests fails because of flakyness in the E2E infrastructure on GHA. Usually, rerunning the tests manually makes the workflow pass. These couple of jobs automatically reruns the workflow up to 3 times in case one of the E2E tests fails ## Changelog: [Internal] - improve CI by rerunning the workflow if the E2E tests fails Differential Revision: D75449445
1 parent c62d952 commit e2cb74f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.github/workflows/retry-workflow.yml

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

.github/workflows/test-all.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,3 +632,15 @@ jobs:
632632
uses: ./.github/actions/lint
633633
with:
634634
github-token: ${{ env.GH_TOKEN }}
635+
636+
# This job reruns the e2e tests in case they failed. It should help with the E2E flakyness.
637+
# This is exactly the same as rerunning failed tests from the GH UI, but automated.
638+
rerun-failed-jobs:
639+
runs-on: ubuntu-latest
640+
needs: [test_e2e_ios_rntester, test_e2e_android_rntester,test_e2e_ios_templateapp, test_e2e_android_templateapp]
641+
if: failure() && ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests }} && fromJSON(github.run_attempt) < 3
642+
steps:
643+
- name: Rerun failed jobs in the current workflow
644+
env:
645+
GH_TOKEN: ${{ github.token }}
646+
run: gh workflow run retry-workflow.yml -F run_id=${{ github.run_id }}

0 commit comments

Comments
 (0)