Skip to content

Commit ec61f8a

Browse files
committed
test: run legacy-cli e2e tests via bazel
1 parent 26aed9e commit ec61f8a

19 files changed

Lines changed: 412 additions & 56 deletions

File tree

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ build:snapshot --workspace_status_command="yarn -s ng-dev release build-env-stam
9090
build:snapshot --stamp
9191
build:snapshot --//:enable_snapshot_repo_deps
9292

93+
build:e2e --workspace_status_command="yarn -s ng-dev release build-env-stamp --mode=release"
94+
build:e2e --stamp
95+
test:e2e --test_timeout=1800
96+
9397
build:local --//:enable_package_json_tar_deps
9498

9599
###############################

.circleci/dynamic_config.yml

Lines changed: 126 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ var_6: &only_pull_requests
4747
only:
4848
- /pull\/\d+/
4949

50-
var_7: &all_e2e_subsets ['npm', 'esbuild', 'yarn']
50+
# All e2e test suites
51+
var_7_subsets: &all_e2e_subsets ['npm', 'esbuild', 'yarn']
52+
var_7_build_types: &all_e2e_build_types ['e2e', 'snapshot']
5153

5254
# Executor Definitions
5355
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors
@@ -72,6 +74,16 @@ executors:
7274
working_directory: ~/ng
7375
resource_class: large
7476

77+
bazel-executor:
78+
parameters:
79+
nodeversion:
80+
type: string
81+
default: *default_nodeversion
82+
docker:
83+
- image: cimg/node:<< parameters.nodeversion >>
84+
working_directory: ~/ng
85+
resource_class: 2xlarge
86+
7587
windows-executor:
7688
# Same as https://circleci.com/orbs/registry/orb/circleci/windows, but named.
7789
working_directory: ~/ng
@@ -136,6 +148,7 @@ commands:
136148
type: env_var_name
137149
default: CIRCLE_PROJECT_REPONAME
138150
steps:
151+
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
139152
- run:
140153
name: 'Setup bazel RBE remote execution'
141154
command: |
@@ -288,15 +301,18 @@ jobs:
288301
paths:
289302
- dist/_*.tgz
290303

291-
build-bazel-e2e:
292-
executor: action-executor
304+
bazel-build:
305+
executor: bazel-executor
293306
steps:
294307
- custom_attach_workspace
295-
- run: yarn bazel build //tests/legacy-cli/...
308+
- setup_bazel_rbe
309+
- run:
310+
name: Bazel Build Packages
311+
command: yarn bazel build //...
312+
- fail_fast
296313

297-
unit-test:
298-
executor: test-executor
299-
resource_class: xlarge
314+
bazel-test:
315+
executor: bazel-executor
300316
parameters:
301317
nodeversion:
302318
type: string
@@ -329,6 +345,59 @@ jobs:
329345
no_output_timeout: 40m
330346
- fail_fast
331347

348+
bazel-e2e-tests:
349+
executor: bazel-executor
350+
parameters:
351+
build_type:
352+
type: enum
353+
enum: *all_e2e_build_types
354+
default: 'e2e'
355+
subset:
356+
type: enum
357+
enum: *all_e2e_subsets
358+
default: 'npm'
359+
steps:
360+
- custom_attach_workspace
361+
- browser-tools/install-chrome
362+
- initialize_env
363+
- setup_bazel_rbe
364+
- run: mkdir /mnt/ramdisk/e2e
365+
- run:
366+
name: Test << parameters.build_type >> << parameters.subset >>
367+
command: yarn bazel test --define=E2E_TEMP=/mnt/ramdisk/e2e --config=<< parameters.build_type >> //tests/legacy-cli:e2e.<< parameters.subset >>
368+
no_output_timeout: 40m
369+
- store_artifacts:
370+
path: dist/testlogs/tests/legacy-cli/e2e.<< parameters.subset >>
371+
- store_test_results:
372+
path: dist/testlogs/tests/legacy-cli/e2e.<< parameters.subset >>
373+
- fail_fast
374+
375+
bazel-test-browsers:
376+
executor: bazel-executor
377+
steps:
378+
- custom_attach_workspace
379+
- initialize_env
380+
- setup_bazel_rbe
381+
- run:
382+
name: Initialize Saucelabs
383+
command: setSecretVar SAUCE_ACCESS_KEY $(echo $SAUCE_ACCESS_KEY | rev)
384+
- run:
385+
name: Start Saucelabs Tunnel
386+
command: ./scripts/saucelabs/start-tunnel.sh
387+
background: true
388+
# Waits for the Saucelabs tunnel to be ready. This ensures that we don't run tests
389+
# too early without Saucelabs not being ready.
390+
- run: ./scripts/saucelabs/wait-for-tunnel.sh
391+
- run:
392+
name: E2E Saucelabs Tests
393+
command: yarn bazel test --config=saucelabs //tests/legacy-cli:e2e.saucelabs
394+
- run: ./scripts/saucelabs/stop-tunnel.sh
395+
- store_artifacts:
396+
path: dist/testlogs/tests/legacy-cli/e2e.saucelabs
397+
- store_test_results:
398+
path: dist/testlogs/tests/legacy-cli/e2e.saucelabs
399+
- fail_fast
400+
332401
snapshot_publish:
333402
executor: action-executor
334403
resource_class: medium
@@ -475,23 +544,65 @@ workflows:
475544
# These jobs only really depend on Setup, but the build job is very quick to run (~35s) and
476545
# will catch any build errors before proceeding to the more lengthy and resource intensive
477546
# Bazel jobs.
478-
- unit-test:
547+
- bazel-test:
479548
name: test-node<< matrix.nodeversion >>
480549
matrix:
481550
parameters:
482551
nodeversion: *all_nodeversion_major
483552
requires:
484-
- build
485-
486-
# Compile the e2e tests with bazel to ensure the non-runtime typescript
487-
# compilation completes succesfully.
488-
- build-bazel-e2e:
489-
requires:
490-
- build
553+
- bazel-build
491554

492555
# Windows jobs
493556
- e2e-cli-win
494557

558+
# Bazel jobs
559+
- bazel-build:
560+
requires:
561+
- setup
562+
563+
- bazel-e2e-tests:
564+
name: bazel-e2e-cli-<< matrix.subset >>
565+
matrix:
566+
parameters:
567+
subset: *all_e2e_subsets
568+
build_type: 'e2e'
569+
filters:
570+
branches:
571+
ignore:
572+
- main
573+
- /\d+\.\d+\.x/
574+
requires:
575+
- bazel-build
576+
577+
- bazel-e2e-tests:
578+
name: bazel-e2e-snapshots-<< matrix.subset >>
579+
matrix:
580+
parameters:
581+
subset: *all_e2e_subsets
582+
build_type: 'snapshot'
583+
pre-steps:
584+
- when:
585+
condition:
586+
and:
587+
- not:
588+
equal: [main, << pipeline.git.branch >>]
589+
- not: << pipeline.parameters.snapshot_changed >>
590+
steps:
591+
# Don't run snapshot E2E's unless it's on the main branch or the snapshots file has been updated.
592+
- run: circleci-agent step halt
593+
requires:
594+
- bazel-build
595+
filters:
596+
branches:
597+
only:
598+
- main
599+
# This is needed to run this steps on Renovate PRs that amend the snapshots package.json
600+
- /^pull\/.*/
601+
602+
- bazel-test-browsers:
603+
requires:
604+
- bazel-build
605+
495606
# Publish jobs
496607
- snapshot_publish:
497608
<<: *only_release_branches

BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.io/license
55
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
6+
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
67

78
package(default_visibility = ["//visibility:public"])
89

@@ -16,6 +17,14 @@ exports_files([
1617
"package.json",
1718
])
1819

20+
# Files required by e2e tests
21+
copy_to_bin(
22+
name = "dot-files",
23+
srcs = [
24+
"package.json",
25+
],
26+
)
27+
1928
# Detect if the build is running under --stamp
2029
config_setting(
2130
name = "stamp",

WORKSPACE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,10 @@ nodejs_register_toolchains(
9898
name = "node16",
9999
node_version = "16.13.1",
100100
)
101+
102+
register_toolchains(
103+
"@npm//@angular/build-tooling/bazel/git-toolchain:git_linux_toolchain",
104+
"@npm//@angular/build-tooling/bazel/git-toolchain:git_macos_x86_toolchain",
105+
"@npm//@angular/build-tooling/bazel/git-toolchain:git_macos_arm64_toolchain",
106+
"@npm//@angular/build-tooling/bazel/git-toolchain:git_windows_toolchain",
107+
)

packages/angular/cli/src/utilities/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Version {
2323
}
2424
}
2525

26-
// TODO: Convert this to use build-time version stamping after flipping the build script to use bazel
26+
// TODO(bazel): Convert this to use build-time version stamping after flipping the build script to use bazel
2727
// export const VERSION = new Version('0.0.0-PLACEHOLDER');
2828
export const VERSION = new Version(
2929
(

tests/legacy-cli/BUILD.bazel

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("//tools:defaults.bzl", "ts_library")
2+
load(":e2e.bzl", "e2e_suites")
23

34
ts_library(
45
name = "runner",
@@ -11,16 +12,25 @@ ts_library(
1112
deps = [
1213
"//packages/angular_devkit/core",
1314
"//packages/angular_devkit/core/node",
14-
"//tests/legacy-cli/e2e/assets",
1515
"//tests/legacy-cli/e2e/utils",
1616
"@npm//@types/glob",
1717
"@npm//@types/yargs-parser",
1818
"@npm//ansi-colors",
1919
"@npm//yargs-parser",
20+
],
21+
)
2022

23+
e2e_suites(
24+
name = "e2e",
25+
data = [
26+
":runner",
27+
28+
# Tests + setup
2129
# Loaded dynamically at runtime, not compiletime deps
30+
"//tests/legacy-cli/e2e/assets",
2231
"//tests/legacy-cli/e2e/setup",
2332
"//tests/legacy-cli/e2e/initialize",
2433
"//tests/legacy-cli/e2e/tests",
2534
],
35+
runner = ":e2e_runner.ts",
2636
)

0 commit comments

Comments
 (0)