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

[lts-active] [ci] Pin deploy test deployments to Node.js 22.x (#100886)

Backports #100879 to `releases/lts/active`.

Conflict resolution: the release branch predates the
pnpm-security-settings and build-log-polling machinery on canary, so
only the `engines.node` pin was carried over. `pinNodeVersion()` is
async here because this branch's `writeFixtureConfiguration` is async.
Co-authored-by: 's avatarClaude Code (kimi-k3[1m]) <noreply@anthropic.com>
parent 22e51c12
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
// trigger deploy tests v2
describe('hello-world', () => { describe('hello-world', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
......
...@@ -13,6 +13,11 @@ import { FileRef } from '../e2e-utils' ...@@ -13,6 +13,11 @@ import { FileRef } from '../e2e-utils'
import { PROXY_HOST_MAP_ENV_KEY } from '../browsers/launch' import { PROXY_HOST_MAP_ENV_KEY } from '../browsers/launch'
import { packPackages } from '../create-next-install' import { packPackages } from '../create-next-install'
// 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'
export class NextDeployInstance extends NextInstance { export class NextDeployInstance extends NextInstance {
private _cliOutput: string private _cliOutput: string
private _buildId: string private _buildId: string
...@@ -291,6 +296,10 @@ export class NextDeployInstance extends NextInstance { ...@@ -291,6 +296,10 @@ export class NextDeployInstance extends NextInstance {
await this.writeMirrorNpmrcIfNecessary() await this.writeMirrorNpmrcIfNecessary()
if (!process.env.NEXT_TEST_DEPLOY_URL?.trim()) {
await 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() &&
...@@ -300,6 +309,26 @@ export class NextDeployInstance extends NextInstance { ...@@ -300,6 +309,26 @@ export class NextDeployInstance extends NextInstance {
} }
} }
// `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 async pinNodeVersion(): Promise<void> {
const packageJsonPath = path.join(this.testDir, 'package.json')
const packageJson: {
engines?: Record<string, string>
} = await fs.readJSON(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,
}
await this.writeFixtureConfiguration(
packageJsonPath,
JSON.stringify(packageJson, null, 2) + '\n'
)
}
private async deploy() { private async deploy() {
const existingDeployUrl = process.env.NEXT_TEST_DEPLOY_URL?.trim() const existingDeployUrl = process.env.NEXT_TEST_DEPLOY_URL?.trim()
const customDeployScriptPath = const customDeployScriptPath =
......
...@@ -56,6 +56,9 @@ describe('deployment lifecycle', () => { ...@@ -56,6 +56,9 @@ describe('deployment lifecycle', () => {
jest jest
.spyOn(NextDeployInstance.prototype as any, 'writeMirrorNpmrcIfNecessary') .spyOn(NextDeployInstance.prototype as any, 'writeMirrorNpmrcIfNecessary')
.mockResolvedValue(undefined) .mockResolvedValue(undefined)
jest
.spyOn(NextDeployInstance.prototype as any, 'pinNodeVersion')
.mockResolvedValue(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