Skip to content
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

build: update bazel dependencies and configuration #15291

Merged
merged 1 commit into from Aug 12, 2019
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -1,2 +1,3 @@
.git
dist
node_modules
115 .bazelrc
@@ -2,11 +2,88 @@
# running as daemons, and cache SourceFile AST's to reduce parse time.
build --strategy=TypeScriptCompile=worker

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

###############################
# Filesystem interactions #
###############################

# Create symlinks in the project:
# - dist/bin for outputs
# - dist/testlogs, dist/genfiles
# - bazel-out
# NB: bazel-out should be excluded from the editor configuration.
# The checked-in /.vscode/settings.json does this for VSCode.
# Other editors may require manual config to ignore this directory.
# In the past, we saw a problem where VSCode traversed a massive tree, opening file handles and
# eventually a surprising failure with auto-discovery of the C++ toolchain in
# MacOS High Sierra.
# See https://github.com/bazelbuild/bazel/issues/4603
build --symlink_prefix=dist/

# Disable watchfs as it causes tests to be flaky on Windows
# https://github.com/angular/angular/issues/29541
build --nowatchfs
This conversation was marked as resolved by clydin

This comment has been minimized.

@josephperrott

josephperrott Aug 9, 2019
Member

Perhaps we should have a platform specific set of rc files for this type of situation? Since we would like --watchfs to be on for unix based systems, but need it disabled for windows.

This comment has been minimized.

@clydin

clydin Aug 11, 2019
Author Member

If there is a way to make them be used automatically based on the platform outside of CI, that would be a good idea.

This comment has been minimized.

@josephperrott

josephperrott Aug 12, 2019
Member

I don't know that there is a way to automatically choose the platform.

I wasn't thinking about how this wasn't CI specific, we can just leave it as --nowatchfs. One day maybe we will be able to do a platform based configurations.


# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on --incompatible_strict_action_env which was on by default
# in Bazel 0.21.0 but turned off again in 0.22.0. Follow
# https://github.com/bazelbuild/bazel/issues/7026 for more details.
# This flag is needed to so that the bazel cache is not invalidated
# when running bazel via `yarn bazel`.
# See https://github.com/angular/angular/issues/27514.
build --incompatible_strict_action_env
run --incompatible_strict_action_env
test --incompatible_strict_action_env

###############################
# Saucelabs support #
# Turn on these settings with #
# --config=saucelabs #
###############################

# Expose SauceLabs environment to actions
# These environment variables are needed by
# web_test_karma to run on Saucelabs
test:saucelabs --action_env=SAUCE_USERNAME
test:saucelabs --action_env=SAUCE_ACCESS_KEY
test:saucelabs --action_env=SAUCE_READY_FILE
test:saucelabs --action_env=SAUCE_PID_FILE
test:saucelabs --action_env=SAUCE_TUNNEL_IDENTIFIER
test:saucelabs --define=KARMA_WEB_TEST_MODE=SL_REQUIRED

###############################
# Release support #
# Turn on these settings with #
# --config=release #
###############################

# Releases should always be stamped with version control info
# This command assumes node on the path and is a workaround for
# https://github.com/bazelbuild/bazel/issues/4802
build:release --workspace_status_command="node ./tools/bazel_stamp_vars.js"

###############################
# Output #
###############################

# A more useful default output mode for bazel query
# Prints eg. "ng_module rule //foo:bar" rather than just "//foo:bar"
query --output=label_kind

# By default, failing tests don't print any output, it goes to the log file
test --test_output=errors

################################
# Settings for CircleCI #
################################

# Bazel flags for CircleCI are in /.circleci/bazel.rc

################################
# Remote Execution Setup #
################################
@@ -52,6 +129,40 @@ build:remote --bes_results_url="https://source.cloud.google.com/results/invocati
# Set remote caching settings
build:remote --remote_accept_cached=true

###############################
# NodeJS rules settings
# These settings are required for rules_nodejs
###############################

# Turn on managed directories feature in Bazel
# This allows us to avoid installing a second copy of node_modules
common --experimental_allow_incremental_repository_updates

# This option is changed to true in Bazel 0.27 and exposes a possible
# regression in Bazel 0.27.0.
# Error observed is in npm_package target `//packages/common/locales:package`:
# ```
# ERROR: /home/circleci/ng/packages/common/locales/BUILD.bazel:13:1: Assembling
# npm package packages/common/locales/package failed: No usable spawn strategy found
# for spawn with mnemonic SkylarkAction. Your --spawn_strategy or --strategy flags
# are probably too strict. Visit https://github.com/bazelbuild/bazel/issues/7480 for
# migration advises
# ```
# Suspect is https://github.com/bazelbuild/rules_nodejs/blob/master/internal/npm_package/npm_package.bzl#L75-L82:
# ```
# execution_requirements = {
# # Never schedule this action remotely because it's not computationally expensive.
# # It just copies files into a directory; it's not worth copying inputs and outputs to a remote worker.
# # Also don't run it in a sandbox, because it resolves an absolute path to the bazel-out directory
# # allowing the .pack and .publish runnables to work with no symlink_prefix
# # See https://github.com/bazelbuild/rules_nodejs/issues/187
# "local": "1",
# },
# ```
build --incompatible_list_based_execution_strategy_selection=false
test --incompatible_list_based_execution_strategy_selection=false
run --incompatible_list_based_execution_strategy_selection=false

####################################################
# User bazel configuration
# NOTE: This needs to be the *last* entry in the config.
108 WORKSPACE
@@ -1,57 +1,77 @@
workspace(name = "angular_cli")
workspace(
name = "angular_cli",
managed_directories = {"@npm": ["node_modules"]},
)

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "fb87ed5965cef93188af9a7287511639403f4b0da418961ce6defb9dcf658f51",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.27.7/rules_nodejs-0.27.7.tar.gz"],
sha256 = "6625259f9f77ef90d795d20df1d0385d9b3ce63b6619325f702b6358abb4ab33",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.35.0/rules_nodejs-0.35.0.tar.gz"],
)

# We use protocol buffers for the Build Event Protocol
This conversation was marked as resolved by clydin

This comment has been minimized.

@josephperrott

josephperrott Aug 9, 2019
Member

Is this necessary still for BEP setup? I know that we don't need to do this for angular/angular so I am not sure if we need to do this here. Unless there is something additional I am not aware of.

This comment has been minimized.

@clydin

clydin Aug 11, 2019
Author Member

The CLI has some basic BEP streaming support and there is a utility that supports debugging it which uses the proto_library rule that in turn requires this.

git_repository(
name = "com_google_protobuf",
commit = "beaeaeda34e97a6ff9735b33a66e011102ab506b",
remote = "https://github.com/protocolbuffers/protobuf",
shallow_since = "1559159889 -0400",
)

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

protobuf_deps()

load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install")

# 0.18.0 is needed for .bazelignore
check_bazel_version(minimum_bazel_version = "0.18.0")
# Check the bazel version and download npm dependencies
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "check_rules_nodejs_version", "node_repositories", "yarn_install")

# Bazel version must be at least the following version because:
# - 0.26.0 managed_directories feature added which is required for nodejs rules 0.30.0
# - 0.27.0 has a fix for managed_directories after `rm -rf node_modules`
check_bazel_version(
message = """
You no longer need to install Bazel on your machine.
Angular has a dependency on the @bazel/bazel package which supplies it.
Try running `yarn bazel` instead.
(If you did run that, check that you've got a fresh `yarn install`)
""",
minimum_bazel_version = "0.27.0",
)

# The NodeJS rules version must be at least the following version because:
# - 0.15.2 Re-introduced the prod_only attribute on yarn_install
# - 0.15.3 Includes a fix for the `jasmine_node_test` rule ignoring target tags
# - 0.16.8 Supports npm installed bazel workspaces
# - 0.26.0 Fix for data files in yarn_install and npm_install
# - 0.27.12 Adds NodeModuleSources provider for transtive npm deps support
# - 0.30.0 yarn_install now uses symlinked node_modules with new managed directories Bazel 0.26.0 feature
# - 0.31.1 entry_point attribute of nodejs_binary & rollup_bundle is now a label
# - 0.32.0 yarn_install and npm_install no longer puts build files under symlinked node_modules
# - 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")

# Setup the Node.js toolchain
node_repositories(
node_repositories = {
"10.9.0-darwin_amd64": (
"node-v10.9.0-darwin-x64.tar.gz",
"node-v10.9.0-darwin-x64",
"3c4fe75dacfcc495a432a7ba2dec9045cff359af2a5d7d0429c84a424ef686fc",
),
"10.9.0-linux_amd64": (
"node-v10.9.0-linux-x64.tar.xz",
"node-v10.9.0-linux-x64",
"c5acb8b7055ee0b6ac653dc4e458c5db45348cecc564b388f4ed1def84a329ff",
),
"10.9.0-windows_amd64": (
"node-v10.9.0-win-x64.zip",
"node-v10.9.0-win-x64",
"6a75cdbb69d62ed242d6cbf0238a470bcbf628567ee339d4d098a5efcda2401e",
),
},
node_version = "10.9.0",
yarn_repositories = {
"1.9.2": (
"yarn-v1.9.2.tar.gz",
"yarn-v1.9.2",
"3ad69cc7f68159a562c676e21998eb21b44138cae7e8fe0749a7d620cf940204",
),
"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"),
},
yarn_version = "1.9.2",
node_version = "10.16.0",
package_json = ["//:package.json"],
# yarn 1.13.0 under Bazel has a regression on Windows that causes build errors on rebuilds:
# ```
# ERROR: Source forest creation failed: C:/.../fyuc5c3n/execroot/angular/external (Directory not empty)
# ```
# See https://github.com/angular/angular/pull/29431 for more information.
# It possible that versions of yarn past 1.13.0 do not have this issue, however, before
# advancing this version we need to test manually on Windows that the above error does not
# happen as the issue is not caught by CI.
yarn_version = "1.12.1",
)

yarn_install(
@@ -60,6 +80,7 @@ yarn_install(
"//:tools/yarn/check-yarn.js",
],
package_json = "//:package.json",
symlink_node_modules = False,
yarn_lock = "//:yarn.lock",
)

@@ -87,27 +108,30 @@ web_test_repositories()
# Bring in bazel_toolchains for RBE setup configuration.
http_archive(
name = "bazel_toolchains",
sha256 = "54764b510cf45754c01ac65c9ba83e5f8fc8a033b8296ef74c4e4d6d1dbfaf21",
strip_prefix = "bazel-toolchains-d67435097bd65153a592ecdcc83094474914c205",
urls = ["https://github.com/xingao267/bazel-toolchains/archive/d67435097bd65153a592ecdcc83094474914c205.tar.gz"],
sha256 = "dcb58e7e5f0b4da54c6c5f8ebc65e63fcfb37414466010cf82ceff912162296e",
strip_prefix = "bazel-toolchains-0.28.2",
url = "https://github.com/bazelbuild/bazel-toolchains/archive/0.28.2.tar.gz",
)

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

rbe_autoconfig(
name = "rbe_ubuntu1604_angular",
# The sha256 of marketplace.gcr.io/google/rbe-ubuntu16-04 container that is
# used by rbe_autoconfig() to pair toolchain configs in the @bazel_toolchains repo.
base_container_digest = "sha256:677c1317f14c6fd5eba2fd8ec645bfdc5119f64b3e5e944e13c89e0525cc8ad1",
# Need to specify a base container digest in order to ensure that we can use the checked-in
# platform configurations for the "ubuntu16_04" image. Otherwise the autoconfig rule would
# need to pull the image and run it in order determine the toolchain configuration. See:
# https://github.com/bazelbuild/bazel-toolchains/blob/0.27.0/configs/ubuntu16_04_clang/versions.bzl
base_container_digest = "sha256:94d7d8552902d228c32c8c148cc13f0effc2b4837757a6e95b73fdc5c5e4b07b",
# Note that if you change the `digest`, you might also need to update the
# `base_container_digest` to make sure marketplace.gcr.io/google/rbe-ubuntu16-04-webtest:<digest>
# and marketplace.gcr.io/google/rbe-ubuntu16-04:<base_container_digest> have
# the same Clang and JDK installed.
# Clang is needed because of the dependency on @com_google_protobuf.
# Java is needed for the Bazel's test executor Java tool.
digest = "sha256:74a8e9dca4781d5f277a7bd8e7ea7ed0f5906c79c9cd996205b6d32f090c62f3",
# the same Clang and JDK installed. Clang is needed because of the dependency on
# @com_google_protobuf. Java is needed for the Bazel's test executor Java tool.
digest = "sha256:76e2e4a894f9ffbea0a0cb2fbde741b5d223d40f265dbb9bca78655430173990",
env = clang_env(),
registry = "marketplace.gcr.io",
# We can't use the default "ubuntu16_04" RBE image provided by the autoconfig because we need
# a specific Linux kernel that comes with "libx11" in order to run headless browser tests.
repository = "google/rbe-ubuntu16-04-webtest",
)
@@ -82,11 +82,11 @@
"devDependencies": {
"@angular/compiler": "~8.2.0-rc.0",
"@angular/compiler-cli": "~8.2.0-rc.0",
"@bazel/bazel": "0.24.1",
"@bazel/buildifier": "^0.22.0",
"@bazel/jasmine": "~0.26.0",
"@bazel/karma": "~0.26.0",
"@bazel/typescript": "~0.26.0",
"@bazel/bazel": "0.28.1",
"@bazel/buildifier": "^0.26.0",
"@bazel/jasmine": "0.35.0",
"@bazel/karma": "0.35.0",
"@bazel/typescript": "0.35.0",
"@types/browserslist": "^4.4.0",
"@types/caniuse-lite": "^1.0.0",
"@types/clean-css": "^4.2.1",
@@ -134,7 +134,7 @@
"tar": "^4.4.4",
"through2": "^2.0.3",
"tree-kill": "^1.2.0",
"ts-api-guardian": "0.4.4",
"ts-api-guardian": "0.4.6",
"ts-node": "^5.0.0",
"tslint-no-circular-imports": "^0.7.0",
"tslint-sonarts": "1.9.0",
@@ -125,6 +125,8 @@ ts_library(
jasmine_node_test(
name = "node_test",
srcs = [":node_test_lib"],
# TODO: Audit tests to determine if tests can be run in RBE environments
local = True,
deps = [
"@npm//chokidar",
"@npm//jasmine",
@@ -12,7 +12,7 @@ nodejs_binary(
data = [
"quicktype_runner.js",
],
entry_point = "angular_cli/tools/quicktype_runner.js",
entry_point = "quicktype_runner.js",
install_source_map_support = False,
node_modules = "@npm//quicktype-core",
templated_args = [
ProTip! Use n and p to navigate between commits in a pull request.