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

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

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

Conflict resolution: this branch's deploy harness predates
`writeFixtureConfiguration` and the `prepareLocalPackages`/`deploy()`
split on canary, so `pinNodeVersion()` writes the fixture `package.json`
directly with `fs.writeFile` and runs unconditionally in `setup()` (this
branch has no `NEXT_TEST_DEPLOY_URL` reuse path). The
`next-deploy-failure` unit test change was dropped since that suite does
not exist on this branch.

<!-- NEXT_JS_LLM -->
Co-authored-by: 's avatarClaude Code (kimi-k3[1m]) <noreply@anthropic.com>
parent 2829b57f
import { nextTestSetup } from 'e2e-utils'
// trigger deploy tests v2
describe('hello-world', () => {
const { next } = nextTestSetup({
files: __dirname,
......
......@@ -11,6 +11,11 @@ import {
import fetch from 'node-fetch'
import { Span } from 'next/dist/trace'
// 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 {
private _cliOutput: string
private _buildId: string
......@@ -21,11 +26,34 @@ export class NextDeployInstance extends NextInstance {
return this._buildId
}
// `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 fs.writeFile(
packageJsonPath,
JSON.stringify(packageJson, null, 2) + '\n'
)
}
public async setup(parentSpan: Span) {
super.setup(parentSpan)
await super.createTestDir({ parentSpan, skipInstall: true })
await this.writeMirrorNpmrcIfNecessary()
await this.pinNodeVersion()
// ensure Vercel CLI is installed
try {
const res = await execa('vercel', ['--version'])
......
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