Skip to content

More bazel tests #16976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7d5a39f
build: also validade BUILD.bazel files
filipesilva Apr 10, 2020
12f6fea
refactor: rename toplevel BUILD to BUILD.bazel
filipesilva Apr 10, 2020
44dc350
fix(@ngtools/webpack): export VirtualFileSystemDecorator type
filipesilva Apr 10, 2020
8d3ae1a
fix(@ngtools/webpack): remove internal markers
filipesilva Apr 10, 2020
66de588
build: don't copy root package test folders
filipesilva Apr 10, 2020
f6d626a
build: use rules_nodejs 1.6.0 features
filipesilva Apr 10, 2020
3108106
test(@angular-devkit/build-webpack): build and test with Bazel
filipesilva Apr 10, 2020
15d84f1
test(@angular-devkit/build-angular): build and test with Bazel
filipesilva Apr 10, 2020
2a9ae14
test(@angular-devkit/build-ng-packagr): build and test with Bazel
filipesilva Apr 10, 2020
43a2dd1
build: add missing npm_package_archive targets
filipesilva Apr 10, 2020
7f72c01
test(@angular/cli): add npm_integration_test
filipesilva Apr 10, 2020
58e59e4
build: update yarn lock
filipesilva Apr 10, 2020
cea0326
test: remove non-bazel test setup
filipesilva Apr 10, 2020
59744c0
ci: use xlarge for bazel tests
filipesilva Apr 10, 2020
3185ce8
build: add webdriver-manager update & ngcc to postinstall
gregmagolan Apr 16, 2020
903839a
docs: add bazel jasmine_node_test debug information
filipesilva Apr 16, 2020
c73a378
build: run tests depending on webdriver-manager locally
gregmagolan Apr 16, 2020
ed18067
build: use no-remote-exec tag so test still runs in sandbox
gregmagolan Apr 16, 2020
35834f4
ci: update required status checks
filipesilva Apr 27, 2020
e94f786
build: use @bazel/bazelisk
filipesilva Apr 27, 2020
903d44f
build: use ts_library macro with common defaults
filipesilva Apr 27, 2020
03b5776
build: add rbe_ubuntu1604-angular docker permissions
filipesilva Apr 27, 2020
cd33c21
build: exclude nested node_modules laid out by yarn workspaces from a…
gregmagolan Apr 28, 2020
cbead4e
ci: add reasoning behind bazel jobs depending on build
filipesilva Apr 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ build:remote --bes_results_url="https://source.cloud.google.com/results/invocati
# Set remote caching settings
build:remote --remote_accept_cached=true

# Force remote executions to consider the entire run as linux.
# This is required for OSX cross-platform RBE.
build:remote --cpu=k8
build:remote --host_cpu=k8

###############################
# NodeJS rules settings
# These settings are required for rules_nodejs
Expand Down
3 changes: 3 additions & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2.1.1
# [NB: this comment has to be after the first line, see https://github.com/bazelbuild/bazelisk/issues/117]
# When updating the Bazel version you also need to update the RBE toolchains version in package.bzl
76 changes: 22 additions & 54 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,27 +156,6 @@ jobs:
- custom_attach_workspace
- run: yarn validate --ci

test:
executor: action-executor
steps:
- custom_attach_workspace
- run: yarn test --full

test-large:
parameters:
ve:
type: boolean
default: false
glob:
type: string
default: ""
executor: test-executor
parallelism: 4
steps:
- custom_attach_workspace
- run: yarn webdriver-update
- run: yarn test-large --full <<# parameters.ve >>--ve<</ parameters.ve >> <<# parameters.glob >>--glob="<< parameters.glob >>"<</ parameters.glob >> --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX}

e2e-cli:
parameters:
ve:
Expand Down Expand Up @@ -242,26 +221,23 @@ jobs:
- custom_attach_workspace
- run: yarn build

# This is where we put all the misbehaving and flaky tests so we can fine-tune their conditions
# and rerun them faster.
flake-jail:
test:
executor: test-executor
resource_class: medium
steps:
- custom_attach_workspace
- run: yarn webdriver-update
- run: yarn test-large --full --flakey --ve
- run: yarn test-large --full --flakey

build-bazel:
executor: action-executor
resource_class: large
resource_class: xlarge
steps:
- custom_attach_workspace
- setup_bazel_rbe
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- run: yarn bazel:test

integration:
executor: test-executor
resource_class: xlarge
steps:
- custom_attach_workspace
- run:
command: yarn bazel:integration

snapshot_publish:
executor: action-executor
resource_class: medium
Expand Down Expand Up @@ -322,7 +298,6 @@ jobs:
steps:
- custom_attach_workspace
- setup_windows
- run: yarn test --full
# Run partial e2e suite on PRs only. Master will run the full e2e suite with sharding.
- run: if (Test-Path env:CIRCLE_PR_NUMBER) { node tests\legacy-cli\run_e2e.js "--glob=tests/{basic,ivy}/**" }

Expand Down Expand Up @@ -353,21 +328,6 @@ workflows:
branches:
ignore:
- /docs-preview/
- build-bazel:
requires:
- build
- test:
requires:
- build
- test-large:
requires:
- build
- test-large:
name: test-large-ve
ve: true
glob: "packages/angular_devkit/@(build_angular|build_ng_packagr)/@(src|test)/@(build|browser)/*_spec_large.ts"
requires:
- build
- e2e-cli:
post-steps:
- store_artifacts:
Expand Down Expand Up @@ -408,7 +368,15 @@ workflows:
- test-browsers:
requires:
- build
- flake-jail:

# Bazel jobs
# These jobs only really depend on Setup, but the build job is very quick to run (~35s) and
# will catch any build errors before proceeding to the more lengthy and resource intensive
# Bazel jobs.
- test:
requires:
- build
- integration:
requires:
- build

Expand All @@ -423,8 +391,8 @@ workflows:
- build
- test-win:
requires:
- setup-and-build-win
- test
- setup-and-build-win
- e2e-cli-win:
<<: *only_release_branches
requires:
Expand All @@ -435,13 +403,13 @@ workflows:
- snapshot_publish:
<<: *only_release_branches
requires:
- test
- build
- test
- e2e-cli
- publish:
requires:
- test
- build
- test
- e2e-cli
- snapshot_publish
filters:
Expand Down
4 changes: 1 addition & 3 deletions .github/angular-robot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ merge:
# list of PR statuses that need to be successful
requiredStatuses:
- "ci/circleci: build"
- "ci/circleci: build-bazel"
- "ci/circleci: setup"
- "ci/circleci: setup-and-build-win"
- "ci/circleci: lint"
- "ci/circleci: validate"
- "ci/circleci: test"
- "ci/circleci: test-win"
- "ci/circleci: test-large"
- "ci/circleci: test-large-ve"
- "ci/circleci: integration"
- "ci/circleci: e2e-cli"
- "ci/circleci: e2e-cli-ve"
- "ci/circleci: test-browsers"
Expand Down
File renamed without changes.
11 changes: 5 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ Try running `yarn bazel` instead.
# - 0.32.1 remove override of @bazel/tsetse & exclude typescript lib declarations in node_module_library transitive_declarations
# - 0.32.2 resolves bug in @bazel/hide-bazel-files postinstall step
# - 0.34.0 introduces protractor rule
check_rules_nodejs_version(minimum_version_string = "0.34.0")
check_rules_nodejs_version(minimum_version_string = "1.5.0")

# Setup the Node.js toolchain
node_repositories(
node_repositories = {
"10.16.0-darwin_amd64": ("node-v10.16.0-darwin-x64.tar.gz", "node-v10.16.0-darwin-x64", "6c009df1b724026d84ae9a838c5b382662e30f6c5563a0995532f2bece39fa9c"),
"10.16.0-linux_amd64": ("node-v10.16.0-linux-x64.tar.xz", "node-v10.16.0-linux-x64", "1827f5b99084740234de0c506f4dd2202a696ed60f76059696747c34339b9d48"),
"10.16.0-windows_amd64": ("node-v10.16.0-win-x64.zip", "node-v10.16.0-win-x64", "aa22cb357f0fb54ccbc06b19b60e37eefea5d7dd9940912675d3ed988bf9a059"),
"12.14.1-darwin_amd64": ("node-v12.14.1-darwin-x64.tar.gz", "node-v12.14.1-darwin-x64", "0be10a28737527a1e5e3784d3ad844d742fe8b0718acd701fd48f718fd3af78f"),
"12.14.1-linux_amd64": ("node-v12.14.1-linux-x64.tar.xz", "node-v12.14.1-linux-x64", "07cfcaa0aa9d0fcb6e99725408d9e0b07be03b844701588e3ab5dbc395b98e1b"),
"12.14.1-windows_amd64": ("node-v12.14.1-win-x64.zip", "node-v12.14.1-win-x64", "1f96ccce3ba045ecea3f458e189500adb90b8bc1a34de5d82fc10a5bf66ce7e3"),
},
node_version = "10.16.0",
node_version = "12.14.1",
package_json = ["//:package.json"],
yarn_repositories = {
"1.22.4": ("yarn-v1.22.4.tar.gz", "yarn-v1.22.4", "bc5316aa110b2f564a71a3d6e235be55b98714660870c5b6b2d2d3f12587fb58"),
Expand All @@ -75,7 +75,6 @@ yarn_install(
"//:tools/yarn/check-yarn.js",
],
package_json = "//:package.json",
symlink_node_modules = False,
yarn_lock = "//:yarn.lock",
)

Expand Down
21 changes: 21 additions & 0 deletions docs/process/bazel.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ Since the requirement is quite lax on Linux but quite strict on windows, what en
happening is that lack of `require.resolve` calls go unnoticed until someone tries to run
things on Windows, at which point it breaks.

## Debugging jasmine_node_test

On Linux, Bazel tests will run under a sandbox for isolation.
You can turn off this sandbox by adding the [`local = True`](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes-tests) attribute to the rule.

Then you will find the intermediate test files in `bazel-out/k8-fastbuild/bin`, followed by the test target path.

Tests that are sharded, via the `shard_count` attribute, can fail if you reduce the number of tests or focus only a few.
This will cause some shards to execute 0 tests, which makes the exit with an error code.


Tests that are marked as flaky, via the `flaky` attribute, will repeat when they fail.
This will cause any focused test to be repeated multiple time, since the presence of focused tests
causes jasmine to exit with a non-zero exit code.

While testing, you can remove the `shard_count` attribute to prevent sharding and the `flaky`
attribute to prevent repetition.

NB: For a few tests, sandbox is required as otherwise the rules_nodejs linker symlinks will conflict
with the yarn workspace symlinks in node_modules.

## Issues

1. Yarn workspaces is not compatible with Bazel-managed deps
Expand Down
10 changes: 6 additions & 4 deletions etc/api/BUILD → etc/api/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ load("@npm_ts_api_guardian//:index.bzl", "ts_api_guardian_test")
),
# We don't want to analyse these exports nor add them to the golden files
# in most cases it's because Ts API Guardian doesn't support Symbol Aliases.
# Note: $ must be escaped to $$ because these patterns will be executed by shell
# and $ has a special meaning there.
strip_export_pattern = [
# @angular-devkit/architect
"^BuilderProgressState$",
"^BuilderProgressState$$",
# @angular-devkit/schematics
"^workflow$",
"^formats$",
"^workflow$$",
"^formats$$",
# @angular-devkit/build-optimizer
"^buildOptimizerLoader$",
"^buildOptimizerLoader$$",
],
# At the moment using this will ignore a big change
use_angular_tag_rules = False,
Expand Down
2 changes: 1 addition & 1 deletion etc/api/angular_devkit/architect/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export interface BuilderContext {
workspaceRoot: string;
addTeardown(teardown: () => (Promise<void> | void)): void;
getBuilderNameForTarget(target: Target): Promise<string>;
getProjectMetadata(target: Target): Promise<json.JsonObject>;
getProjectMetadata(projectName: string): Promise<json.JsonObject>;
getProjectMetadata(target: Target): Promise<json.JsonObject>;
getTargetOptions(target: Target): Promise<json.JsonObject>;
reportProgress(current: number, total?: number, status?: string): void;
reportRunning(): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out

# dependencies
/node_modules

# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json

# IDEs and editors
/.idea
.project
Expand All @@ -23,20 +29,18 @@
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# e2e
/e2e/*.js
/e2e/*.map

# System Files
.DS_Store
Thumbs.db
54 changes: 54 additions & 0 deletions integration/angular_cli/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
load("//tools/npm_integration_test:npm_integration_test.bzl", "npm_integration_test")

filegroup(
name = "angular_cli_sources",
srcs = glob(
include = ["**/*"],
exclude = [
"node_modules/**",
".yarn_local_cache/**",
],
),
)

npm_integration_test(
name = "angular_cli_test",
check_npm_packages = [
"@angular/cli",
"@angular-devkit/architect",
"@angular-devkit/build-angular",
"@angular-devkit/build-webpack",
"@angular-devkit/build-optimizer",
"@angular-devkit/core",
"@angular-devkit/schematics",
"@schematics/angular",
"@schematics/update",
],
commands = [
# Workaround https://github.com/yarnpkg/yarn/issues/2165
# Yarn will cache file://dist URIs and not update
"rm -rf ./.yarn_local_cache",
"mkdir .yarn_local_cache",
"patch-package-json",
"$(rootpath @nodejs//:yarn_bin) install --cache-folder ./.yarn_local_cache",
"$(rootpath @nodejs//:yarn_bin) --cache-folder ./.yarn_local_cache ng version",
"rm -rf ./.yarn_local_cache",
],
data = [
"@nodejs//:yarn_bin",
"@nodejs//:yarn_files",
],
npm_packages = {
"//packages/angular/cli:npm_package_archive": "@angular/cli",
"//packages/angular_devkit/architect:npm_package_archive": "@angular-devkit/architect",
"//packages/angular_devkit/build_angular:npm_package_archive": "@angular-devkit/build-angular",
"//packages/angular_devkit/core:npm_package_archive": "@angular-devkit/core",
"//packages/angular_devkit/schematics:npm_package_archive": "@angular-devkit/schematics",
"//packages/angular_devkit/build_optimizer:npm_package_archive": "@angular-devkit/build-optimizer",
"//packages/angular_devkit/build_webpack:npm_package_archive": "@angular-devkit/build-webpack",
"//packages/ngtools/webpack:npm_package_archive": "@ngtools/webpack",
"//packages/schematics/angular:npm_package_archive": "@schematics/angular",
"//packages/schematics/update:npm_package_archive": "@schematics/update",
},
test_files = ":angular_cli_sources",
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HelloWorldApp
# IntegrationProject

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.7.0-beta.1.
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.

## Development server

Expand All @@ -12,7 +12,7 @@ Run `ng generate component component-name` to generate a new component. You can

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.

## Running unit tests

Expand Down
Loading