Skip to content

Commit 8feaa9c

Browse files
authored
[cli][tests] Work around Yarn + Corepack issue in tests (#10858)
CI started failing on corepack related tests with error: ``` error This project's package.json defines "packageManager": "yarn@npm@8.1.0". However the current global version of Yarn is 1.22.21. ``` This appears to be a bug in the Yarn v1.22.21, which was released a week ago: https://github.com/yarnpkg/yarn/releases/tag/v1.22.21 Setting the `SKIP_YARN_COREPACK_CHECK` env var disables this new check which fixes the issue for us. **NOTE:** Review with [whitespace changes disabled](https://github.com/vercel/vercel/pull/10858/files?w=1) for an easier view.
1 parent 31daff6 commit 8feaa9c

File tree

2 files changed

+58
-42
lines changed

2 files changed

+58
-42
lines changed

.changeset/green-pianos-grow.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/cli/test/integration-1.test.ts

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ afterAll(async () => {
211211
test('[vc build] should build project with corepack and select npm@8.1.0', async () => {
212212
try {
213213
process.env.ENABLE_EXPERIMENTAL_COREPACK = '1';
214+
process.env.SKIP_YARN_COREPACK_CHECK = '1';
214215
const directory = await setupE2EFixture('vc-build-corepack-npm');
215216
const before = await exec(directory, 'npm', ['--version']);
216217
const output = await execCli(binaryPath, ['build'], { cwd: directory });
@@ -234,55 +235,68 @@ test('[vc build] should build project with corepack and select npm@8.1.0', async
234235
expect(contents).toEqual(['home', 'shim']);
235236
} finally {
236237
delete process.env.ENABLE_EXPERIMENTAL_COREPACK;
238+
delete process.env.SKIP_YARN_COREPACK_CHECK;
237239
}
238240
});
239241

240242
test('[vc build] should build project with corepack and select pnpm@7.1.0', async () => {
241-
process.env.ENABLE_EXPERIMENTAL_COREPACK = '1';
242-
const directory = await setupE2EFixture('vc-build-corepack-pnpm');
243-
const before = await exec(directory, 'pnpm', ['--version']);
244-
const output = await execCli(binaryPath, ['build'], { cwd: directory });
245-
expect(output.exitCode, formatOutput(output)).toBe(0);
246-
expect(output.stderr).toMatch(/Build Completed/gm);
247-
const after = await exec(directory, 'pnpm', ['--version']);
248-
// Ensure global pnpm didn't change
249-
expect(before.stdout).toBe(after.stdout);
250-
// Ensure version is correct
251-
expect(
252-
await fs.readFile(
253-
path.join(directory, '.vercel/output/static/index.txt'),
254-
'utf8'
255-
)
256-
).toBe('7.1.0\n');
257-
// Ensure corepack will be cached
258-
const contents = fs.readdirSync(
259-
path.join(directory, '.vercel/cache/corepack')
260-
);
261-
expect(contents).toEqual(['home', 'shim']);
243+
try {
244+
process.env.ENABLE_EXPERIMENTAL_COREPACK = '1';
245+
process.env.SKIP_YARN_COREPACK_CHECK = '1';
246+
const directory = await setupE2EFixture('vc-build-corepack-pnpm');
247+
const before = await exec(directory, 'pnpm', ['--version']);
248+
const output = await execCli(binaryPath, ['build'], { cwd: directory });
249+
expect(output.exitCode, formatOutput(output)).toBe(0);
250+
expect(output.stderr).toMatch(/Build Completed/gm);
251+
const after = await exec(directory, 'pnpm', ['--version']);
252+
// Ensure global pnpm didn't change
253+
expect(before.stdout).toBe(after.stdout);
254+
// Ensure version is correct
255+
expect(
256+
await fs.readFile(
257+
path.join(directory, '.vercel/output/static/index.txt'),
258+
'utf8'
259+
)
260+
).toBe('7.1.0\n');
261+
// Ensure corepack will be cached
262+
const contents = fs.readdirSync(
263+
path.join(directory, '.vercel/cache/corepack')
264+
);
265+
expect(contents).toEqual(['home', 'shim']);
266+
} finally {
267+
delete process.env.ENABLE_EXPERIMENTAL_COREPACK;
268+
delete process.env.SKIP_YARN_COREPACK_CHECK;
269+
}
262270
});
263271

264272
test('[vc build] should build project with corepack and select yarn@2.4.3', async () => {
265-
process.env.ENABLE_EXPERIMENTAL_COREPACK = '1';
266-
const directory = await setupE2EFixture('vc-build-corepack-yarn');
267-
const before = await exec(directory, 'yarn', ['--version']);
268-
const output = await execCli(binaryPath, ['build'], { cwd: directory });
269-
expect(output.exitCode, formatOutput(output)).toBe(0);
270-
expect(output.stderr).toMatch(/Build Completed/gm);
271-
const after = await exec(directory, 'yarn', ['--version']);
272-
// Ensure global yarn didn't change
273-
expect(before.stdout).toBe(after.stdout);
274-
// Ensure version is correct
275-
expect(
276-
await fs.readFile(
277-
path.join(directory, '.vercel/output/static/index.txt'),
278-
'utf8'
279-
)
280-
).toBe('2.4.3\n');
281-
// Ensure corepack will be cached
282-
const contents = fs.readdirSync(
283-
path.join(directory, '.vercel/cache/corepack')
284-
);
285-
expect(contents).toEqual(['home', 'shim']);
273+
try {
274+
process.env.ENABLE_EXPERIMENTAL_COREPACK = '1';
275+
process.env.SKIP_YARN_COREPACK_CHECK = '1';
276+
const directory = await setupE2EFixture('vc-build-corepack-yarn');
277+
const before = await exec(directory, 'yarn', ['--version']);
278+
const output = await execCli(binaryPath, ['build'], { cwd: directory });
279+
expect(output.exitCode, formatOutput(output)).toBe(0);
280+
expect(output.stderr).toMatch(/Build Completed/gm);
281+
const after = await exec(directory, 'yarn', ['--version']);
282+
// Ensure global yarn didn't change
283+
expect(before.stdout).toBe(after.stdout);
284+
// Ensure version is correct
285+
expect(
286+
await fs.readFile(
287+
path.join(directory, '.vercel/output/static/index.txt'),
288+
'utf8'
289+
)
290+
).toBe('2.4.3\n');
291+
// Ensure corepack will be cached
292+
const contents = fs.readdirSync(
293+
path.join(directory, '.vercel/cache/corepack')
294+
);
295+
expect(contents).toEqual(['home', 'shim']);
296+
} finally {
297+
delete process.env.ENABLE_EXPERIMENTAL_COREPACK;
298+
delete process.env.SKIP_YARN_COREPACK_CHECK;
299+
}
286300
});
287301

288302
test('[vc dev] should print help from `vc develop --help`', async () => {

0 commit comments

Comments
 (0)