Skip to content

Commit

Permalink
Implement Turbopack build manifest update (#63461)
Browse files Browse the repository at this point in the history
WIP.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2857
  • Loading branch information
timneutkens authored Mar 19, 2024
1 parent d91e78a commit b9547e7
Show file tree
Hide file tree
Showing 8 changed files with 630 additions and 41 deletions.
125 changes: 93 additions & 32 deletions .github/actions/upload-turboyet-data/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/actions/upload-turboyet-data/dist/index.js.map

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions .github/workflows/turbopack-daily-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,23 @@ on:
default: 'canary'

jobs:
# Trigger actual next.js integration tests.
next_js_integration:
next_js_dev_integration:
name: Execute Next.js integration workflow
if: github.repository_owner == 'vercel'
permissions:
pull-requests: write
uses: ./.github/workflows/turbopack-nextjs-integration-tests.yml
uses: ./.github/workflows/turbopack-nextjs-dev-integration-tests.yml
secrets: inherit
with:
diff_base: 'none'
version: ${{ inputs.version || 'canary' }}

next_js_build_integration:
name: Execute Next.js integration workflow
if: github.repository_owner == 'vercel'
permissions:
pull-requests: write
uses: ./.github/workflows/turbopack-nextjs-build-integration-tests.yml
secrets: inherit
with:
diff_base: 'none'
Expand Down
199 changes: 199 additions & 0 deletions .github/workflows/turbopack-nextjs-build-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# Reusable workflow to execute certain version of Next.js integration tests
# with turbopack.
#
# Refer test.yml for how this workflow is being initialized
# - Workflow can specify `inputs.version` to specify which version of next.js to use, otherwise will use latest release version.
name: Turbopack Next.js production integration tests

on:
workflow_call:
inputs:
# Allow to specify Next.js version to run integration test against.
# If not specified, will use latest release version including canary.
version:
type: string
# The base of the test results to compare against. If not specified, will try to compare with latest main branch's test results.
diff_base:
type: string
default: 'main'

# Workflow-common env variables
env:
# Enabling backtrace will makes snapshot tests fail
RUST_BACKTRACE: 0
NEXT_TELEMETRY_DISABLED: 1
TEST_CONCURRENCY: 6
NEXT_JUNIT_TEST_REPORT: 'true'
# Turbopack specific customization for the test runner
TURBOPACK: 1
__INTERNAL_CUSTOM_TURBOPACK_BINDINGS: ${{ github.workspace }}/packages/next-swc/native/next-swc.linux-x64-gnu.node
NEXT_TEST_SKIP_RETRY_MANIFEST: ${{ github.workspace }}/integration-test-data/test-results/main/failed-test-path-list.json
NEXT_TEST_CONTINUE_ON_ERROR: TRUE
NEXT_E2E_TEST_TIMEOUT: 240000
NEXT_TEST_JOB: 1

jobs:
# First, build Next.js to execute across tests.
setup_nextjs:
name: Setup Next.js build
uses: ./.github/workflows/setup-nextjs-build.yml
with:
version: ${{ inputs.version }}

# Actual test scheduling. These jobs mimic the same jobs in Next.js repo,
# which we do allow some of duplications to make it easier to update if upstream changes.
# Refer build_and_test.yml in the Next.js repo for more details.
test-build:
# This job name is being used in github action to collect test results. Do not change it, or should update
# ./.github/actions/next-integration-stat to match the new name.
name: Next.js integration test (Production)
# Currently it is possible test grouping puts large number of failing tests suites in a single group,
# which ends up job timeouts. Temporarily relieve the timeout until we make progresses on the failing suites.
# ref: https://github.com/vercel/turbo/pull/5668
# timeout-minutes: 180
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'

needs: [setup_nextjs]
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6]

steps:
- uses: actions/cache/restore@v3
id: restore-build
with:
path: ./*
key: ${{ inputs.version }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt}}-${{ github.run_number }}
fail-on-cache-miss: true

- name: Enable corepack and install yarn
run: |
corepack enable
corepack prepare --activate [email protected]
- name: Setup playwright
run: |
pnpm playwright install
- name: Run test/production
run: |
NEXT_TEST_MODE=start TURBOPACK=1 TURBOPACK_BUILD=1 node run-tests.js -g ${{ matrix.group }}/6 -c ${TEST_CONCURRENCY} --type start
# It is currently expected to fail some of next.js integration test, do not fail CI check.
continue-on-error: true

- name: Upload test report artifacts
uses: actions/upload-artifact@v4
with:
name: test-reports-start-${{ matrix.group }}
if-no-files-found: 'error'
path: |
test/turbopack-test-junit-report
test-integration:
name: Next.js production integration test (Integration)
needs: [setup_nextjs]
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'

timeout-minutes: 180
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

steps:
- uses: actions/cache/restore@v3
id: restore-build
with:
path: ./*
key: ${{ inputs.version }}-${{ github.sha }}
fail-on-cache-miss: true

- name: Enable corepack and install yarn
run: |
corepack enable
corepack prepare --activate [email protected]
- name: Setup playwright
run: |
pnpm playwright install
- name: Run test/integration
run: |
TURBOPACK=1 TURBOPACK_BUILD=1 node run-tests.js -g ${{ matrix.group }}/12 -c ${TEST_CONCURRENCY} --type integration
continue-on-error: true

- name: Upload test report artifacts
uses: actions/upload-artifact@v4
with:
name: test-reports-integration-${{ matrix.group }}
if-no-files-found: 'error'
path: |
test/turbopack-test-junit-report
# Collect integration test results from execute_tests,
# Store it as github artifact for next step to consume.
collect_nextjs_integration_stat:
needs: [test-build, test-integration]
name: Next.js integration test status report
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'

if: always()
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Collect integration test stat
uses: ./.github/actions/next-integration-stat
with:
diff_base: ${{ inputs.diff_base }}

- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: test-results-build
path: |
nextjs-test-results.json
failed-test-path-list.json
passed-test-path-list.json
upload_test_report:
needs: [test-build, test-integration]
name: Upload test report to datadog
runs-on:
- 'self-hosted'
- 'linux'
- 'x64'
- 'metal'

if: ${{ !cancelled() }}
steps:
- name: Download test report artifacts
id: download-test-reports
uses: actions/download-artifact@v4
with:
pattern: test-reports-*
path: test/reports
merge-multiple: true

- name: Upload to datadog
env:
DATADOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }}
DD_ENV: 'ci'
run: |
# We'll tag this to the "Turbopack" datadog service, not "nextjs"
npx @datadog/[email protected] junit upload --tags test.type:turbopack-build.daily --service Turbopack ./test/reports
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Refer test.yml for how this workflow is being initialized
# - Workflow can specify `inputs.version` to specify which version of next.js to use, otherwise will use latest release version.
name: Turbopack Next.js integration tests
name: Turbopack Next.js development integration tests

on:
workflow_call:
Expand Down
41 changes: 37 additions & 4 deletions .github/workflows/turbopack-update-tests-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
workflow_dispatch:

jobs:
update_manifest:
name: Update and upload Turbopack test manifest
update_dev_manifest:
name: Update and upload Turbopack development test manifest
if: github.repository_owner == 'vercel'
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -39,5 +39,38 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PULL_REQUESTS }}
BRANCH_NAME: turbopack-manifest
SCRIPT: test/build-turbopack-dev-tests-manifest.js
PR_TITLE: Update Turbopack test manifest
PR_BODY: This auto-generated PR updates the integration test manifest used when testing Turbopack.
PR_TITLE: Update Turbopack development test manifest
PR_BODY: This auto-generated PR updates the development integration test manifest used when testing Turbopack.
update_build_manifest:
name: Update and upload Turbopack production test manifest
if: github.repository_owner == 'vercel'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Commits made with the default `GITHUB_TOKEN` won't trigger workflows.
# See: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

- run: corepack enable

- name: Install dependencies
shell: bash
run: pnpm i

- name: Create Pull Request
shell: bash
run: node scripts/automated-update-workflow.js
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PULL_REQUESTS }}
BRANCH_NAME: turbopack-manifest
SCRIPT: test/build-turbopack-build-tests-manifest.js
PR_TITLE: Update Turbopack production test manifest
PR_BODY: This auto-generated PR updates the production integration test manifest used when testing Turbopack.
4 changes: 4 additions & 0 deletions .github/workflows/turbopack-upload-tests-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
node ./test/build-turbopack-dev-tests-manifest.js
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PULL_REQUESTS }}
- run: |
node ./test/build-turbopack-build-tests-manifest.js
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PULL_REQUESTS }}
- name: 'Upload results to "Are We Turbo Yet" KV'
env:
Expand Down
Loading

0 comments on commit b9547e7

Please sign in to comment.