2023-05-28 06:02:31 +02:00
|
|
|
name: Build Reusable
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
afterBuild:
|
|
|
|
required: false
|
|
|
|
description: 'additional steps to run'
|
|
|
|
type: string
|
2023-06-22 10:03:44 +02:00
|
|
|
# Toggles the mold linker. The default linker is much slower and can run into OOMs.
|
|
|
|
# However, custom linkers won't work for wasm.
|
|
|
|
mold:
|
|
|
|
required: false
|
|
|
|
description: 'whether to use the mold linker'
|
|
|
|
type: string
|
2023-05-28 06:02:31 +02:00
|
|
|
skipInstallBuild:
|
|
|
|
required: false
|
|
|
|
description: 'whether to skip pnpm install && pnpm build'
|
|
|
|
type: string
|
2023-06-12 16:47:43 +02:00
|
|
|
skipNativeBuild:
|
|
|
|
required: false
|
|
|
|
description: 'whether to skip building native modules'
|
|
|
|
type: string
|
2023-10-24 07:48:41 +02:00
|
|
|
uploadAnalyzerArtifacts:
|
|
|
|
required: false
|
|
|
|
description: 'whether to upload analyzer artifacts'
|
|
|
|
type: string
|
2023-05-28 06:02:31 +02:00
|
|
|
nodeVersion:
|
|
|
|
required: false
|
|
|
|
description: 'version of Node.js to use'
|
|
|
|
type: string
|
2023-06-12 16:47:43 +02:00
|
|
|
needsRust:
|
|
|
|
required: false
|
|
|
|
description: 'if rust is needed'
|
|
|
|
type: string
|
2023-05-28 06:02:31 +02:00
|
|
|
needsNextest:
|
|
|
|
required: false
|
|
|
|
description: 'if nextest rust dep is needed'
|
|
|
|
type: string
|
2023-06-06 18:57:09 +02:00
|
|
|
uploadSwcArtifact:
|
|
|
|
required: false
|
|
|
|
description: 'if swc artifact needs uploading'
|
|
|
|
type: string
|
2023-08-27 03:54:14 +02:00
|
|
|
rustCacheKey:
|
|
|
|
required: false
|
|
|
|
description: 'rustCacheKey to cache shared target assets'
|
|
|
|
type: string
|
2024-01-25 09:39:40 +01:00
|
|
|
stepName:
|
|
|
|
required: true
|
|
|
|
description: 'name of the step, to be used for the upload artifact unique key '
|
|
|
|
type: string
|
2024-06-11 22:59:43 +02:00
|
|
|
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"]'
|
2023-05-28 06:02:31 +02:00
|
|
|
|
|
|
|
env:
|
|
|
|
NAPI_CLI_VERSION: 2.14.7
|
2024-06-12 21:31:42 +02:00
|
|
|
TURBO_VERSION: 2.0.3
|
2023-10-30 19:03:48 +01:00
|
|
|
NODE_LTS_VERSION: 20.9.0
|
2023-08-11 23:05:11 +02:00
|
|
|
TEST_CONCURRENCY: 8
|
2023-06-07 18:53:50 +02:00
|
|
|
# disable backtrace for test snapshots
|
|
|
|
RUST_BACKTRACE: 0
|
2023-05-28 06:02:31 +02:00
|
|
|
|
|
|
|
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
|
2023-06-08 12:52:49 +02:00
|
|
|
DATADOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }}
|
2023-11-23 15:18:03 +01:00
|
|
|
NEXT_JUNIT_TEST_REPORT: 'true'
|
2023-06-08 12:52:49 +02:00
|
|
|
DD_ENV: 'ci'
|
2023-05-28 06:02:31 +02:00
|
|
|
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }}
|
|
|
|
NEXT_TEST_JOB: 1
|
2024-06-11 22:59:43 +02:00
|
|
|
VERCEL_TEST_TOKEN: ${{ secrets.VERCEL_TEST_TOKEN }}
|
|
|
|
VERCEL_TEST_TEAM: vtest314-next-e2e-tests
|
2023-05-28 06:02:31 +02:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2024-06-11 22:59:43 +02:00
|
|
|
timeout-minutes: ${{ inputs.timeout_minutes }}
|
|
|
|
runs-on: ${{ fromJson(inputs.runs_on_labels) }}
|
2023-05-28 06:02:31 +02:00
|
|
|
|
2024-01-25 09:39:40 +01:00
|
|
|
outputs:
|
|
|
|
input_step_key: ${{ steps.var.outputs.input_step_key }}
|
|
|
|
|
2023-05-28 06:02:31 +02:00
|
|
|
steps:
|
2024-01-25 09:39:40 +01:00
|
|
|
- name: Normalize input step names into path key
|
2024-02-01 22:13:29 +01:00
|
|
|
uses: actions/github-script@v7
|
2024-01-25 09:39:40 +01:00
|
|
|
id: var
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
core.setOutput('input_step_key', '${{ inputs.stepName }}'.toLowerCase().replaceAll(/[/.]/g, '-').trim('-'));
|
|
|
|
|
2024-06-11 22:59:43 +02:00
|
|
|
- name: Setup Node.js
|
|
|
|
uses: actions/setup-node@v4
|
|
|
|
with:
|
|
|
|
node-version: ${{ inputs.nodeVersion || env.NODE_LTS_VERSION }}
|
|
|
|
check-latest: true
|
|
|
|
|
2023-05-28 06:02:31 +02:00
|
|
|
- run: node -v
|
2023-08-04 21:40:20 +02:00
|
|
|
- run: corepack enable
|
2023-05-28 06:02:31 +02:00
|
|
|
- run: pwd
|
|
|
|
|
2023-11-29 19:07:22 +01:00
|
|
|
- run: rm -rf .git
|
|
|
|
|
2024-02-01 22:13:29 +01:00
|
|
|
- uses: actions/checkout@v4
|
2023-06-07 18:53:50 +02:00
|
|
|
with:
|
|
|
|
fetch-depth: 25
|
|
|
|
|
|
|
|
# local action -> needs to run after checkout
|
|
|
|
- name: Install Rust
|
|
|
|
uses: ./.github/actions/setup-rust
|
2023-06-12 16:47:43 +02:00
|
|
|
if: ${{ inputs.skipNativeBuild != 'yes' || inputs.needsNextest == 'yes' || inputs.needsRust == 'yes' }}
|
2023-05-28 06:02:31 +02:00
|
|
|
|
2023-06-22 10:03:44 +02:00
|
|
|
- name: 'Install mold linker'
|
|
|
|
if: ${{ inputs.mold == 'yes' }}
|
|
|
|
run: |
|
|
|
|
sudo apt update
|
|
|
|
sudo apt install -y mold
|
|
|
|
echo RUSTFLAGS=${RUSTFLAGS}\ -C\ link-arg=-fuse-ld=mold >> $GITHUB_ENV
|
|
|
|
|
2023-05-28 06:02:31 +02:00
|
|
|
- name: Install nextest
|
|
|
|
if: ${{ inputs.needsNextest == 'yes' }}
|
|
|
|
uses: taiki-e/install-action@nextest
|
|
|
|
|
|
|
|
- run: rustc --version
|
2023-06-12 16:47:43 +02:00
|
|
|
if: ${{ inputs.skipNativeBuild != 'yes' || inputs.needsNextest == 'yes' || inputs.needsRust == 'yes' }}
|
2023-05-28 06:02:31 +02:00
|
|
|
|
2023-08-04 21:40:20 +02:00
|
|
|
- run: corepack prepare --activate yarn@1.22.19 && npm i -g "turbo@${TURBO_VERSION}" "@napi-rs/cli@${NAPI_CLI_VERSION}"
|
2023-05-28 06:02:31 +02:00
|
|
|
|
2023-08-27 03:54:14 +02:00
|
|
|
- name: Cache on ${{ github.ref_name }}
|
2024-04-15 23:15:10 +02:00
|
|
|
uses: ijjk/rust-cache@turbo-cache-v1.0.8
|
2023-08-27 03:54:14 +02:00
|
|
|
if: ${{ inputs.rustCacheKey }}
|
|
|
|
with:
|
|
|
|
cache-provider: 'turbo'
|
2023-08-29 07:29:28 +02:00
|
|
|
save-if: ${{ github.ref_name == 'canary' }}
|
|
|
|
shared-key: ${{ inputs.rustCacheKey }}-x86_64-unknown-linux-gnu-build-${{ hashFiles('.cargo/config.toml') }}
|
2023-08-27 03:54:14 +02:00
|
|
|
|
2023-05-28 06:02:31 +02:00
|
|
|
# clean up any previous artifacts to avoid hitting disk space limits
|
2023-06-12 16:47:43 +02:00
|
|
|
- run: git clean -xdf && rm -rf /tmp/next-repo-*; rm -rf /tmp/next-install-* /tmp/yarn-* /tmp/ncc-cache target
|
|
|
|
|
2024-04-26 18:19:50 +02:00
|
|
|
# Configure a git user so that Create Next App can initialize git repos during integration tests.
|
|
|
|
- name: Set CI git user
|
|
|
|
run: |
|
|
|
|
git config --global user.name "vercel-ci-bot"
|
|
|
|
git config --global user.email "infra+ci@vercel.com"
|
|
|
|
|
2023-06-12 16:47:43 +02:00
|
|
|
- run: cargo clean
|
|
|
|
if: ${{ inputs.skipNativeBuild != 'yes' || inputs.needsNextest == 'yes' || inputs.needsRust == 'yes' }}
|
2023-05-28 06:02:31 +02:00
|
|
|
|
|
|
|
# normalize versions before build-native for better cache hits
|
|
|
|
- run: node scripts/normalize-version-bump.js
|
|
|
|
name: normalize versions
|
|
|
|
|
2024-06-12 21:31:42 +02:00
|
|
|
- run: turbo run build-native-release -vvv --env-mode loose --remote-cache-timeout 90 --summarize -- --target x86_64-unknown-linux-gnu
|
2023-11-29 19:25:01 +01:00
|
|
|
if: ${{ inputs.skipNativeBuild != 'yes' }}
|
2023-05-28 06:02:31 +02:00
|
|
|
|
2023-06-06 18:57:09 +02:00
|
|
|
- name: Upload next-swc artifact
|
2023-11-29 19:25:01 +01:00
|
|
|
if: ${{ inputs.uploadSwcArtifact == 'yes' }}
|
2024-01-25 09:39:40 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-06-06 18:57:09 +02:00
|
|
|
with:
|
|
|
|
name: next-swc-binary
|
|
|
|
path: packages/next-swc/native/next-swc.linux-x64-gnu.node
|
|
|
|
|
2023-05-28 06:02:31 +02:00
|
|
|
# undo normalize version changes for install/build
|
|
|
|
- run: git checkout .
|
|
|
|
if: ${{ inputs.skipInstallBuild != 'yes' }}
|
|
|
|
|
|
|
|
- run: pnpm install
|
|
|
|
if: ${{ inputs.skipInstallBuild != 'yes' }}
|
|
|
|
|
2023-10-24 07:48:41 +02:00
|
|
|
- run: ANALYZE=1 pnpm build
|
2023-05-28 06:02:31 +02:00
|
|
|
if: ${{ inputs.skipInstallBuild != 'yes' }}
|
|
|
|
|
|
|
|
- run: pnpm playwright install-deps
|
|
|
|
if: ${{ inputs.skipInstallBuild != 'yes' }}
|
|
|
|
|
|
|
|
- run: pnpm playwright install chromium
|
|
|
|
if: ${{ inputs.skipInstallBuild != 'yes' }}
|
|
|
|
|
|
|
|
- run: turbo run get-test-timings -- --build ${{ github.sha }}
|
|
|
|
|
|
|
|
- run: /bin/bash -c "${{ inputs.afterBuild }}"
|
2024-06-11 22:59:43 +02:00
|
|
|
timeout-minutes: ${{ inputs.timeout_minutes }}
|
2023-05-28 06:02:31 +02:00
|
|
|
|
|
|
|
- name: Upload artifact
|
2024-01-25 09:39:40 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-05-28 06:02:31 +02:00
|
|
|
with:
|
2024-01-25 09:39:40 +01:00
|
|
|
name: turbo-run-summary-${{ steps.var.outputs.input_step_key }}
|
2023-05-28 06:02:31 +02:00
|
|
|
path: .turbo/runs
|
2023-11-23 15:18:03 +01:00
|
|
|
if-no-files-found: ignore
|
2023-06-12 19:14:13 +02:00
|
|
|
|
2023-10-24 07:48:41 +02:00
|
|
|
- name: Upload bundle analyzer artifacts
|
2024-01-25 09:39:40 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-10-24 07:48:41 +02:00
|
|
|
if: ${{ inputs.uploadAnalyzerArtifacts == 'yes' }}
|
|
|
|
with:
|
2024-01-25 09:39:40 +01:00
|
|
|
name: webpack bundle analysis stats-${{ steps.var.outputs.input_step_key }}
|
2023-10-24 07:48:41 +02:00
|
|
|
path: packages/next/dist/compiled/next-server/report.*.html
|
|
|
|
|
2023-11-23 15:18:03 +01:00
|
|
|
- name: Upload test report artifacts
|
2024-01-25 09:39:40 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-11-23 15:18:03 +01:00
|
|
|
if: ${{ inputs.afterBuild && always() }}
|
2023-06-12 19:14:13 +02:00
|
|
|
with:
|
2024-01-25 09:39:40 +01:00
|
|
|
name: test-reports-${{ steps.var.outputs.input_step_key }}
|
2023-06-12 19:14:13 +02:00
|
|
|
path: |
|
|
|
|
test/test-junit-report
|
|
|
|
test/turbopack-test-junit-report
|
|
|
|
if-no-files-found: ignore
|
2023-12-11 20:07:08 +01:00
|
|
|
|
|
|
|
# upload playwright snapshots from failed tests
|
|
|
|
- name: Upload test report artifacts
|
2024-01-25 09:39:40 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-12-11 20:07:08 +01:00
|
|
|
if: ${{ inputs.afterBuild && always() }}
|
|
|
|
with:
|
2024-01-25 09:39:40 +01:00
|
|
|
name: test-playwright-snapshots-${{ steps.var.outputs.input_step_key }}
|
2023-12-11 20:07:08 +01:00
|
|
|
path: |
|
|
|
|
test/traces
|
|
|
|
if-no-files-found: ignore
|