Skip to content

Commit 71cf56d

Browse files
committed
build: update bazel dependencies and configuration
This leverages the configuration from FW where possible. Bazel updated to 28.1 Rules for nodejs/typescript/karma/jasmine updated to 0.35.0
1 parent efd1c48 commit 71cf56d

File tree

6 files changed

+499
-190
lines changed

6 files changed

+499
-190
lines changed

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
.git
12
dist
23
node_modules

.bazelrc

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,122 @@
22
# running as daemons, and cache SourceFile AST's to reduce parse time.
33
build --strategy=TypeScriptCompile=worker
44

5-
# Performance: avoid stat'ing input files
6-
build --watchfs
5+
# Enable debugging tests with --config=debug
6+
test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test_strategy=exclusive --test_timeout=9999 --nocache_test_results
77

8+
###############################
9+
# Filesystem interactions #
10+
###############################
11+
12+
# Create symlinks in the project:
13+
# - dist/bin for outputs
14+
# - dist/testlogs, dist/genfiles
15+
# - bazel-out
16+
# NB: bazel-out should be excluded from the editor configuration.
17+
# The checked-in /.vscode/settings.json does this for VSCode.
18+
# Other editors may require manual config to ignore this directory.
19+
# In the past, we say a problem where VSCode traversed a massive tree, opening file handles and
20+
# eventually a surprising failure with auto-discovery of the C++ toolchain in
21+
# MacOS High Sierra.
22+
# See https://github.com/bazelbuild/bazel/issues/4603
23+
build --symlink_prefix=dist/
24+
25+
# Disable watchfs as it causes tests to be flaky on Windows
26+
# https://github.com/angular/angular/issues/29541
27+
build --nowatchfs
28+
29+
# Turn off legacy external runfiles
30+
run --nolegacy_external_runfiles
31+
test --nolegacy_external_runfiles
32+
33+
# Turn on --incompatible_strict_action_env which was on by default
34+
# in Bazel 0.21.0 but turned off again in 0.22.0. Follow
35+
# https://github.com/bazelbuild/bazel/issues/7026 for more details.
36+
# This flag is needed to so that the bazel cache is not invalidated
37+
# when running bazel via `yarn bazel`.
38+
# See https://github.com/angular/angular/issues/27514.
39+
build --incompatible_strict_action_env
40+
run --incompatible_strict_action_env
41+
test --incompatible_strict_action_env
42+
43+
###############################
44+
# Saucelabs support #
45+
# Turn on these settings with #
46+
# --config=saucelabs #
47+
###############################
48+
49+
# Expose SauceLabs environment to actions
50+
# These environment variables are needed by
51+
# web_test_karma to run on Saucelabs
52+
test:saucelabs --action_env=SAUCE_USERNAME
53+
test:saucelabs --action_env=SAUCE_ACCESS_KEY
54+
test:saucelabs --action_env=SAUCE_READY_FILE
55+
test:saucelabs --action_env=SAUCE_PID_FILE
56+
test:saucelabs --action_env=SAUCE_TUNNEL_IDENTIFIER
57+
test:saucelabs --define=KARMA_WEB_TEST_MODE=SL_REQUIRED
58+
59+
###############################
60+
# Release support #
61+
# Turn on these settings with #
62+
# --config=release #
63+
###############################
64+
65+
# Releases should always be stamped with version control info
66+
# This command assumes node on the path and is a workaround for
67+
# https://github.com/bazelbuild/bazel/issues/4802
68+
build:release --workspace_status_command="node ./tools/bazel_stamp_vars.js"
69+
70+
###############################
71+
# Output #
72+
###############################
73+
74+
# A more useful default output mode for bazel query
75+
# Prints eg. "ng_module rule //foo:bar" rather than just "//foo:bar"
76+
query --output=label_kind
77+
78+
# By default, failing tests don't print any output, it goes to the log file
879
test --test_output=errors
980

81+
################################
82+
# Settings for CircleCI #
83+
################################
84+
85+
# Bazel flags for CircleCI are in /.circleci/bazel.rc
86+
87+
###############################
88+
# NodeJS rules settings
89+
# These settings are required for rules_nodejs
90+
###############################
91+
92+
# Turn on managed directories feature in Bazel
93+
# This allows us to avoid installing a second copy of node_modules
94+
common --experimental_allow_incremental_repository_updates
95+
96+
# This option is changed to true in Bazel 0.27 and exposes a possible
97+
# regression in Bazel 0.27.0.
98+
# Error observed is in npm_package target `//packages/common/locales:package`:
99+
# ```
100+
# ERROR: /home/circleci/ng/packages/common/locales/BUILD.bazel:13:1: Assembling
101+
# npm package packages/common/locales/package failed: No usable spawn strategy found
102+
# for spawn with mnemonic SkylarkAction. Your --spawn_strategyor --strategy flags
103+
# are probably too strict. Visit https://github.com/bazelbuild/bazel/issues/7480 for
104+
# migration advises
105+
# ```
106+
# Suspect is https://github.com/bazelbuild/rules_nodejs/blob/master/internal/npm_package/npm_package.bzl#L75-L82:
107+
# ```
108+
# execution_requirements = {
109+
# # Never schedule this action remotely because it's not computationally expensive.
110+
# # It just copies files into a directory; it's not worth copying inputs and outputs to a remote worker.
111+
# # Also don't run it in a sandbox, because it resolves an absolute path to the bazel-out directory
112+
# # allowing the .pack and .publish runnables to work with no symlink_prefix
113+
# # See https://github.com/bazelbuild/rules_nodejs/issues/187
114+
# "local": "1",
115+
# },
116+
# ```
117+
build --incompatible_list_based_execution_strategy_selection=false
118+
test --incompatible_list_based_execution_strategy_selection=false
119+
run --incompatible_list_based_execution_strategy_selection=false
120+
10121
################################
11122
# Remote Execution Setup #
12123
################################

WORKSPACE

Lines changed: 69 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,80 @@
1-
workspace(name = "angular_cli")
1+
workspace(
2+
name = "angular_cli",
3+
managed_directories = {"@npm": ["node_modules"]},
4+
)
25

3-
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
46
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
7+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
58

69
http_archive(
710
name = "build_bazel_rules_nodejs",
8-
sha256 = "fb87ed5965cef93188af9a7287511639403f4b0da418961ce6defb9dcf658f51",
9-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.27.7/rules_nodejs-0.27.7.tar.gz"],
11+
# patch_args = ["-p1"],
12+
# Patch https://github.com/bazelbuild/rules_nodejs/pull/903
13+
# patches = ["//tools:rollup_bundle_commonjs_ignoreGlobal.patch"],
14+
sha256 = "6625259f9f77ef90d795d20df1d0385d9b3ce63b6619325f702b6358abb4ab33",
15+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.35.0/rules_nodejs-0.35.0.tar.gz"],
1016
)
1117

1218
# We use protocol buffers for the Build Event Protocol
1319
git_repository(
1420
name = "com_google_protobuf",
1521
commit = "beaeaeda34e97a6ff9735b33a66e011102ab506b",
1622
remote = "https://github.com/protocolbuffers/protobuf",
23+
shallow_since = "1559159889 -0400",
1724
)
1825

1926
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
2027

2128
protobuf_deps()
2229

23-
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install")
24-
25-
# 0.18.0 is needed for .bazelignore
26-
check_bazel_version(minimum_bazel_version = "0.18.0")
30+
# Check the bazel version and download npm dependencies
31+
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "check_rules_nodejs_version", "node_repositories", "yarn_install")
32+
33+
# Bazel version must be at least the following version because:
34+
# - 0.26.0 managed_directories feature added which is required for nodejs rules 0.30.0
35+
# - 0.27.0 has a fix for managed_directories after `rm -rf node_modules`
36+
check_bazel_version(
37+
message = """
38+
You no longer need to install Bazel on your machine.
39+
Angular has a dependency on the @bazel/bazel package which supplies it.
40+
Try running `yarn bazel` instead.
41+
(If you did run that, check that you've got a fresh `yarn install`)
42+
""",
43+
minimum_bazel_version = "0.27.0",
44+
)
2745

46+
# The NodeJS rules version must be at least the following version because:
47+
# - 0.15.2 Re-introduced the prod_only attribute on yarn_install
48+
# - 0.15.3 Includes a fix for the `jasmine_node_test` rule ignoring target tags
49+
# - 0.16.8 Supports npm installed bazel workspaces
50+
# - 0.26.0 Fix for data files in yarn_install and npm_install
51+
# - 0.27.12 Adds NodeModuleSources provider for transtive npm deps support
52+
# - 0.30.0 yarn_install now uses symlinked node_modules with new managed directories Bazel 0.26.0 feature
53+
# - 0.31.1 entry_point attribute of nodejs_binary & rollup_bundle is now a label
54+
# - 0.32.0 yarn_install and npm_install no longer puts build files under symlinked node_modules
55+
# - 0.32.1 remove override of @bazel/tsetse & exclude typescript lib declarations in node_module_library transitive_declarations
56+
# - 0.32.2 resolves bug in @bazel/hide-bazel-files postinstall step
57+
# - 0.34.0 introduces protractor rule
58+
check_rules_nodejs_version(minimum_version_string = "0.34.0")
59+
60+
# Setup the Node.js toolchain
2861
node_repositories(
2962
node_repositories = {
30-
"10.9.0-darwin_amd64": (
31-
"node-v10.9.0-darwin-x64.tar.gz",
32-
"node-v10.9.0-darwin-x64",
33-
"3c4fe75dacfcc495a432a7ba2dec9045cff359af2a5d7d0429c84a424ef686fc",
34-
),
35-
"10.9.0-linux_amd64": (
36-
"node-v10.9.0-linux-x64.tar.xz",
37-
"node-v10.9.0-linux-x64",
38-
"c5acb8b7055ee0b6ac653dc4e458c5db45348cecc564b388f4ed1def84a329ff",
39-
),
40-
"10.9.0-windows_amd64": (
41-
"node-v10.9.0-win-x64.zip",
42-
"node-v10.9.0-win-x64",
43-
"6a75cdbb69d62ed242d6cbf0238a470bcbf628567ee339d4d098a5efcda2401e",
44-
),
45-
},
46-
node_version = "10.9.0",
47-
yarn_repositories = {
48-
"1.9.2": (
49-
"yarn-v1.9.2.tar.gz",
50-
"yarn-v1.9.2",
51-
"3ad69cc7f68159a562c676e21998eb21b44138cae7e8fe0749a7d620cf940204",
52-
),
63+
"10.16.0-darwin_amd64": ("node-v10.16.0-darwin-x64.tar.gz", "node-v10.16.0-darwin-x64", "6c009df1b724026d84ae9a838c5b382662e30f6c5563a0995532f2bece39fa9c"),
64+
"10.16.0-linux_amd64": ("node-v10.16.0-linux-x64.tar.xz", "node-v10.16.0-linux-x64", "1827f5b99084740234de0c506f4dd2202a696ed60f76059696747c34339b9d48"),
65+
"10.16.0-windows_amd64": ("node-v10.16.0-win-x64.zip", "node-v10.16.0-win-x64", "aa22cb357f0fb54ccbc06b19b60e37eefea5d7dd9940912675d3ed988bf9a059"),
5366
},
54-
yarn_version = "1.9.2",
67+
node_version = "10.16.0",
68+
package_json = ["//:package.json"],
69+
# yarn 1.13.0 under Bazel has a regression on Windows that causes build errors on rebuilds:
70+
# ```
71+
# ERROR: Source forest creation failed: C:/.../fyuc5c3n/execroot/angular/external (Directory not empty)
72+
# ```
73+
# See https://github.com/angular/angular/pull/29431 for more information.
74+
# It possible that versions of yarn past 1.13.0 do not have this issue, however, before
75+
# advancing this version we need to test manually on Windows that the above error does not
76+
# happen as the issue is not caught by CI.
77+
yarn_version = "1.12.1",
5578
)
5679

5780
yarn_install(
@@ -60,6 +83,7 @@ yarn_install(
6083
"//:tools/yarn/check-yarn.js",
6184
],
6285
package_json = "//:package.json",
86+
symlink_node_modules = False,
6387
yarn_lock = "//:yarn.lock",
6488
)
6589

@@ -87,27 +111,30 @@ web_test_repositories()
87111
# Bring in bazel_toolchains for RBE setup configuration.
88112
http_archive(
89113
name = "bazel_toolchains",
90-
sha256 = "54764b510cf45754c01ac65c9ba83e5f8fc8a033b8296ef74c4e4d6d1dbfaf21",
91-
strip_prefix = "bazel-toolchains-d67435097bd65153a592ecdcc83094474914c205",
92-
urls = ["https://github.com/xingao267/bazel-toolchains/archive/d67435097bd65153a592ecdcc83094474914c205.tar.gz"],
114+
sha256 = "dcb58e7e5f0b4da54c6c5f8ebc65e63fcfb37414466010cf82ceff912162296e",
115+
strip_prefix = "bazel-toolchains-0.28.2",
116+
url = "https://github.com/bazelbuild/bazel-toolchains/archive/0.28.2.tar.gz",
93117
)
94118

95119
load("@bazel_toolchains//rules:environments.bzl", "clang_env")
96120
load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
97121

98122
rbe_autoconfig(
99123
name = "rbe_ubuntu1604_angular",
100-
# The sha256 of marketplace.gcr.io/google/rbe-ubuntu16-04 container that is
101-
# used by rbe_autoconfig() to pair toolchain configs in the @bazel_toolchains repo.
102-
base_container_digest = "sha256:677c1317f14c6fd5eba2fd8ec645bfdc5119f64b3e5e944e13c89e0525cc8ad1",
124+
# Need to specify a base container digest in order to ensure that we can use the checked-in
125+
# platform configurations for the "ubuntu16_04" image. Otherwise the autoconfig rule would
126+
# need to pull the image and run it in order determine the toolchain configuration. See:
127+
# https://github.com/bazelbuild/bazel-toolchains/blob/0.27.0/configs/ubuntu16_04_clang/versions.bzl
128+
base_container_digest = "sha256:94d7d8552902d228c32c8c148cc13f0effc2b4837757a6e95b73fdc5c5e4b07b",
103129
# Note that if you change the `digest`, you might also need to update the
104130
# `base_container_digest` to make sure marketplace.gcr.io/google/rbe-ubuntu16-04-webtest:<digest>
105131
# and marketplace.gcr.io/google/rbe-ubuntu16-04:<base_container_digest> have
106-
# the same Clang and JDK installed.
107-
# Clang is needed because of the dependency on @com_google_protobuf.
108-
# Java is needed for the Bazel's test executor Java tool.
109-
digest = "sha256:74a8e9dca4781d5f277a7bd8e7ea7ed0f5906c79c9cd996205b6d32f090c62f3",
132+
# the same Clang and JDK installed. Clang is needed because of the dependency on
133+
# @com_google_protobuf. Java is needed for the Bazel's test executor Java tool.
134+
digest = "sha256:76e2e4a894f9ffbea0a0cb2fbde741b5d223d40f265dbb9bca78655430173990",
110135
env = clang_env(),
111136
registry = "marketplace.gcr.io",
137+
# We can't use the default "ubuntu16_04" RBE image provided by the autoconfig because we need
138+
# a specific Linux kernel that comes with "libx11" in order to run headless browser tests.
112139
repository = "google/rbe-ubuntu16-04-webtest",
113140
)

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@
8282
"devDependencies": {
8383
"@angular/compiler": "~8.2.0-rc.0",
8484
"@angular/compiler-cli": "~8.2.0-rc.0",
85-
"@bazel/bazel": "0.24.1",
86-
"@bazel/buildifier": "^0.22.0",
87-
"@bazel/jasmine": "~0.26.0",
88-
"@bazel/karma": "~0.26.0",
89-
"@bazel/typescript": "~0.26.0",
85+
"@bazel/bazel": "0.28.1",
86+
"@bazel/buildifier": "^0.26.0",
87+
"@bazel/jasmine": "0.35.0",
88+
"@bazel/karma": "0.35.0",
89+
"@bazel/typescript": "0.35.0",
9090
"@types/browserslist": "^4.4.0",
9191
"@types/caniuse-lite": "^1.0.0",
9292
"@types/clean-css": "^4.2.1",
@@ -134,7 +134,7 @@
134134
"tar": "^4.4.4",
135135
"through2": "^2.0.3",
136136
"tree-kill": "^1.2.0",
137-
"ts-api-guardian": "0.4.4",
137+
"ts-api-guardian": "0.4.6",
138138
"ts-node": "^5.0.0",
139139
"tslint-no-circular-imports": "^0.7.0",
140140
"tslint-sonarts": "1.9.0",

tools/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ nodejs_binary(
1212
data = [
1313
"quicktype_runner.js",
1414
],
15-
entry_point = "angular_cli/tools/quicktype_runner.js",
15+
entry_point = "quicktype_runner.js",
1616
install_source_map_support = False,
1717
node_modules = "@npm//quicktype-core",
1818
templated_args = [

0 commit comments

Comments
 (0)