Skip to content

Commit 29c7019

Browse files
committed
ci: add bun package manager to e2e tests
This commit introduces support for the `bun` package manager in our end-to-end tests. The following changes are included: - The `bun` package manager is now part of the test matrix in the CI configuration. - The package manager flags for `bun` have been updated to align with the latest version. - The `ng add` command has been updated to support `bun`, including a workaround for a symlink issue. - Tests that are not compatible with `bun`, such as those for unscoped authentication, are now skipped when `bun` the active package manager.
1 parent 41c6798 commit 29c7019

File tree

10 files changed

+28
-12
lines changed

10 files changed

+28
-12
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ jobs:
164164
# flaky targets are retried. The larger machine type comes with 2x more SSD space.
165165
os: [ubuntu-latest-4core]
166166
node: [22]
167-
subset: [yarn, pnpm]
167+
subset: [yarn, pnpm, bun]
168168
shard: [0, 1, 2]
169169
runs-on: ${{ matrix.os }}
170170
steps:

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ jobs:
182182
# flaky targets are retried. The larger machine type comes with 2x more SSD space.
183183
os: [ubuntu-latest-4core]
184184
node: [22]
185-
subset: [yarn, pnpm]
185+
subset: [yarn, pnpm, bun]
186186
shard: [0, 1, 2]
187187
runs-on: ${{ matrix.os }}
188188
steps:

packages/angular/cli/src/utilities/package-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ export class PackageManagerUtils {
158158
};
159159
case PackageManager.Bun:
160160
return {
161-
saveDev: '--development',
161+
saveDev: '--dev',
162162
install: 'add',
163163
installAll: 'install',
164164
prefix: '--cwd',
165-
noLockfile: '',
165+
noLockfile: '--no-save',
166166
};
167167
default:
168168
return {

tests/legacy-cli/e2e/assets/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ load("//tools:defaults.bzl", "copy_to_bin")
22

33
copy_to_bin(
44
name = "assets",
5-
srcs = glob(["**"]),
5+
srcs = glob(
6+
include = ["**"],
7+
exclude = ["BUILD.bazel"],
8+
),
69
visibility = ["//visibility:public"],
710
)

tests/legacy-cli/e2e/setup/100-global-cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const PACKAGE_MANAGER_VERSION = {
66
'npm': '10.8.1',
77
'yarn': '1.22.22',
88
'pnpm': '10.17.1',
9-
'bun': '1.2.21',
9+
'bun': '1.3.2',
1010
};
1111

1212
export default async function () {
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1+
import { cp } from 'fs/promises';
12
import { assetDir } from '../../../utils/assets';
23
import { expectFileToExist } from '../../../utils/fs';
34
import { ng } from '../../../utils/process';
5+
import { resolve } from 'path';
46

57
export default async function () {
6-
await ng('add', assetDir('add-collection'), '--name=blah', '--skip-confirmation');
8+
const collectionName = 'add-collection-dir';
9+
const dirCollectionPath = resolve(collectionName);
10+
11+
// Copy locally as bun doesn't install the dependency correctly if it has symlinks.
12+
await cp(assetDir(collectionName), dirCollectionPath, {
13+
recursive: true,
14+
dereference: true,
15+
});
16+
17+
await ng('add', dirCollectionPath, '--name=blah', '--skip-confirmation');
718
await expectFileToExist('blah');
819
}

tests/legacy-cli/e2e/tests/commands/add/secure-registry.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ import { expectToFail } from '../../../utils/utils';
77
export default async function () {
88
// The environment variable has priority over the .npmrc
99
delete process.env['NPM_CONFIG_REGISTRY'];
10-
const isNpm = getActivePackageManager() === 'npm';
10+
const packageManager = getActivePackageManager();
11+
const supportsUnscopedAuth = packageManager !== 'bun' && packageManager !== 'npm';
1112

1213
const command = ['add', '@angular/pwa', '--skip-confirmation'];
1314
await expectFileNotToExist('public/manifest.webmanifest');
1415

1516
// Works with unscoped registry authentication details
16-
if (!isNpm) {
17-
// NPM no longer support unscoped.
17+
if (supportsUnscopedAuth) {
18+
// Some package managers such as Bun and NPM do not support unscoped auth.
1819
await createNpmConfigForAuthentication(false);
1920
await ng(...command);
2021
await expectFileToExist('public/manifest.webmanifest');
2122
await git('clean', '-dxf');
2223
}
24+
2325
// Works with scoped registry authentication details
2426
await expectFileNotToExist('public/manifest.webmanifest');
2527

@@ -28,8 +30,8 @@ export default async function () {
2830
await expectFileToExist('public/manifest.webmanifest');
2931

3032
// Invalid authentication token
31-
if (isNpm) {
32-
// NPM no longer support unscoped.
33+
if (!supportsUnscopedAuth) {
34+
// Some package managers such as Bun and NPM do not support unscoped auth.
3335
await createNpmConfigForAuthentication(false, true);
3436
await expectToFail(() => ng(...command));
3537
}

0 commit comments

Comments
 (0)