Skip to content

Commit c545f77

Browse files
committed
test: add bun and pnpm subsets
This commit adds PNPM and Bun package managers as subsets. However, Bun tests are currently disabled due to an issue where packages from the local registry are only partially extracted.
1 parent 8d256b0 commit c545f77

File tree

10 files changed

+88
-65
lines changed

10 files changed

+88
-65
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
matrix:
7676
os: [ubuntu-latest, windows-latest]
7777
node: [18, 20, 22]
78-
subset: [npm, yarn, esbuild]
78+
subset: [npm, yarn, pnpm, esbuild]
7979
shard: [0, 1, 2, 3, 4, 5]
8080
exclude:
8181
# Exclude Node.js v18 when running on a PR
@@ -87,6 +87,9 @@ jobs:
8787
# Skip yarn subset on Windows
8888
- os: windows-latest
8989
subset: yarn
90+
# Skip pnpm subset on Windows
91+
- os: windows-latest
92+
subset: pnpm
9093
# Skip Node.js v18 tests on Windows
9194
- os: windows-latest
9295
node: 18
@@ -112,7 +115,7 @@ jobs:
112115
matrix:
113116
os: [ubuntu-latest]
114117
node: [18]
115-
subset: [npm, yarn, esbuild]
118+
subset: [npm, yarn, pnpm, esbuild]
116119
shard: [0, 1, 2, 3, 4, 5]
117120
runs-on: ${{ matrix.os }}
118121
steps:

.github/workflows/pr.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
matrix:
108108
os: [ubuntu-latest, windows-latest]
109109
node: [18, 20, 22]
110-
subset: [npm, yarn, esbuild]
110+
subset: [npm, yarn, pnpm, esbuild]
111111
shard: [0, 1, 2, 3, 4, 5]
112112
exclude:
113113
# Exclude Node.js v18 when running on a PR
@@ -119,6 +119,9 @@ jobs:
119119
# Skip yarn subset on Windows
120120
- os: windows-latest
121121
subset: yarn
122+
# Skip pnpm subset on Windows
123+
- os: windows-latest
124+
subset: pnpm
122125
# Skip Node.js v18 tests on Windows
123126
- os: windows-latest
124127
node: 18
@@ -146,7 +149,7 @@ jobs:
146149
matrix:
147150
os: [ubuntu-latest]
148151
node: [18]
149-
subset: [npm, yarn, esbuild]
152+
subset: [npm, yarn, pnpm, esbuild]
150153
shard: [0, 1, 2, 3, 4, 5]
151154
runs-on: ${{ matrix.os }}
152155
steps:

tests/legacy-cli/e2e.bzl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ TEST_TAGS = ["no-remote-exec", "requires-network"]
2828

2929
# Subset of tests for yarn/esbuild
3030
BROWSER_TESTS = ["tests/misc/browsers.js"]
31-
YARN_TESTS = ["tests/basic/**", "tests/update/**", "tests/commands/add/**"]
31+
PACKAGE_MANAGER_SUBSET_TESTS = ["tests/basic/**", "tests/update/**", "tests/commands/add/**", "tests/misc/create-angular.js"]
3232
ESBUILD_TESTS = [
3333
"tests/basic/**",
3434
"tests/build/**",
@@ -72,6 +72,8 @@ def e2e_suites(name, runner, data):
7272
_e2e_tests(name + "_" + toolchain_name, runner, data = data, toolchain = toolchain, tags = ["manual"])
7373

7474
_e2e_suite(name, runner, "npm", data, toolchain_name, toolchain)
75+
_e2e_suite(name, runner, "bun", data, toolchain_name, toolchain)
76+
_e2e_suite(name, runner, "pnpm", data, toolchain_name, toolchain)
7577
_e2e_suite(name, runner, "yarn", data, toolchain_name, toolchain)
7678
_e2e_suite(name, runner, "esbuild", data, toolchain_name, toolchain)
7779

@@ -124,7 +126,7 @@ def _e2e_tests(name, runner, **kwargs):
124126

125127
def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None):
126128
"""
127-
Setup a predefined test suite (yarn|esbuild|saucelabs|npm).
129+
Setup a predefined test suite (yarn|pnpm|bun|esbuild|saucelabs|npm).
128130
"""
129131
args = []
130132
tests = None
@@ -133,9 +135,10 @@ def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None):
133135
if toolchain_name:
134136
toolchain_name = "_" + toolchain_name
135137

136-
if type == "yarn":
137-
args.append("--yarn")
138-
tests = YARN_TESTS
138+
if type == "yarn" or type == "bun" or type == "pnpm":
139+
args.append("--package-manager=%s" % type)
140+
args.append("--esbuild")
141+
tests = PACKAGE_MANAGER_SUBSET_TESTS
139142
ignore = BROWSER_TESTS + WEBPACK_IGNORE_TESTS
140143
elif type == "esbuild":
141144
args.append("--esbuild")

tests/legacy-cli/e2e/initialize/300-log-environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ export default async function () {
1313
console.log(` ${envName}: ${process.env[envName]!.replace(/[\n\r]+/g, '\n ')}`);
1414
});
1515

16-
await exec('which', 'ng', 'yarn', 'npm');
16+
await exec('which', 'ng', 'yarn', 'npm', 'bun', 'pnpm');
1717
await ng('version');
1818
}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
import { getGlobalVariable } from '../utils/env';
22
import { globalNpm } from '../utils/process';
33

4-
const NPM_VERSION = '7.24.0';
5-
const YARN_VERSION = '1.22.18';
4+
const NPM_VERSION = '7.24.0'; // TODO: update to latest and fix tests.
5+
const YARN_VERSION = '1.22.22';
6+
const PNPM_VERSION = '9.3.0';
7+
const BUN_VERSION = '1.1.13';
68

79
export default async function () {
810
const argv = getGlobalVariable('argv');
911
if (argv.noglobal) {
1012
return;
1113
}
1214

13-
const testRegistry: string = getGlobalVariable('package-registry');
15+
const testRegistry = getGlobalVariable('package-registry');
1416

1517
// Install global Angular CLI being tested, npm+yarn used by e2e tests.
1618
await globalNpm([
1719
'install',
1820
'--global',
1921
`--registry=${testRegistry}`,
2022
'@angular/cli',
23+
`bun@${BUN_VERSION}`,
2124
`npm@${NPM_VERSION}`,
2225
`yarn@${YARN_VERSION}`,
26+
`pnpm@${PNPM_VERSION}`,
2327
]);
2428
}

tests/legacy-cli/e2e/tests/misc/create-angular.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { join, resolve } from 'path';
22
import { expectFileToExist, readFile, rimraf } from '../../utils/fs';
33
import { getActivePackageManager } from '../../utils/packages';
4-
import { silentNpm, silentYarn } from '../../utils/process';
4+
import { silentBun, silentNpm, silentPnpm, silentYarn } from '../../utils/process';
55

66
export default async function () {
77
const currentDirectory = process.cwd();
@@ -21,6 +21,14 @@ export default async function () {
2121
case 'yarn':
2222
await silentYarn('create', '@angular', projectName, '--skip-install', '--style=scss');
2323

24+
break;
25+
case 'bun':
26+
await silentBun('create', '@angular', projectName, '--skip-install', '--style=scss');
27+
28+
break;
29+
case 'pnpm':
30+
await silentPnpm('create', '@angular', projectName, '--skip-install', '--style=scss');
31+
2432
break;
2533
default:
2634
throw new Error(`This test is not configured to use ${packageManager}.`);

tests/legacy-cli/e2e/tests/update/update.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export default async function () {
1414
// older versions @angular/cli packages which would cause `npm install` during `ng update` to fail.
1515
restoreRegistry = await createProjectFromAsset('15.0-project', true);
1616

17+
// CLI project version
18+
const cliMajorProjectVersion = 15;
19+
1720
// If using npm, enable legacy peer deps mode to avoid defects in npm 7+'s peer dependency resolution
1821
// Example error where 11.2.14 satisfies the SemVer range ^11.0.0 but still fails:
1922
// npm ERR! Conflicting peer dependency: @angular/compiler-cli@11.2.14
@@ -25,12 +28,6 @@ export default async function () {
2528
await appendFile('.npmrc', '\nlegacy-peer-deps=true');
2629
}
2730

28-
// CLI project version
29-
const { version: cliVersion } = JSON.parse(
30-
await readFile('./node_modules/@angular/cli/package.json'),
31-
);
32-
const cliMajorProjectVersion = new SemVer(cliVersion).major;
33-
3431
// CLI current version.
3532
const cliMajorVersion = getNgCLIVersion().major;
3633

tests/legacy-cli/e2e/utils/packages.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
import { getGlobalVariable } from './env';
2-
import { ProcessOutput, silentNpm, silentYarn } from './process';
2+
import { ProcessOutput, silentBun, silentNpm, silentPnpm, silentYarn } from './process';
33

44
export interface PkgInfo {
55
readonly name: string;
66
readonly version: string;
77
readonly path: string;
88
}
99

10-
export function getActivePackageManager(): 'npm' | 'yarn' {
11-
const value = getGlobalVariable('package-manager');
12-
if (value && value !== 'npm' && value !== 'yarn') {
13-
throw new Error('Invalid package manager value: ' + value);
14-
}
15-
16-
return value || 'npm';
10+
export function getActivePackageManager(): 'npm' | 'yarn' | 'bun' | 'pnpm' {
11+
return getGlobalVariable('package-manager');
1712
}
1813

1914
export async function installWorkspacePackages(options?: { force?: boolean }): Promise<void> {
@@ -26,7 +21,13 @@ export async function installWorkspacePackages(options?: { force?: boolean }): P
2621
await silentNpm(...npmArgs);
2722
break;
2823
case 'yarn':
29-
await silentYarn();
24+
await silentYarn('install');
25+
break;
26+
case 'pnpm':
27+
await silentPnpm('install');
28+
break;
29+
case 'bun':
30+
await silentBun('install');
3031
break;
3132
}
3233
}
@@ -38,6 +39,10 @@ export async function installPackage(specifier: string, registry?: string): Prom
3839
return silentNpm('install', specifier, ...registryOption);
3940
case 'yarn':
4041
return silentYarn('add', specifier, ...registryOption);
42+
case 'bun':
43+
return silentBun('add', specifier, ...registryOption);
44+
case 'pnpm':
45+
return silentPnpm('add', specifier, ...registryOption);
4146
}
4247
}
4348

@@ -47,6 +52,10 @@ export async function uninstallPackage(name: string): Promise<ProcessOutput> {
4752
return silentNpm('uninstall', name);
4853
case 'yarn':
4954
return silentYarn('remove', name);
55+
case 'bun':
56+
return silentBun('remove', name);
57+
case 'pnpm':
58+
return silentPnpm('remove', name);
5059
}
5160
}
5261

tests/legacy-cli/e2e/utils/process.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,14 @@ export function silentYarn(...args: string[]) {
359359
return _exec({ silent: true }, 'yarn', args);
360360
}
361361

362+
export function silentPnpm(...args: string[]) {
363+
return _exec({ silent: true }, 'pnpm', args);
364+
}
365+
366+
export function silentBun(...args: string[]) {
367+
return _exec({ silent: true }, 'bun', args);
368+
}
369+
362370
export function globalNpm(args: string[], env?: NodeJS.ProcessEnv) {
363371
if (!process.env.LEGACY_CLI_RUNNER) {
364372
throw new Error(
@@ -369,10 +377,6 @@ export function globalNpm(args: string[], env?: NodeJS.ProcessEnv) {
369377
return _exec({ silent: true, env }, process.execPath, [require.resolve('npm'), ...args]);
370378
}
371379

372-
export function npm(...args: string[]) {
373-
return _exec({}, 'npm', args);
374-
}
375-
376380
export function node(...args: string[]) {
377381
return _exec({}, process.execPath, args);
378382
}

tests/legacy-cli/e2e_runner.ts

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,38 @@ Error.stackTraceLimit = Infinity;
1919

2020
/**
2121
* Here's a short description of those flags:
22-
* --debug If a test fails, block the thread so the temporary directory isn't deleted.
23-
* --noproject Skip creating a project or using one.
24-
* --noglobal Skip linking your local @angular/cli directory. Can save a few seconds.
25-
* --nosilent Never silence ng commands.
26-
* --ng-tag=TAG Use a specific tag for build snapshots. Similar to ng-snapshots but point to a
27-
* tag instead of using the latest `main`.
28-
* --ng-snapshots Install angular snapshot builds in the test project.
29-
* --glob Run tests matching this glob pattern (relative to tests/e2e/).
30-
* --ignore Ignore tests matching this glob pattern.
31-
* --reuse=/path Use a path instead of create a new project. That project should have been
32-
* created, and npm installed. Ideally you want a project created by a previous
33-
* run of e2e.
34-
* --nb-shards Total number of shards that this is part of. Default is 2 if --shard is
35-
* passed in.
36-
* --shard Index of this processes' shard.
37-
* --tmpdir=path Override temporary directory to use for new projects.
38-
* --yarn Use yarn as package manager.
39-
* --package=path An npm package to be published before running tests
22+
* --debug If a test fails, block the thread so the temporary directory isn't deleted.
23+
* --noproject Skip creating a project or using one.
24+
* --noglobal Skip linking your local @angular/cli directory. Can save a few seconds.
25+
* --nosilent Never silence ng commands.
26+
* --ng-tag=TAG Use a specific tag for build snapshots. Similar to ng-snapshots but point to a
27+
* tag instead of using the latest `main`.
28+
* --ng-snapshots Install angular snapshot builds in the test project.
29+
* --glob Run tests matching this glob pattern (relative to tests/e2e/).
30+
* --ignore Ignore tests matching this glob pattern.
31+
* --reuse=/path Use a path instead of create a new project. That project should have been
32+
* created, and npm installed. Ideally you want a project created by a previous
33+
* run of e2e.
34+
* --nb-shards Total number of shards that this is part of. Default is 2 if --shard is
35+
* passed in.
36+
* --shard Index of this processes' shard.
37+
* --tmpdir=path Override temporary directory to use for new projects.
38+
* --package-manager Package manager to use.
39+
* --package=path An npm package to be published before running tests
4040
*
4141
* If unnamed flags are passed in, the list of tests will be filtered to include only those passed.
4242
*/
4343
const argv = yargsParser(process.argv.slice(2), {
44-
boolean: [
45-
'debug',
46-
'esbuild',
47-
'ng-snapshots',
48-
'noglobal',
49-
'nosilent',
50-
'noproject',
51-
'verbose',
52-
'yarn',
53-
],
54-
string: ['devkit', 'glob', 'reuse', 'ng-tag', 'tmpdir', 'ng-version'],
44+
boolean: ['debug', 'esbuild', 'ng-snapshots', 'noglobal', 'nosilent', 'noproject', 'verbose'],
45+
string: ['devkit', 'glob', 'reuse', 'ng-tag', 'tmpdir', 'ng-version', 'package-manager'],
5546
number: ['nb-shards', 'shard'],
5647
array: ['package', 'ignore'],
5748
configuration: {
5849
'camel-case-expansion': false,
5950
'dot-notation': false,
6051
},
6152
default: {
53+
'package-manager': 'npm',
6254
'package': ['./dist/_*.tgz'],
6355
'debug': !!process.env.BUILD_WORKSPACE_DIRECTORY,
6456
'glob': process.env.TESTBRIDGE_TEST_ONLY,
@@ -140,8 +132,8 @@ const allTests = glob
140132
// will be executed on the same shard.
141133
const fileName = path.basename(name);
142134
if (
143-
(fileName.startsWith('yarn-') && !argv.yarn) ||
144-
(fileName.startsWith('npm-') && argv.yarn)
135+
(fileName.startsWith('yarn-') && argv['package-manager'] !== 'yarn') ||
136+
(fileName.startsWith('npm-') && argv['package-manager'] !== 'npm')
145137
) {
146138
return false;
147139
}
@@ -197,7 +189,7 @@ if (testsToRun.length == allTests.length) {
197189
console.log(['Tests:', ...testsToRun].join('\n '));
198190

199191
setGlobalVariable('argv', argv);
200-
setGlobalVariable('package-manager', argv.yarn ? 'yarn' : 'npm');
192+
setGlobalVariable('package-manager', argv['package-manager']);
201193

202194
// Use the chrome supplied by bazel or the puppeteer chrome and webdriver-manager driver outside.
203195
// This is needed by karma-chrome-launcher, protractor etc.

0 commit comments

Comments
 (0)