Skip to content

Commit 3a86fcf

Browse files
committed
ci: use current minimum Node.js v16 version to test snapshot builds
Node.js 16.10 is currently the minimum version of v16 supported by the Angular CLI and is now used when executing the Angular snapshot E2E test suite to ensure that the latest snapshots of Angular continue to function at this Node.js version. Node.js v16 is the version currently used to develop the Angular CLI. The npm 7+ workaround of installing npm 6 is also removed to more closely track the behavior of Node.js 16.10 as well as any other Node.js version used during testing.
1 parent b220f32 commit 3a86fcf

File tree

5 files changed

+56
-36
lines changed

5 files changed

+56
-36
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,8 @@ jobs:
204204
- browser-tools/install-chrome
205205
- run:
206206
name: Initialize Environment
207-
# npm 7 currently does not properly publish the packages locally
208207
command: |
209208
./.circleci/env.sh
210-
sudo npm install --global npm@6
211209
- run:
212210
name: Execute CLI E2E Tests
213211
command: |
@@ -354,6 +352,7 @@ workflows:
354352
- build
355353
- e2e-cli:
356354
name: e2e-cli-ng-snapshots
355+
nodeversion: '16.10'
357356
snapshots: true
358357
requires:
359358
- build
Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
import { getGlobalVariable } from '../utils/env';
2-
import { npm } from '../utils/process';
2+
import { execWithEnv } from '../utils/process';
33
import { isPrereleaseCli } from '../utils/project';
44

55
export default async function () {
66
const testRegistry = getGlobalVariable('package-registry');
7-
await npm(
8-
'run',
9-
'admin',
10-
'--',
11-
'publish',
12-
'--no-versionCheck',
13-
'--no-branchCheck',
14-
`--registry=${testRegistry}`,
15-
'--tag',
16-
isPrereleaseCli() ? 'next' : 'latest',
7+
await execWithEnv(
8+
'npm',
9+
[
10+
'run',
11+
'admin',
12+
'--',
13+
'publish',
14+
'--no-versionCheck',
15+
'--no-branchCheck',
16+
`--registry=${testRegistry}`,
17+
'--tag',
18+
isPrereleaseCli() ? 'next' : 'latest',
19+
],
20+
{
21+
...process.env,
22+
// Also set an auth token value for the local test registry which is required by npm 7+
23+
// even though it is never actually used.
24+
'NPM_CONFIG__AUTH': 'e2e-testing',
25+
},
1726
);
1827
}
Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
11
import { expectFileToMatch } from '../../utils/fs';
2-
import { ng, silentNpm } from '../../utils/process';
2+
import { execWithEnv, ng, silentNpm } from '../../utils/process';
33
import { installPackage, uninstallPackage } from '../../utils/packages';
44
import { isPrereleaseCli } from '../../utils/project';
55

66
export default async function () {
77
// Must publish old version to local registry to allow install. This is especially important
88
// for release commits as npm will try to request tooling packages that are not on the npm registry yet
9-
const { stdout: stdoutPack1 } = await silentNpm(
10-
'pack',
11-
'@schematics/angular@7',
12-
'--registry=https://registry.npmjs.org',
13-
);
14-
await silentNpm('publish', stdoutPack1.trim(), '--tag=outdated');
15-
const { stdout: stdoutPack2 } = await silentNpm(
16-
'pack',
17-
'@angular-devkit/core@7',
18-
'--registry=https://registry.npmjs.org',
19-
);
20-
await silentNpm('publish', stdoutPack2.trim(), '--tag=outdated');
21-
const { stdout: stdoutPack3 } = await silentNpm(
22-
'pack',
23-
'@angular-devkit/schematics@7',
24-
'--registry=https://registry.npmjs.org',
25-
);
26-
await silentNpm('publish', stdoutPack3.trim(), '--tag=outdated');
9+
await publishOutdated('@schematics/angular@7');
10+
await publishOutdated('@angular-devkit/core@7');
11+
await publishOutdated('@angular-devkit/schematics@7');
2712

2813
// Install outdated and incompatible version
2914
await installPackage('@schematics/angular@7');
@@ -36,3 +21,17 @@ export default async function () {
3621
// Not doing so can cause adding material to fail if an incompatible cdk is present
3722
await uninstallPackage('@angular/cdk');
3823
}
24+
25+
async function publishOutdated(npmSpecifier: string): Promise<void> {
26+
const { stdout: stdoutPack } = await silentNpm(
27+
'pack',
28+
npmSpecifier,
29+
'--registry=https://registry.npmjs.org',
30+
);
31+
await execWithEnv('npm', ['publish', stdoutPack.trim(), '--tag=outdated'], {
32+
...process.env,
33+
// Also set an auth token value for the local test registry which is required by npm 7+
34+
// even though it is never actually used.
35+
'NPM_CONFIG__AUTH': 'e2e-testing',
36+
});
37+
}

tests/legacy-cli/e2e/tests/misc/third-party-decorators.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export default async function () {
1515
packageJson['devDependencies']['typescript'] = '~4.6.2';
1616
});
1717

18-
await installWorkspacePackages();
18+
// Force is need to prevent npm 7+ from failing due to potential peer dependency resolution range errors.
19+
// This is especially common when testing snapshot builds for new prereleases.
20+
await installWorkspacePackages({ force: true });
1921

2022
// Create an app that uses ngrx decorators and has e2e tests.
2123
await writeMultipleFiles({

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { getGlobalVariable } from './env';
2-
import { writeFile } from './fs';
32
import { ProcessOutput, npm, silentNpm, silentYarn } from './process';
43

54
export function getActivePackageManager(): 'npm' | 'yarn' {
@@ -11,10 +10,14 @@ export function getActivePackageManager(): 'npm' | 'yarn' {
1110
return value || 'npm';
1211
}
1312

14-
export async function installWorkspacePackages(): Promise<void> {
13+
export async function installWorkspacePackages(options?: { force?: boolean }): Promise<void> {
1514
switch (getActivePackageManager()) {
1615
case 'npm':
17-
await silentNpm('install');
16+
const npmArgs = ['install'];
17+
if (options?.force) {
18+
npmArgs.push('--force');
19+
}
20+
await silentNpm(...npmArgs);
1821
break;
1922
case 'yarn':
2023
await silentYarn();
@@ -47,6 +50,7 @@ export async function setRegistry(useTestRegistry: boolean): Promise<void> {
4750
: 'https://registry.npmjs.org';
4851

4952
const isCI = getGlobalVariable('ci');
53+
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
5054

5155
// Ensure local test registry is used when outside a project
5256
if (isCI) {
@@ -56,4 +60,11 @@ export async function setRegistry(useTestRegistry: boolean): Promise<void> {
5660
// Yarn supports both `NPM_CONFIG_REGISTRY` and `YARN_REGISTRY`.
5761
process.env['NPM_CONFIG_REGISTRY'] = url;
5862
}
63+
64+
// Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch).
65+
// In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests.
66+
// To support this case, legacy peer dependency mode is enabled for snapshot builds.
67+
if (isSnapshotBuild) {
68+
process.env['NPM_CONFIG_legacy_peer_deps'] = 'true';
69+
}
5970
}

0 commit comments

Comments
 (0)