Skip to content

Commit

Permalink
split CI retry workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed Jun 14, 2024
1 parent 1e06340 commit d906f55
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 32 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/retry_deploy_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: retry-tests

on:
workflow_run:
workflows: ['test-e2e-deploy-release']
types:
- completed

env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_DEPLOY_SLACK_WEBHOOK_URL }}

permissions:
actions: write

jobs:
retry-on-failure:
name: retry failed jobs
# Retry the test-e2e-deploy-release workflow up to 2 times
if: >-
${{
github.event.workflow_run.conclusion == 'failure' &&
github.repository == 'vercel/next.js' &&
github.event.workflow_run.run_attempt < 2
}}
runs-on: ubuntu-latest
steps:
- name: send retry request to GitHub API
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/rerun-failed-jobs
report-failure:
name: report failure to slack
# Report the failure to Slack if the test-e2e-deploy-release workflow has failed 2 times
if: >-
${{
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.run_attempt >= 2 &&
!github.event.workflow_run.head_repository.fork
}}
runs-on: ubuntu-latest
steps:
- name: send webhook
uses: slackapi/slack-github-action@v1.25.0
with:
payload: |
{
"commit_title": ${{ toJSON(github.event.workflow_run.display_title) }},
"commit_url": "github.com/${{ github.repository }}/commit/${{ github.event.workflow_run.head_sha }}",
"workflow_run_url": "github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/attempts/${{ github.event.workflow_run.run_attempt }}"
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}
35 changes: 3 additions & 32 deletions .github/workflows/retry_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,26 @@ name: retry-tests

on:
workflow_run:
workflows: ['build-and-test', 'test-e2e-deploy-release']
workflows: ['build-and-test']
branches: [canary]
types:
- completed

env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_CANARY_SLACK_WEBHOOK_URL }}
SLACK_DEPLOY_TEST_WEBHOOK_URL: ${{ secrets.BROKEN_DEPLOY_SLACK_WEBHOOK_URL }}

permissions:
actions: write

jobs:
retry-on-failure:
name: retry failed jobs
# Retry the build-and-test workflow up to 3 times and the test-e2e-deploy-release workflow up to 2 times.
# Retry the build-and-test workflow up to 3 times
if: >-
${{
github.event.workflow_run.conclusion == 'failure' &&
github.repository == 'vercel/next.js' &&
(
(github.event.workflow_run.name == 'build-and-test' && github.event.workflow_run.run_attempt < 3) ||
(github.event.workflow_run.name == 'test-e2e-deploy-release' && github.event.workflow_run.run_attempt < 2)
)
github.event.workflow_run.run_attempt < 3)
}}
runs-on: ubuntu-latest
steps:
Expand All @@ -44,7 +40,6 @@ jobs:
# Report the failure to Slack if the build-and-test workflow has failed 3 times
if: >-
${{
github.event.workflow_run.name == 'build-and-test' &&
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.run_attempt >= 3 &&
!github.event.workflow_run.head_repository.fork
Expand All @@ -65,27 +60,3 @@ jobs:
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}

report-deploy-test-failure:
name: report failure to slack
# Report the failure to Slack if the test-e2e-deploy-release workflow has failed 2 times
if: >-
${{
github.event.workflow_run.name == 'test-e2e-deploy-release' &&
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.run_attempt >= 2 &&
!github.event.workflow_run.head_repository.fork
}}
runs-on: ubuntu-latest
steps:
- name: send webhook
uses: slackapi/slack-github-action@v1.25.0
with:
payload: |
{
"commit_title": ${{ toJSON(github.event.workflow_run.display_title) }},
"commit_url": "github.com/${{ github.repository }}/commit/${{ github.event.workflow_run.head_sha }}",
"workflow_run_url": "github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/attempts/${{ github.event.workflow_run.run_attempt }}"
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_DEPLOY_TEST_WEBHOOK_URL }}

0 comments on commit d906f55

Please sign in to comment.