Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: deploy tests fixes #69621

Draft
wants to merge 19 commits into
base: 14-2-1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
65dc140
fix e2e deployment test action (#66721)
ztanner Jun 11, 2024
056de98
tweak deploy failure notification condition (#66769)
ztanner Jun 11, 2024
4b3f043
tweak deploy test concurrency & fail condition (#66779)
ztanner Jun 12, 2024
10fceec
convert a bunch of tests to nextTestSetup
lubieowoce Sep 3, 2024
52512a7
disable deploy tests for incompatible suites (#66776)
ztanner Jun 12, 2024
4ca3246
re-add test output string in run-tests (#66828)
ztanner Jun 13, 2024
f886817
tweak deploy test jobs (#66856)
ztanner Jun 14, 2024
79a25af
split CI retry workflows (#66888)
ztanner Jun 14, 2024
601d2ef
Persist package tarballs as GitHub Actions artifacts (#66445)
eps1lon Jul 2, 2024
717e70d
ci: disable uploading results to datadog on non-canary branches
lubieowoce Sep 3, 2024
7869b61
pass NEXT_TEST_VERSION corresponding to the commit hash to deploy tests
lubieowoce Sep 3, 2024
f9ce4d1
ci: only trigger slack webhook from canary
lubieowoce Sep 3, 2024
a563bf8
ci: try overriding the next swc version for deploy tests
lubieowoce Sep 3, 2024
5cd4f9d
chore: add logs to download-swc ci job (#69425)
huozhi Aug 28, 2024
f0f84fb
fix retrieval of deploy test build logs (#67971)
ztanner Jul 19, 2024
b8d566a
capture test-deploy stderr in cliOutput (#67976)
ztanner Jul 19, 2024
17e1c13
explicitly pass test mode to jest task
ztanner Sep 3, 2024
4a1976b
ensure e2e tests workflow doesnt skip postinstall
ztanner Sep 4, 2024
0818dbb
ci: make inputs.skipNativeInstall do what it says (#69674)
lubieowoce Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 71 additions & 24 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Update all mentions of this name in vercel-packages when changing.
name: build-and-deploy

on:
push:
branches: ['canary', '14-2-1']
# TODO: Run only on canary pushes but PR syncs.
# Requires checking if CI is approved
workflow_dispatch:

env:
Expand All @@ -14,15 +16,48 @@ env:
TURBO_REMOTE_ONLY: 'true'

jobs:
deploy-target:
runs-on: ubuntu-latest
outputs:
value: ${{ steps.deploy-target.outputs.value }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true
- run: corepack enable
- name: Determine deploy target
# 'force-preview' performs a full preview build but only if acknowledged i.e. workflow_dispatch
# 'automated-preview' for pushes on branches other than 'canary' for integration testing.
# 'staging' for canary branch since that will eventually be published i.e. become the production build.
id: deploy-target
run: |
if [[ $(node ./scripts/check-is-release.js 2> /dev/null || :) = v* ]];
then
echo "value=production" >> $GITHUB_OUTPUT
elif [ '${{ github.ref }}' == 'refs/heads/canary' ]
then
echo "value=staging" >> $GITHUB_OUTPUT
elif [ '${{ github.event_name }}' == 'workflow_dispatch' ]
then
echo "value=force-preview" >> $GITHUB_OUTPUT
else
echo "value=automated-preview" >> $GITHUB_OUTPUT
fi
- name: Print deploy target
run: echo "Deploy target is '${{ steps.deploy-target.outputs.value }}'"

build:
runs-on: ubuntu-latest
env:
NEXT_TELEMETRY_DISABLED: 1
# we build a dev binary for use in CI so skip downloading
# canary next-swc binaries in the monorepo
NEXT_SKIP_NATIVE_POSTINSTALL: 1
outputs:
isRelease: ${{ github.event_name != 'workflow_dispatch' && steps.check-release.outputs.IS_RELEASE }}
steps:
- name: Setup node
uses: actions/setup-node@v4
Expand Down Expand Up @@ -52,15 +87,6 @@ jobs:

- run: pnpm run build

- id: check-release
run: |
if [[ $(node ./scripts/check-is-release.js 2> /dev/null || :) = v* ]];
then
echo "IS_RELEASE=true" >> $GITHUB_OUTPUT
else
echo "IS_RELEASE=false" >> $GITHUB_OUTPUT
fi

- uses: actions/cache@v4
timeout-minutes: 5
id: cache-build
Expand All @@ -70,13 +96,26 @@ jobs:

# Build binaries for publishing
build-native:
needs:
- deploy-target
defaults:
run:
shell: bash -leo pipefail {0}

strategy:
fail-fast: false
matrix:
exclude:
# Exclude slow builds for automated previews
# These are rarely needed for the standard preview usage (e.g. Front sync)
- settings:
target: ${{ needs.deploy-target.outputs.value == 'automated-preview' && 'i686-pc-windows-msvc' }}
- settings:
target: ${{ needs.deploy-target.outputs.value == 'automated-preview' && 'x86_64-pc-windows-msvc' }}
- settings:
target: ${{ needs.deploy-target.outputs.value == 'automated-preview' && 'aarch64-unknown-linux-musl' }}
- settings:
target: ${{ needs.deploy-target.outputs.value == 'automated-preview' && 'x86_64-unknown-linux-musl' }}
settings:
- host:
- 'self-hosted'
Expand Down Expand Up @@ -396,16 +435,14 @@ jobs:
path: packages/next-swc/crates/wasm/pkg-*

deployTarball:
if: ${{ needs.build.outputs.isRelease != 'true' }}
name: Deploy tarball
if: ${{ needs.deploy-target.outputs.value != 'production' }}
name: Deploy preview tarball
runs-on: ubuntu-latest
needs:
- deploy-target
- build
- build-wasm
- build-native
env:
VERCEL_TEST_TOKEN: ${{ secrets.VERCEL_TEST_TOKEN }}
VERCEL_TEST_TEAM: vtest314-next-e2e-tests
steps:
- name: Setup node
uses: actions/setup-node@v4
Expand Down Expand Up @@ -437,15 +474,22 @@ jobs:
merge-multiple: true
path: packages/next-swc/crates/wasm

- run: npm i -g vercel@latest
- name: Create tarballs
run: node scripts/create-preview-tarballs.js "${{ github.sha }}" "${{ runner.temp }}/preview-tarballs"

- run: node ./scripts/deploy-tarball.js
- name: Upload tarballs
uses: actions/upload-artifact@v4
with:
# Update all mentions of this name in vercel-packages when changing.
name: preview-tarballs
path: ${{ runner.temp }}/preview-tarballs/*

publishRelease:
if: ${{ needs.build.outputs.isRelease == 'true' }}
if: ${{ needs.deploy-target.outputs.value == 'production' }}
name: Potentially publish release
runs-on: ubuntu-latest
needs:
- deploy-target
- build
- build-wasm
- build-native
Expand Down Expand Up @@ -500,23 +544,25 @@ jobs:
path: /home/runner/.npm/_logs/*

deployExamples:
if: ${{ needs.deploy-target.outputs.value != 'automated-preview' }}
name: Deploy examples
runs-on: ubuntu-latest
needs: [build]
needs: [build, deploy-target]
steps:
- run: echo '${{ needs.deploy-target.outputs.value }}'
- uses: actions/checkout@v4
with:
fetch-depth: 25
- name: Install Vercel CLI
run: npm i -g vercel@latest
- name: Deploy preview examples
if: ${{ needs.build.outputs.isRelease != 'true' }}
if: ${{ needs.deploy-target.outputs.value != 'production' }}
run: ./scripts/deploy-examples.sh
env:
VERCEL_API_TOKEN: ${{ secrets.VERCEL_API_TOKEN }}
DEPLOY_ENVIRONMENT: preview
- name: Deploy production examples
if: ${{ needs.build.outputs.isRelease == 'true' }}
if: ${{ needs.deploy-target.outputs.value == 'production' }}
run: ./scripts/deploy-examples.sh
env:
VERCEL_API_TOKEN: ${{ secrets.VERCEL_API_TOKEN }}
Expand Down Expand Up @@ -551,9 +597,10 @@ jobs:
NEXT_SKIP_NATIVE_POSTINSTALL: 1

upload_turbopack_bytesize:
if: ${{ needs.deploy-target.outputs.value != 'automated-preview'}}
name: Upload Turbopack Bytesize metrics to Datadog
runs-on: ubuntu-latest
needs: [build-native]
needs: [build-native, deploy-target]
env:
DATADOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }}
steps:
Expand Down
39 changes: 28 additions & 11 deletions .github/workflows/build_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ on:
required: false
description: 'whether to skip building native modules'
type: string
skipNativeInstall:
required: false
description: 'whether to skip native postinstall script'
type: string
default: 'yes'
uploadAnalyzerArtifacts:
required: false
description: 'whether to upload analyzer artifacts'
Expand Down Expand Up @@ -49,6 +54,16 @@ on:
required: true
description: 'name of the step, to be used for the upload artifact unique key '
type: string
timeout_minutes:
description: 'Timeout in minutes'
required: false
type: number
default: 30
runs_on_labels:
description: 'List of runner labels'
required: false
type: string
default: '["self-hosted", "linux", "x64", "metal"]'

env:
NAPI_CLI_VERSION: 2.14.7
Expand All @@ -61,23 +76,20 @@ env:
TURBO_TEAM: 'vercel'
TURBO_REMOTE_ONLY: 'true'
NEXT_TELEMETRY_DISABLED: 1
# we build a dev binary for use in CI so skip downloading
# canary next-swc binaries in the monorepo
NEXT_SKIP_NATIVE_POSTINSTALL: 1
# allow not skipping install-native postinstall script if we don't have a binary available already
NEXT_SKIP_NATIVE_POSTINSTALL: ${{ inputs.skipNativeInstall == 'yes' && '1' || '' }}
DATADOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }}
NEXT_JUNIT_TEST_REPORT: 'true'
DD_ENV: 'ci'
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }}
NEXT_TEST_JOB: 1
VERCEL_TEST_TOKEN: ${{ secrets.VERCEL_TEST_TOKEN }}
VERCEL_TEST_TEAM: vtest314-next-e2e-tests

jobs:
build:
timeout-minutes: 30
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'
timeout-minutes: ${{ inputs.timeout_minutes }}
runs-on: ${{ fromJson(inputs.runs_on_labels) }}

outputs:
input_step_key: ${{ steps.var.outputs.input_step_key }}
Expand All @@ -90,7 +102,12 @@ jobs:
script: |
core.setOutput('input_step_key', '${{ inputs.stepName }}'.toLowerCase().replaceAll(/[/.]/g, '-').trim('-'));

- run: fnm use --install-if-missing ${{ inputs.nodeVersion || env.NODE_LTS_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodeVersion || env.NODE_LTS_VERSION }}
check-latest: true

- run: node -v
- run: corepack enable
- run: pwd
Expand Down Expand Up @@ -171,7 +188,7 @@ jobs:
- run: turbo run get-test-timings -- --build ${{ github.sha }}

- run: /bin/bash -c "${{ inputs.afterBuild }}"
timeout-minutes: 15
timeout-minutes: ${{ inputs.timeout_minutes }}

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/retry_deploy_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: retry-deploy-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.ref_name == 'canary' &&
!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 }}
17 changes: 15 additions & 2 deletions .github/workflows/retry_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ permissions:
jobs:
retry-on-failure:
name: retry failed jobs
if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.run_attempt < 3 && github.repository == 'vercel/next.js' }}
# 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.run_attempt < 3
}}
runs-on: ubuntu-latest
steps:
- name: send retry request to GitHub API
Expand All @@ -31,7 +37,14 @@ jobs:

report-failure:
name: report failure to slack
if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.run_attempt >= 3 && !github.event.workflow_run.head_repository.fork }}
# Report the failure to Slack if the build-and-test workflow has failed 3 times
if: >-
${{
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.run_attempt >= 3 &&
github.ref_name == 'canary' &&
!github.event.workflow_run.head_repository.fork
}}
runs-on: ubuntu-latest
steps:
- name: send webhook
Expand Down
Loading
Loading