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

[test] Pin package manager versions used (#93592)

parent 0b8a0fb4
...@@ -16,7 +16,7 @@ RUN corepack enable ...@@ -16,7 +16,7 @@ RUN corepack enable
FROM base AS pnpm-deploy FROM base AS pnpm-deploy
WORKDIR /dot-github WORKDIR /dot-github
COPY pnpm-lock.yaml pnpm-workspace.yaml . COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY --exclude=actions/*/node_modules \ COPY --exclude=actions/*/node_modules \
actions/next-stats-action actions/next-stats-action actions/next-stats-action actions/next-stats-action
RUN pnpm deploy --filter=next-stats-action --production /next-stats RUN pnpm deploy --filter=next-stats-action --production /next-stats
......
{
"name": "next-github-workflows",
"private": true,
"packageManager": "pnpm@10.33.0"
}
...@@ -7,6 +7,8 @@ settings: ...@@ -7,6 +7,8 @@ settings:
importers: importers:
.: {}
actions/needs-triage: actions/needs-triage:
dependencies: dependencies:
'@actions/core': '@actions/core':
......
...@@ -11,6 +11,7 @@ describe('nx-handling', () => { ...@@ -11,6 +11,7 @@ describe('nx-handling', () => {
name: '@nx-next/source', name: '@nx-next/source',
version: '0.0.0', version: '0.0.0',
private: true, private: true,
packageManager: 'npm@10.9.2',
scripts: { scripts: {
build: 'rm -rf dist; nx run next-nx-test:build', build: 'rm -rf dist; nx run next-nx-test:build',
dev: 'nx run next-nx-test:dev', dev: 'nx run next-nx-test:dev',
......
...@@ -48,6 +48,7 @@ for (const cacheEnabled of [false, true]) { ...@@ -48,6 +48,7 @@ for (const cacheEnabled of [false, true]) {
files: __dirname, files: __dirname,
skipDeployment: true, skipDeployment: true,
packageJson: { packageJson: {
packageManager: 'npm@10.9.2',
scripts: { scripts: {
build: `${envVars} next build`, build: `${envVars} next build`,
dev: `${envVars} next dev`, dev: `${envVars} next dev`,
......
import { createNext } from 'e2e-utils' import { createNext, isNextDev } from 'e2e-utils'
import { NextInstance } from 'e2e-utils' import { NextInstance } from 'e2e-utils'
import { renderViaHTTP } from 'next-test-utils' import { renderViaHTTP } from 'next-test-utils'
...@@ -24,8 +24,18 @@ describe('handle-non-hoisted-swc-helpers', () => { ...@@ -24,8 +24,18 @@ describe('handle-non-hoisted-swc-helpers', () => {
} }
`, `,
}, },
packageJson: {
packageManager: 'npm@10.9.2',
scripts: {
build: 'next build',
dev: 'next dev',
start: 'next start',
},
},
installCommand: installCommand:
'npm install; mkdir -p node_modules/next/node_modules/@swc; mv node_modules/@swc/helpers node_modules/next/node_modules/@swc/', 'npm install; mkdir -p node_modules/next/node_modules/@swc; mv node_modules/@swc/helpers node_modules/next/node_modules/@swc/',
buildCommand: 'npm run build',
startCommand: isNextDev ? 'npm run dev' : 'npm run start',
dependencies: {}, dependencies: {},
}) })
}) })
......
...@@ -45,6 +45,11 @@ export function runTests( ...@@ -45,6 +45,11 @@ export function runTests(
}, },
{} as { [key: string]: FileRef } {} as { [key: string]: FileRef }
), ),
packageJson: {
// Bootstrap with classic yarn; the install command below runs
// `yarn set version berry` which rewrites this to the berry version.
packageManager: 'yarn@1.22.22',
},
dependencies: { dependencies: {
...packageJson.dependencies, ...packageJson.dependencies,
...packageJson.devDependencies, ...packageJson.devDependencies,
......
import { import {
command,
DEFAULT_FILES, DEFAULT_FILES,
FULL_EXAMPLE_PATH, FULL_EXAMPLE_PATH,
projectFilesShouldExist, projectFilesShouldExist,
...@@ -10,6 +11,11 @@ import { ...@@ -10,6 +11,11 @@ import {
const lockFile = 'pnpm-lock.yaml' const lockFile = 'pnpm-lock.yaml'
const files = [...DEFAULT_FILES, lockFile] const files = [...DEFAULT_FILES, lockFile]
// Match the monorepo's pinned pnpm so CNA's `pnpm install` doesn't drift to
// whichever version corepack happens to fetch as "latest" at test time.
const rootPackageManager: string =
require('../../../../package.json').packageManager
describe('create-next-app with package manager pnpm', () => { describe('create-next-app with package manager pnpm', () => {
let nextTgzFilename: string let nextTgzFilename: string
...@@ -18,6 +24,8 @@ describe('create-next-app with package manager pnpm', () => { ...@@ -18,6 +24,8 @@ describe('create-next-app with package manager pnpm', () => {
throw new Error('This test needs to be run with `node run-tests.js`.') throw new Error('This test needs to be run with `node run-tests.js`.')
} }
await command('corepack', ['prepare', '--activate', rootPackageManager])
const pkgPaths = new Map<string, string>( const pkgPaths = new Map<string, string>(
JSON.parse(process.env.NEXT_TEST_PKG_PATHS) JSON.parse(process.env.NEXT_TEST_PKG_PATHS)
) )
......
...@@ -9,6 +9,7 @@ const { linkPackages } = ...@@ -9,6 +9,7 @@ const { linkPackages } =
const PREFER_OFFLINE = process.env.NEXT_TEST_PREFER_OFFLINE === '1' const PREFER_OFFLINE = process.env.NEXT_TEST_PREFER_OFFLINE === '1'
const useRspack = process.env.NEXT_TEST_USE_RSPACK === '1' const useRspack = process.env.NEXT_TEST_USE_RSPACK === '1'
const ROOT_PACKAGE_MANAGER = require('../../package.json').packageManager
async function installDependencies(cwd, tmpDir) { async function installDependencies(cwd, tmpDir) {
const args = [ const args = [
...@@ -175,6 +176,10 @@ async function createNextInstall({ ...@@ -175,6 +176,10 @@ async function createNextInstall({
path.join(installDir, 'package.json'), path.join(installDir, 'package.json'),
JSON.stringify( JSON.stringify(
{ {
// Pin packageManager so corepack doesn't auto-inject a reference
// to the latest version (and rewrite this file mid-test).
// Callers can override via packageJson.packageManager.
packageManager: ROOT_PACKAGE_MANAGER,
...packageJson, ...packageJson,
scripts, scripts,
dependencies: combinedDependencies, dependencies: combinedDependencies,
......
...@@ -71,6 +71,9 @@ type OmitFirstArgument<F> = F extends ( ...@@ -71,6 +71,9 @@ type OmitFirstArgument<F> = F extends (
// prettier-ignore // prettier-ignore
const nextjsReactPeerVersion = "19.2.6"; const nextjsReactPeerVersion = "19.2.6";
const ROOT_PACKAGE_MANAGER: string =
require('../../../package.json').packageManager
export class NextInstance { export class NextInstance {
protected files: ResolvedFileConfig protected files: ResolvedFileConfig
protected overrideFiles: ResolvedFileConfig protected overrideFiles: ResolvedFileConfig
...@@ -275,6 +278,10 @@ export class NextInstance { ...@@ -275,6 +278,10 @@ export class NextInstance {
path.join(this.testDir, 'package.json'), path.join(this.testDir, 'package.json'),
JSON.stringify( JSON.stringify(
{ {
// Pin packageManager so corepack doesn't auto-inject a reference
// to the latest version (and rewrite this file mid-test).
// Callers can override via packageJson.packageManager.
packageManager: ROOT_PACKAGE_MANAGER,
...this.packageJson, ...this.packageJson,
dependencies: { dependencies: {
...finalDependencies, ...finalDependencies,
......
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