Skip to content

Commit 141a25a

Browse files
committed
test: run e2e tests on provided packages
The NPM packages to test must be specified via --package instead of invoking the build from within the e2e tests
1 parent b5cb05f commit 141a25a

File tree

4 files changed

+39
-23
lines changed

4 files changed

+39
-23
lines changed

.circleci/dynamic_config.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -237,23 +237,23 @@ jobs:
237237
- run:
238238
name: Execute CLI E2E Tests with NPM
239239
command: |
240-
node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} <<# parameters.snapshots >>--ng-snapshots<</ parameters.snapshots >> --tmpdir=/mnt/ramdisk/e2e
240+
node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} <<# parameters.snapshots >>--ng-snapshots<</ parameters.snapshots >> --tmpdir=/mnt/ramdisk/e2e --package ./dist/_*.tgz
241241
- when:
242242
condition:
243243
equal: ['esbuild', << parameters.subset >>]
244244
steps:
245245
- run:
246246
name: Execute CLI E2E Tests Subset with Esbuild
247247
command: |
248-
node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} <<# parameters.snapshots >>--ng-snapshots<</ parameters.snapshots >> --esbuild --tmpdir=/mnt/ramdisk/e2e --glob="{tests/basic/**,tests/build/prod-build.ts,tests/build/relative-sourcemap.ts,tests/build/styles/scss.ts,tests/build/styles/include-paths.ts,tests/commands/add/add-pwa.ts}" --ignore="tests/basic/{environment,rebuild,serve,scripts-array}.ts"
248+
node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} <<# parameters.snapshots >>--ng-snapshots<</ parameters.snapshots >> --esbuild --tmpdir=/mnt/ramdisk/e2e --package ./dist/_*.tgz --glob="{tests/basic/**,tests/build/prod-build.ts,tests/build/relative-sourcemap.ts,tests/build/styles/scss.ts,tests/build/styles/include-paths.ts,tests/commands/add/add-pwa.ts}" --ignore="tests/basic/{environment,rebuild,serve,scripts-array}.ts"
249249
- when:
250250
condition:
251251
equal: ['yarn', << parameters.subset >>]
252252
steps:
253253
- run:
254254
name: Execute CLI E2E Tests Subset with Yarn
255255
command: |
256-
node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} <<# parameters.snapshots >>--ng-snapshots<</ parameters.snapshots >> --yarn --tmpdir=/mnt/ramdisk/e2e --glob="{tests/basic/**,tests/update/**,tests/commands/add/**}"
256+
node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} <<# parameters.snapshots >>--ng-snapshots<</ parameters.snapshots >> --yarn --tmpdir=/mnt/ramdisk/e2e --package ./dist/_*.tgz --glob="{tests/basic/**,tests/update/**,tests/commands/add/**}"
257257
- fail_fast
258258

259259
test-browsers:
@@ -275,7 +275,7 @@ jobs:
275275
# Waits for the Saucelabs tunnel to be ready. This ensures that we don't run tests
276276
# too early without Saucelabs not being ready.
277277
- run: ./scripts/saucelabs/wait-for-tunnel.sh
278-
- run: node ./tests/legacy-cli/run_e2e ./tests/legacy-cli/e2e/tests/misc/browsers.ts
278+
- run: node ./tests/legacy-cli/run_e2e --package ./dist/_*.tgz --glob="tests/misc/browsers.ts"
279279
- run: ./scripts/saucelabs/stop-tunnel.sh
280280
- fail_fast
281281

@@ -284,6 +284,10 @@ jobs:
284284
steps:
285285
- custom_attach_workspace
286286
- run: yarn build
287+
- persist_to_workspace:
288+
root: *workspace_location
289+
paths:
290+
- dist/_*.tgz
287291

288292
build-bazel-e2e:
289293
executor: action-executor
@@ -350,12 +354,14 @@ jobs:
350354
# Path where Arsenal Image Mounter files are downloaded.
351355
# Must match path in .circleci/win-ram-disk.ps1
352356
- ./aim
357+
# Build the npm packages for the e2e tests
358+
- run: yarn build
353359
# Run partial e2e suite on PRs only. Release branches will run the full e2e suite.
354360
- run:
355361
name: Execute E2E Tests
356362
command: |
357363
mkdir X:/ramdisk/e2e-main
358-
node tests\legacy-cli\run_e2e.js --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX --tmpdir=X:/ramdisk/e2e-main
364+
node tests\legacy-cli\run_e2e.js --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX --tmpdir=X:/ramdisk/e2e-main --package ./dist/_*.tgz
359365
- fail_fast
360366

361367
workflows:
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1+
import { join } from 'path';
2+
import glob from 'glob';
13
import { getGlobalVariable } from '../utils/env';
24
import { globalNpm, extractNpmEnv } from '../utils/process';
35
import { isPrereleaseCli } from '../utils/project';
46

57
export default async function () {
68
const testRegistry: string = getGlobalVariable('package-registry');
7-
await globalNpm(
8-
[
9-
'run',
10-
'admin',
11-
'--',
12-
'publish',
13-
'--no-versionCheck',
14-
'--no-branchCheck',
15-
`--registry=${testRegistry}`,
16-
'--tag',
17-
isPrereleaseCli() ? 'next' : 'latest',
18-
],
19-
{
20-
...extractNpmEnv(),
21-
// Also set an auth token value for the local test registry which is required by npm 7+
22-
// even though it is never actually used.
23-
'NPM_CONFIG__AUTH': 'e2e-testing',
24-
},
9+
10+
// Publish packages specified with --package
11+
await Promise.all(
12+
(getGlobalVariable('argv').package || [])
13+
.flatMap((p: string) => glob.sync(p))
14+
.map((p: string) =>
15+
globalNpm(
16+
[
17+
'publish',
18+
`--registry=${testRegistry}`,
19+
'--tag',
20+
isPrereleaseCli() ? 'next' : 'latest',
21+
join(process.cwd(), p),
22+
],
23+
{
24+
...extractNpmEnv(),
25+
// Also set an auth token value for the local test registry which is required by npm 7+
26+
// even though it is never actually used.
27+
'NPM_CONFIG__AUTH': 'e2e-testing',
28+
},
29+
),
30+
),
2531
);
2632
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ ts_library(
77
visibility = ["//visibility:public"],
88
deps = [
99
"//tests/legacy-cli/e2e/utils",
10+
"@npm//glob",
1011
],
1112
)

tests/legacy-cli/e2e_runner.ts

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Error.stackTraceLimit = Infinity;
3434
* --shard Index of this processes' shard.
3535
* --tmpdir=path Override temporary directory to use for new projects.
3636
* --yarn Use yarn as package manager.
37+
* --package=path An npm package to be published before running tests
38+
*
3739
* If unnamed flags are passed in, the list of tests will be filtered to include only those passed.
3840
*/
3941
const argv = yargsParser(process.argv.slice(2), {
@@ -49,6 +51,7 @@ const argv = yargsParser(process.argv.slice(2), {
4951
],
5052
string: ['devkit', 'glob', 'ignore', 'reuse', 'ng-tag', 'tmpdir', 'ng-version'],
5153
number: ['nb-shards', 'shard'],
54+
array: ['package'],
5255
configuration: {
5356
'dot-notation': false,
5457
'camel-case-expansion': false,

0 commit comments

Comments
 (0)