Unverified Commit 4c6a3fa4 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[ci] Pin deploy test deployments to Node.js 22.x (#100879)

Otherwise Vercel default for new projects is used which is latest
Node.js. This could cause random breakages if not everything is future
compatible.

We can later use the same setup to configure runs to use newer Node.js
versions (e.g. on a schedule to test future compat).

## Verification

- Full deploy run:
https://github.com/vercel/next.js/actions/runs/40861798132 -> [Example
deployment with Node.js
override](https://vercel.com/vtest314-next-adapter-e2e-tests/vtest314-e2e-tests/DVip99zHRvi6EVDiiFs7S6jcK97U)

<!-- NEXT_JS_LLM -->

---------
Co-authored-by: 's avatarClaude Code (kimi-k3[1m]) <noreply@anthropic.com>
parent 5a2d24ea
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
// trigger deploy tests v1 // trigger deploy tests v2
describe('hello-world', () => { describe('hello-world', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
......
...@@ -25,6 +25,11 @@ const BUILD_LOGS_MAX_POLL_MS = 180_000 ...@@ -25,6 +25,11 @@ const BUILD_LOGS_MAX_POLL_MS = 180_000
// with its own diagnostic instead of an opaque hook timeout. // with its own diagnostic instead of an opaque hook timeout.
const SETUP_HOOK_MARGIN_MS = 20_000 const SETUP_HOOK_MARGIN_MS = 20_000
// The Node.js version deployments are pinned to via `engines.node`. Must use
// the exact `N.x` form: a range like `>=22.0.0` maps to the newest available
// major. Matches NODE_LTS_VERSION in build_and_test.yml.
const DEPLOY_TEST_NODE_VERSION = '22.x'
const BUILD_LOG_MARKERS = [ const BUILD_LOG_MARKERS = [
'BUILD_ID', 'BUILD_ID',
'DEPLOYMENT_ID', 'DEPLOYMENT_ID',
...@@ -435,6 +440,10 @@ export class NextDeployInstance extends NextInstance { ...@@ -435,6 +440,10 @@ export class NextDeployInstance extends NextInstance {
await this.writeMirrorNpmrcIfNecessary() await this.writeMirrorNpmrcIfNecessary()
if (!process.env.NEXT_TEST_DEPLOY_URL?.trim()) {
this.pinNodeVersion()
}
if ( if (
!process.env.NEXT_TEST_DEPLOY_URL?.trim() && !process.env.NEXT_TEST_DEPLOY_URL?.trim() &&
!process.env.NEXT_TEST_DEPLOY_SCRIPT_PATH?.trim() && !process.env.NEXT_TEST_DEPLOY_SCRIPT_PATH?.trim() &&
...@@ -446,6 +455,26 @@ export class NextDeployInstance extends NextInstance { ...@@ -446,6 +455,26 @@ export class NextDeployInstance extends NextInstance {
this.preparePnpmSettings() this.preparePnpmSettings()
} }
// `engines.node` overrides the project-level Node.js version on Vercel, so
// it is the only place the pin can live: the weekly project reset recreates
// the projects, and the create-project API does not accept `nodeVersion`.
private pinNodeVersion(): void {
const packageJsonPath = path.join(this.testDir, 'package.json')
const packageJson: {
engines?: Record<string, string>
} = fs.readJsonSync(packageJsonPath)
packageJson.engines = {
...packageJson.engines,
// A fixture's own `engines.node` wins so it can deliberately deploy
// with a different version.
node: packageJson.engines?.node ?? DEPLOY_TEST_NODE_VERSION,
}
this.writeFixtureConfiguration(
packageJsonPath,
JSON.stringify(packageJson, null, 2) + '\n'
)
}
private preparePnpmSettings(): void { private preparePnpmSettings(): void {
const workspacePath = path.join(this.testDir, 'pnpm-workspace.yaml') const workspacePath = path.join(this.testDir, 'pnpm-workspace.yaml')
const settings = { const settings = {
......
...@@ -92,6 +92,9 @@ describe('deployment lifecycle', () => { ...@@ -92,6 +92,9 @@ describe('deployment lifecycle', () => {
jest jest
.spyOn(NextDeployInstance.prototype as any, 'preparePnpmSettings') .spyOn(NextDeployInstance.prototype as any, 'preparePnpmSettings')
.mockReturnValue(undefined) .mockReturnValue(undefined)
jest
.spyOn(NextDeployInstance.prototype as any, 'pinNodeVersion')
.mockReturnValue(undefined)
jest jest
.spyOn(NextDeployInstance.prototype as any, 'configureProxyAddress') .spyOn(NextDeployInstance.prototype as any, 'configureProxyAddress')
.mockResolvedValue(undefined) .mockResolvedValue(undefined)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment