Skip to content

Commit 52f1c3b

Browse files
committed
build: WIP: run e2e legacy-cli tests under bazel
1 parent efa840e commit 52f1c3b

31 files changed

+2602
-135
lines changed

.bazelrc

+1
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,4 @@ try-import .bazelrc.user
148148
# Enable runfiles even on Windows.
149149
# Architect resolves output files from data files, and this isn't possible without runfile support.
150150
test --enable_runfiles
151+
build --enable_runfiles

.circleci/config.yml

+42-4
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ commands:
9898
- run:
9999
name: 'Setup bazel RBE remote execution'
100100
command: |
101+
sudo npm install --global @bazel/bazelisk
102+
101103
touch .bazelrc.user;
102104
# We need ensure that the same default digest is used for encoding and decoding
103105
# with openssl. Openssl versions might have different default digests which can
@@ -225,6 +227,36 @@ jobs:
225227
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"
226228
- fail_fast
227229

230+
e2e-cli-bazel:
231+
parameters:
232+
nodeversion:
233+
type: string
234+
default: *default_nodeversion
235+
snapshots:
236+
type: boolean
237+
default: false
238+
executor:
239+
name: test-executor
240+
steps:
241+
- custom_attach_workspace
242+
- browser-tools/install-chrome
243+
- setup_bazel_rbe
244+
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
245+
- run:
246+
name: Initialize Environment
247+
command: |
248+
./.circleci/env.sh
249+
- run:
250+
name: Execute CLI E2E Tests (bazel)
251+
command: bazel run //tests/legacy-cli:e2e
252+
- run:
253+
name: Execute CLI E2E Tests Subset with Yarn (bazel)
254+
command: bazel run //tests/legacy-cli:e2e.yarn
255+
- run:
256+
name: Execute CLI E2E Tests Subset with esbuild builder (bazel)
257+
command: bazel run //tests/legacy-cli:e2e.esbuild
258+
- fail_fast
259+
228260
test-browsers:
229261
executor:
230262
name: test-executor
@@ -372,13 +404,19 @@ workflows:
372404
requires:
373405
- build
374406

375-
# Bazel jobs
376-
# These jobs only really depend on Setup, but the build job is very quick to run (~35s) and
377-
# will catch any build errors before proceeding to the more lengthy and resource intensive
378407
# Bazel jobs.
379408
- test:
380409
requires:
381-
- build
410+
- setup
411+
- e2e-cli-bazel:
412+
nodeversion: '14.15'
413+
requires:
414+
- setup
415+
- e2e-cli-bazel:
416+
name: e2e-cli-node-16
417+
nodeversion: '16.10'
418+
requires:
419+
- setup
382420

383421
# Windows jobs
384422
- e2e-cli-win:

BUILD.bazel

+2
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

lib/BUILD.bazel

+15
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

+4
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');

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
"minimatch": "5.0.1",
172172
"ng-packagr": "14.0.0-next.10",
173173
"node-fetch": "^2.2.0",
174+
"npm": "6.14.15",
174175
"npm-package-arg": "9.0.2",
175176
"open": "8.4.0",
176177
"ora": "5.4.1",
@@ -219,6 +220,7 @@
219220
"webpack-subresource-integrity": "5.1.0",
220221
"yargs": "17.4.1",
221222
"yargs-parser": "21.0.1",
223+
"yarn": "^1.22.18",
222224
"zone.js": "^0.11.3"
223225
}
224226
}

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

+4-1
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

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

tests/legacy-cli/bazel_e2e_setup.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
import { join } from 'path';
4+
5+
import { IS_BAZEL, setPackages } from './e2e/utils/bazel';
6+
if (!IS_BAZEL) {
7+
throw new Error(`${__filename} must be invoked via bazel`);
8+
}
9+
10+
// When run via bazel the extra argument is a config file containing an array of test configs.
11+
// Read the config file and metadata about each package.
12+
const packages = require(process.argv[2]).map((pkg: any) => {
13+
// The path relative to this file (relative to the BUILD compiling it);
14+
const pkgPath = pkg.path;
15+
16+
// require() using relative path
17+
const packageJSON = require(`${pkgPath}/package.json`);
18+
19+
return {
20+
name: packageJSON.name,
21+
version: packageJSON.version,
22+
path: join(__dirname, pkgPath),
23+
};
24+
});
25+
26+
console.log('BAZEL_PACKAGES: ', packages);
27+
28+
// Globally persist the packages
29+
setPackages(packages);

tests/legacy-cli/bazel_runner.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
require('./bazel_e2e_setup');
3+
require('./e2e_runner');

0 commit comments

Comments
 (0)