Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
154 lines
5.6 KiB
YAML
154 lines
5.6 KiB
YAML
name: retry-tests
|
|
|
|
on:
|
|
workflow_run:
|
|
# Make sure that required_job_conclusion knows what the name of the required
|
|
# job is in each workflow.
|
|
workflows: ['build-and-test', 'build-and-deploy']
|
|
branches: [canary]
|
|
types:
|
|
- completed
|
|
|
|
env:
|
|
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_CANARY_SLACK_WEBHOOK_URL }}
|
|
|
|
permissions:
|
|
actions: write
|
|
|
|
jobs:
|
|
retry-on-failure:
|
|
name: retry failed jobs
|
|
# Retry the build-and-test workflow up to 2 times
|
|
if: >-
|
|
${{
|
|
github.event.workflow_run.conclusion == 'failure' &&
|
|
github.repository == 'vercel/next.js' &&
|
|
github.event.workflow_run.run_attempt < 3
|
|
}}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check conclusion of required job
|
|
id: required_job_conclusion
|
|
uses: actions/github-script@v7
|
|
continue-on-error: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
script: |
|
|
// See build-and-test.yml and build-and-deploy.yml for the required job names
|
|
const requiredJobName = {
|
|
'build-and-test': 'thank you, next',
|
|
'build-and-deploy': 'thank you, build',
|
|
}[context.payload.workflow_run.name]
|
|
|
|
async function rerunIfRequiredNotSuccessful() {
|
|
const result = await github.paginate.iterator(
|
|
'GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs',
|
|
{
|
|
attempt_number: context.payload.workflow_run.run_attempt,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
run_id: context.payload.workflow_run.id,
|
|
}
|
|
)
|
|
|
|
for await (const { data: jobs } of result) {
|
|
for (const job of jobs) {
|
|
if (job.name === requiredJobName) {
|
|
console.log(
|
|
"Using conclusion '%s' from %s",
|
|
job.conclusion,
|
|
job.html_url
|
|
)
|
|
return job.conclusion
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log("Couldn't find job with name '%s'", requiredJobName)
|
|
return null
|
|
}
|
|
|
|
return await rerunIfRequiredNotSuccessful()
|
|
- name: send retry request to GitHub API
|
|
if: ${{ steps.required_job_conclusion.outputs.result != '"success"' }}
|
|
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 build-and-test workflow has failed 3 times
|
|
# build-and-deploy is not retried so we always report it
|
|
if: >-
|
|
${{
|
|
github.event.workflow_run.conclusion == 'failure' &&
|
|
github.event.workflow_run.run_attempt >= 3 &&
|
|
!github.event.workflow_run.head_repository.fork
|
|
}}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check conclusion of required job
|
|
id: required_job_conclusion
|
|
uses: actions/github-script@v7
|
|
continue-on-error: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
script: |
|
|
// See build-and-test.yml and build-and-deploy.yml for the required job names
|
|
const requiredJobName = {
|
|
'build-and-test': 'thank you, next',
|
|
'build-and-deploy': 'thank you, build',
|
|
}[context.payload.workflow_run.name]
|
|
|
|
async function rerunIfRequiredNotSuccessful() {
|
|
const result = await github.paginate.iterator(
|
|
'GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs',
|
|
{
|
|
attempt_number: context.payload.workflow_run.run_attempt,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
run_id: context.payload.workflow_run.id,
|
|
}
|
|
)
|
|
|
|
for await (const { data: jobs } of result) {
|
|
for (const job of jobs) {
|
|
if (job.name === requiredJobName) {
|
|
console.log(
|
|
"Using conclusion '%s' from %s",
|
|
job.conclusion,
|
|
job.html_url
|
|
)
|
|
return job.conclusion
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log("Couldn't find job with name '%s'", requiredJobName)
|
|
return null
|
|
}
|
|
|
|
return await rerunIfRequiredNotSuccessful()
|
|
- name: send webhook
|
|
if: ${{ steps.required_job_conclusion.outputs.result != '"success"' }}
|
|
uses: slackapi/slack-github-action@v1.25.0
|
|
with:
|
|
# These urls are intentionally missing the protocol,
|
|
# allowing them to be transformed into actual links in the Slack workflow
|
|
# (through slightly hacky means).
|
|
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 }}
|