Skip to content

Commit 13d21c2

Browse files
committed
test: WIP - update legecy e2e test to bazel
1 parent 9f35913 commit 13d21c2

29 files changed

Lines changed: 644 additions & 37 deletions

.bazelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ build --symlink_prefix=dist/
3030
build --nowatchfs
3131

3232
# Turn off legacy external runfiles
33+
build --nolegacy_external_runfiles
3334
run --nolegacy_external_runfiles
3435
test --nolegacy_external_runfiles
3536

@@ -148,3 +149,7 @@ try-import .bazelrc.user
148149
# Enable runfiles even on Windows.
149150
# Architect resolves output files from data files, and this isn't possible without runfile support.
150151
test --enable_runfiles
152+
build --enable_runfiles
153+
154+
# Fixes use of npm paths with spaces such as some within the puppeteer module
155+
build --experimental_inprocess_symlink_creation

.circleci/config.yml

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,36 @@ jobs:
223223
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-esbuild --glob="{tests/basic/**,tests/build/prod-build.ts}" --ignore="tests/basic/{environment,rebuild,serve,scripts-array}.ts"
224224
- fail_fast
225225

226+
e2e-cli-bazel:
227+
parameters:
228+
nodeversion:
229+
type: string
230+
default: *default_nodeversion
231+
snapshots:
232+
type: boolean
233+
default: false
234+
executor:
235+
name: test-executor
236+
steps:
237+
- custom_attach_workspace
238+
- browser-tools/install-chrome
239+
- setup_bazel_rbe
240+
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
241+
- run:
242+
name: Initialize Environment
243+
command: |
244+
./.circleci/env.sh
245+
- run:
246+
name: Execute CLI E2E Tests (bazel)
247+
command: yarn bazel run //tests/legacy-cli:e2e
248+
- run:
249+
name: Execute CLI E2E Tests Subset with Yarn (bazel)
250+
command: yarn bazel run //tests/legacy-cli:e2e.yarn
251+
- run:
252+
name: Execute CLI E2E Tests Subset with esbuild builder (bazel)
253+
command: yarn bazel run //tests/legacy-cli:e2e.esbuild
254+
- fail_fast
255+
226256
test-browsers:
227257
executor:
228258
name: test-executor
@@ -248,6 +278,34 @@ jobs:
248278
- run: ./scripts/saucelabs/stop-tunnel.sh
249279
- fail_fast
250280

281+
test-browsers-bazel:
282+
executor:
283+
name: test-executor
284+
environment:
285+
E2E_BROWSERS: true
286+
resource_class: medium
287+
steps:
288+
- custom_attach_workspace
289+
- browser-tools/install-chrome
290+
- setup_bazel_rbe
291+
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
292+
- run:
293+
name: Initialize Environment
294+
command: ./.circleci/env.sh
295+
- run:
296+
name: Initialize Saucelabs
297+
command: setSecretVar SAUCE_ACCESS_KEY $(echo $SAUCE_ACCESS_KEY | rev)
298+
- run:
299+
name: Start Saucelabs Tunnel
300+
command: ./scripts/saucelabs/start-tunnel.sh
301+
background: true
302+
# Waits for the Saucelabs tunnel to be ready. This ensures that we don't run tests
303+
# too early without Saucelabs not being ready.
304+
- run: ./scripts/saucelabs/wait-for-tunnel.sh
305+
- run: yarn bazel run //tests/legacy-cli:e2e.browsers
306+
- run: ./scripts/saucelabs/stop-tunnel.sh
307+
- fail_fast
308+
251309
build:
252310
executor: action-executor
253311
steps:
@@ -263,7 +321,7 @@ jobs:
263321
- setup_bazel_rbe
264322
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
265323
- run:
266-
command: yarn bazel:test
324+
command: yarn bazel test //packages/...
267325
# This timeout provides time for the actual tests to timeout and report status
268326
# instead of CircleCI stopping the job without test failure information.
269327
no_output_timeout: 40m
@@ -370,13 +428,22 @@ workflows:
370428
requires:
371429
- build
372430

373-
# Bazel jobs
374-
# These jobs only really depend on Setup, but the build job is very quick to run (~35s) and
375-
# will catch any build errors before proceeding to the more lengthy and resource intensive
376431
# Bazel jobs.
377432
- test:
378433
requires:
379-
- build
434+
- setup
435+
- test-browsers-bazel:
436+
requires:
437+
- setup
438+
- e2e-cli-bazel:
439+
nodeversion: '14.17'
440+
requires:
441+
- setup
442+
# - e2e-cli-bazel:
443+
# name: e2e-cli-bazel-node-16
444+
# nodeversion: '16.10'
445+
# requires:
446+
# - setup
380447

381448
# Windows jobs
382449
- e2e-cli-win:

BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ exports_files([
1313
"tsconfig.json", # @external
1414
"tsconfig-test.json", # @external
1515
"tsconfig-build.json", # @external
16+
".monorepo.json",
1617
"package.json",
18+
".gitignore",
1719
])
1820

1921
# Detect if the build is running under --stamp

WORKSPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ yarn_install(
6868
# 1. Missing Windows support currently.
6969
# 2. Incompatibilites with the `ts_library` rule.
7070
exports_directories_only = False,
71+
# TODO: exports_directories_only=True, will get errors about files with spaces, delete those in a package.json postinstall
72+
# OR set https://docs.bazel.build/versions/main/command-line-reference.html#flag--experimental_inprocess_symlink_creation which might solve it
7173
package_json = "//:package.json",
7274
# We prefer to symlink the `node_modules` to only maintain a single install.
7375
# See https://github.com/angular/dev-infra/pull/446#issuecomment-1059820287 for details.

lib/BUILD.bazel

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
load("//tools:defaults.bzl", "ts_library")
2+
3+
ts_library(
4+
name = "lib",
5+
srcs = ["packages.ts"],
6+
data = [
7+
"//:.monorepo.json",
8+
],
9+
visibility = ["//visibility:public"],
10+
deps = [
11+
"//packages/angular_devkit/core",
12+
"@npm//@types/node",
13+
"@npm//typescript",
14+
],
15+
)

lib/bootstrap-local.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ const os = require('os');
2020
const path = require('path');
2121
const ts = require('typescript');
2222

23+
if (process.env.BAZEL_TARGET) {
24+
throw new Error(`${__filename} should not be used when executing under bazel`);
25+
}
26+
2327
const tmpRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'angular-devkit-'));
2428

2529
debugLocal('starting bootstrap local');

lib/packages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ const pattern =
148148
const excludeRe = new RegExp(pattern);
149149

150150
// Find all the package.json that aren't excluded from tsconfig.
151+
// TODO(bazel): do not traverse source/cwd directories for this.
151152
const packageJsonPaths = [
152153
..._findPrimaryPackageJsonFiles(path.join(__dirname, '..', 'packages'), excludeRe),
153154
];

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
]
6060
},
6161
"resolutions": {
62-
"**/ajv-formats/ajv": "8.11.0"
62+
"**/ajv-formats/ajv": "8.11.0",
63+
"**/webdriver-manager": "^12.1.8"
6364
},
6465
"devDependencies": {
6566
"@ampproject/remapping": "2.2.0",
@@ -213,6 +214,7 @@
213214
"typescript": "4.7.1-rc",
214215
"verdaccio": "5.10.2",
215216
"verdaccio-auth-memory": "^10.0.0",
217+
"webdriver-manager": "^12.1.8",
216218
"webpack": "5.72.1",
217219
"webpack-dev-middleware": "5.3.1",
218220
"webpack-dev-server": "4.9.0",

packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ ts_library(
1717
name = "TypeScript",
1818
srcs = ["lib/typescript.d.ts"],
1919
data = ["lib/typescript.js"],
20-
visibility = ["//packages/schematics/angular:__subpackages__"],
20+
visibility = [
21+
"//packages/schematics/angular:__subpackages__",
22+
"//tests/legacy-cli:__subpackages__",
23+
],
2124
)

tests/legacy-cli/BUILD.bazel

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
load(":cli_integration_test.bzl", "cli_integration_test")
2+
load("//tools:defaults.bzl", "ts_library")
3+
4+
# bazel query --output=label "kind('pkg_npm', //packages/...)"
5+
TESTED_PACKAGES = [
6+
"//packages/schematics/angular:npm_package",
7+
"//packages/ngtools/webpack:npm_package",
8+
"//packages/angular_devkit/schematics_cli:npm_package",
9+
"//packages/angular_devkit/schematics:npm_package",
10+
"//packages/angular_devkit/core:npm_package",
11+
"//packages/angular_devkit/build_webpack:npm_package",
12+
"//packages/angular_devkit/build_angular:npm_package",
13+
# this is private so don't use here
14+
# "//packages/angular_devkit/benchmark:npm_package",
15+
"//packages/angular_devkit/architect_cli:npm_package",
16+
"//packages/angular_devkit/architect:npm_package",
17+
"//packages/angular/pwa:npm_package",
18+
"//packages/angular/cli:npm_package",
19+
]
20+
21+
ts_library(
22+
name = "runner",
23+
testonly = True,
24+
srcs = glob(["**/*.ts"]),
25+
data = [
26+
"verdaccio.yaml",
27+
"verdaccio_auth.yaml",
28+
],
29+
deps = [
30+
"//packages/angular_devkit/core",
31+
"//packages/angular_devkit/core/node",
32+
"//tests/legacy-cli/e2e/assets",
33+
"//tests/legacy-cli/e2e/utils",
34+
"@npm//@types/glob",
35+
"@npm//@types/yargs-parser",
36+
"@npm//ansi-colors",
37+
"@npm//yargs-parser",
38+
39+
# Loaded dynamically at runtime, not compiletime deps
40+
"//tests/legacy-cli/e2e/setup",
41+
"//tests/legacy-cli/e2e/tests",
42+
],
43+
)
44+
45+
# TODO(bazel): run e2e tests on node14+16, npm+yarn+esbuild
46+
47+
cli_integration_test(
48+
name = "e2e",
49+
data = [
50+
# Test runner
51+
":runner",
52+
53+
# Runtime deps
54+
# TODO: not needed when no longer compiling inline?
55+
"//:.gitignore",
56+
"//:package.json",
57+
"//:tsconfig.json",
58+
59+
# Runtime deps of everything
60+
# TODO: do this dynamically within cli_integration_test, for now for simplicity
61+
# just put every potential runtime dep.
62+
#
63+
# > cat `find packages/ | grep BUILD` | grep "@npm" | grep -v "@types" | sed -e 's/ //g' | sed -e 's/#.*//g' | sort -u
64+
"@npm//@ampproject/remapping",
65+
"@npm//@angular/animations",
66+
"@npm//@angular/common",
67+
"@npm//@angular/compiler",
68+
"@npm//@angular/compiler-cli",
69+
"@npm//@angular/core",
70+
"@npm//@angular/localize",
71+
"@npm//@angular/material",
72+
"@npm//@angular/platform-browser",
73+
"@npm//@angular/platform-browser-dynamic",
74+
"@npm//@angular/platform-server",
75+
"@npm//@angular/router",
76+
"@npm//@angular/service-worker",
77+
"@npm//@babel/core",
78+
"@npm//@babel/generator",
79+
"@npm//@babel/helper-annotate-as-pure",
80+
"@npm//@babel/plugin-proposal-async-generator-functions",
81+
"@npm//@babel/plugin-transform-async-to-generator",
82+
"@npm//@babel/plugin-transform-runtime",
83+
"@npm//@babel/preset-env",
84+
"@npm//@babel/runtime",
85+
"@npm//@babel/template",
86+
"@npm//@discoveryjs/json-ext",
87+
"@npm//@yarnpkg/lockfile",
88+
"@npm//ajv",
89+
"@npm//ajv-formats",
90+
"@npm//ansi-colors",
91+
"@npm//babel-loader",
92+
"@npm//babel-plugin-istanbul",
93+
"@npm//bootstrap",
94+
"@npm//browserslist",
95+
"@npm//cacache",
96+
"@npm//chokidar",
97+
"@npm//copy-webpack-plugin",
98+
"@npm//critters",
99+
"@npm//css-loader",
100+
"@npm//esbuild",
101+
"@npm//esbuild-wasm",
102+
"@npm//express",
103+
"@npm//font-awesome",
104+
"@npm//glob",
105+
"@npm//http-proxy",
106+
"@npm//https-proxy-agent",
107+
"@npm//ini",
108+
"@npm//inquirer",
109+
"@npm//jasmine",
110+
"@npm//jasmine-spec-reporter",
111+
"@npm//jquery",
112+
"@npm//jsonc-parser",
113+
"@npm//karma",
114+
"@npm//karma-chrome-launcher",
115+
"@npm//karma-coverage",
116+
"@npm//karma-jasmine",
117+
"@npm//karma-jasmine-html-reporter",
118+
"@npm//karma-source-map-support",
119+
"@npm//less",
120+
"@npm//less-loader",
121+
"@npm//license-webpack-plugin",
122+
"@npm//loader-utils",
123+
"@npm//magic-string",
124+
"@npm//mini-css-extract-plugin",
125+
"@npm//minimatch",
126+
"@npm//ng-packagr",
127+
"@npm//node-fetch",
128+
"@npm//npm",
129+
"@npm//npm-package-arg",
130+
"@npm//open",
131+
"@npm//ora",
132+
"@npm//pacote",
133+
"@npm//parse5-html-rewriting-stream",
134+
"@npm//pidtree",
135+
"@npm//pidusage",
136+
"@npm//piscina",
137+
"@npm//popper.js",
138+
"@npm//postcss",
139+
"@npm//postcss-import",
140+
"@npm//postcss-loader",
141+
"@npm//postcss-preset-env",
142+
"@npm//prettier",
143+
"@npm//protractor",
144+
"@npm//puppeteer",
145+
"@npm//regenerator-runtime",
146+
"@npm//resolve-url-loader",
147+
"@npm//rxjs",
148+
"@npm//sass",
149+
"@npm//sass-loader",
150+
"@npm//semver",
151+
"@npm//source-map",
152+
"@npm//source-map-loader",
153+
"@npm//source-map-support",
154+
"@npm//stylus",
155+
"@npm//stylus-loader",
156+
"@npm//symbol-observable",
157+
"@npm//terser",
158+
"@npm//text-table",
159+
"@npm//tree-kill",
160+
"@npm//ts-node",
161+
"@npm//tslib",
162+
"@npm//typescript",
163+
"@npm//webpack",
164+
"@npm//webpack-dev-middleware",
165+
"@npm//webpack-dev-server",
166+
"@npm//webpack-merge",
167+
"@npm//webpack-subresource-integrity",
168+
"@npm//yargs",
169+
"@npm//yargs-parser",
170+
"@npm//yarn",
171+
"@npm//zone.js",
172+
] + TESTED_PACKAGES, # TODO(bazel): required for package discovery in lib/packages.ts
173+
entry_point = ":bazel_runner.js",
174+
# Pass the archive (.tar) of the packages to avoid sandbox symlinks within
175+
# the npm package directory.
176+
packages = [("%s_archive" % p) for p in TESTED_PACKAGES],
177+
shard_count = 1,
178+
)

0 commit comments

Comments
 (0)