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: use Bazel from npm #14170

Merged
merged 5 commits into from
Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 20 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@
# Variables

## IMPORTANT
# If you change the `docker_image` version, also change the `cache_key` suffix and the version of
# `com_github_bazelbuild_buildtools` in the `/WORKSPACE` file.
# If you change the cache key prefix, also sync the restore_cache fallback to match.
# Keep the static part of the cache key as prefix to enable correct fallbacks.
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
var_1: &docker_image angular/ngcontainer:0.10.0
var_2: &cache_key angular_devkit-0.10.0-{{ checksum "yarn.lock" }}
var_1: &default_docker_image circleci/node:10.12
var_2: &browsers_docker_image circleci/node:10.12-browsers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? We use puppeteer for our e2e tests so I didn't expect it to be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sadly headless chrome still requires dynamic linked dependency on libx11 which is pretty lame. We should raise with the Chrome team.

var_3: &cache_key angular_devkit-0.10.0-{{ checksum "yarn.lock" }}

# Settings common to each job
anchor_1: &defaults
working_directory: ~/ng
docker:
- image: *docker_image
- image: *default_docker_image

# After checkout, rebase on top of target branch.
anchor_2: &post_checkout
Expand Down Expand Up @@ -71,6 +70,11 @@ jobs:
steps:
- attach_workspace: *attach_options
- run: npm run lint
- run: 'yarn bazel:format -mode=check ||
(echo "BUILD files not formatted. Please run ''yarn bazel:format''" ; exit 1)'
# Run the skylark linter to check our Bazel rules
- run: 'yarn bazel:lint ||
(echo -e "\n.bzl files have lint errors. Please run ''yarn bazel:lint-fix''"; exit 1)'

validate:
<<: *defaults
Expand All @@ -86,6 +90,8 @@ jobs:

test-large:
<<: *defaults
docker:
- image: *browsers_docker_image
resource_class: large
parallelism: 4
steps:
Expand All @@ -95,26 +101,32 @@ jobs:

e2e-cli:
<<: *defaults
docker:
- image: *browsers_docker_image
environment:
BASH_ENV: ~/.profile
NPM_CONFIG_PREFIX: ~/.npm-global
resource_class: xlarge
parallelism: 4
steps:
- attach_workspace: *attach_options
- run: xvfb-run -a node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX}
- run: PATH=~/.npm-global/bin:$PATH xvfb-run -a node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX}
alexeagle marked this conversation as resolved.
Show resolved Hide resolved
- store_artifacts:
path: /tmp/dist
destination: cli/new-production

e2e-cli-ivy:
<<: *defaults
docker:
- image: *browsers_docker_image
environment:
BASH_ENV: ~/.profile
NPM_CONFIG_PREFIX: ~/.npm-global
resource_class: xlarge
parallelism: 4
steps:
- attach_workspace: *attach_options
- run: xvfb-run -a node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} --ivy
- run: PATH=~/.npm-global/bin:$PATH xvfb-run -a node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} --ivy

e2e-cli-ng-snapshots:
<<: *defaults
Expand Down Expand Up @@ -145,7 +157,7 @@ jobs:
steps:
- attach_workspace: *attach_options
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- run: bazel test ...
- run: yarn bazel:test

snapshot_publish:
<<: *defaults
Expand Down
25 changes: 14 additions & 11 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

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

# TS API Guardian resides in Angular
Expand All @@ -20,56 +20,59 @@ http_archive(
# We use protocol buffers for the Build Event Protocol
git_repository(
name = "com_google_protobuf",
remote = "https://github.com/protocolbuffers/protobuf",
commit = "b6375e03aa80274dae89410efdf46346413b2247",
remote = "https://github.com/protocolbuffers/protobuf",
)

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("0.18.0")
check_bazel_version(minimum_bazel_version = "0.18.0")

node_repositories(
node_version = "10.9.0",
yarn_version = "1.9.2",
node_repositories = {
"10.9.0-darwin_amd64": (
"node-v10.9.0-darwin-x64.tar.gz",
"node-v10.9.0-darwin-x64",
"3c4fe75dacfcc495a432a7ba2dec9045cff359af2a5d7d0429c84a424ef686fc"
"3c4fe75dacfcc495a432a7ba2dec9045cff359af2a5d7d0429c84a424ef686fc",
),
"10.9.0-linux_amd64": (
"node-v10.9.0-linux-x64.tar.xz",
"node-v10.9.0-linux-x64",
"c5acb8b7055ee0b6ac653dc4e458c5db45348cecc564b388f4ed1def84a329ff"
"c5acb8b7055ee0b6ac653dc4e458c5db45348cecc564b388f4ed1def84a329ff",
),
"10.9.0-windows_amd64": (
"node-v10.9.0-win-x64.zip",
"node-v10.9.0-win-x64",
"6a75cdbb69d62ed242d6cbf0238a470bcbf628567ee339d4d098a5efcda2401e"
"6a75cdbb69d62ed242d6cbf0238a470bcbf628567ee339d4d098a5efcda2401e",
),
},
node_version = "10.9.0",
yarn_repositories = {
"1.9.2": (
"yarn-v1.9.2.tar.gz",
"yarn-v1.9.2",
"3ad69cc7f68159a562c676e21998eb21b44138cae7e8fe0749a7d620cf940204"
"3ad69cc7f68159a562c676e21998eb21b44138cae7e8fe0749a7d620cf940204",
),
},
yarn_version = "1.9.2",
)

yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
data = [
"//:tools/yarn/check-yarn.js",
],
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)

load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")

install_bazel_dependencies()

load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace")
Expand Down
14 changes: 7 additions & 7 deletions etc/api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ load("@angular//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test")
bundle[1],
bundle[2],
),
allow_module_identifiers = [
"fs",
"ts",
"ajv",
"Symbol",
"webpack",
],
data = glob([
"%s/%s/**/*.d.ts" % (
bundle[0],
Expand Down Expand Up @@ -38,13 +45,6 @@ load("@angular//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test")
# @angular-devkit/build-optimizer
"^buildOptimizerLoader$",
],
allow_module_identifiers = [
"fs",
"ts",
"ajv",
"Symbol",
"webpack",
],
# At the moment using this will ignore a big change
use_angular_tag_rules = False,
) for bundle in [b[:-len(".d.ts")].split("/", 2) for b in glob(
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
],
"scripts": {
"admin": "node ./bin/devkit-admin",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: would be nice to have "bazel": "bazel",

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npx bazel?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the script proper is better I feel. It makes it pretty obvious that it's the right way of using bazel, whether via yarn or npm, and it's more ergonomic for scripts too. I don't know if all the docker images we use have npx either, but I guess they would.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes with npm. If you’re only using yarn you should be able to just do ‘yarn bazel’

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah you can yarn bazel if you want to pick your targets.

"bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unused-variable",
"bazel:lint": "yarn bazel:format --lint=warn",
"bazel:lint-fix": "yarn bazel:format --lint=fix",
"bazel:test": "bazel test //...",
"build": "npm run admin -- build",
"build-tsc": "tsc -p tsconfig.json",
"fix": "npm run admin -- lint --fix",
"lint": "npm run admin -- lint",
"prebuildifier": "bazel build --noshow_progress @com_github_bazelbuild_buildtools//buildifier",
"buildifier": "find . -type f \\( -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs $(bazel info bazel-bin)/external/com_github_bazelbuild_buildtools/buildifier/buildifier",
"templates": "node ./bin/devkit-admin templates",
"test": "node ./bin/devkit-admin test",
"test-large": "node ./bin/devkit-admin test --large --spec-reporter",
Expand Down Expand Up @@ -79,6 +81,9 @@
"devDependencies": {
"@angular/compiler": "^8.0.0-beta.12",
"@angular/compiler-cli": "^8.0.0-beta.12",
"@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",
"@ngtools/json-schema": "^1.1.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/angular/cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ ts_library(
"**/*_spec_large.ts",
],
),
data = glob(["**/*.json", "**/*.md"]),
data = glob([
"**/*.json",
"**/*.md",
]),
module_name = "@angular/cli",
# strict_checks = False,
deps = [
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/pwa/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ ts_library(
":pwa_schema",
"//packages/angular_devkit/core",
"//packages/angular_devkit/schematics",
"@npm//rxjs",
"@npm//@types/node",
"@npm//rxjs",
],
)

Expand Down
30 changes: 15 additions & 15 deletions packages/angular_devkit/architect/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ ts_json_schema(
name = "builder_input_schema",
src = "src/input-schema.json",
)

ts_json_schema(
name = "builder_output_schema",
src = "src/output-schema.json",
)

ts_json_schema(
name = "builder_builders_schema",
src = "src/builders-schema.json",
)

ts_json_schema(
name = "progress_schema",
src = "src/progress-schema.json",
Expand All @@ -41,15 +44,14 @@ ts_library(
module_root = "node/index.d.ts",
# strict_checks = False,
deps = [
"//packages/angular_devkit/core",
"//packages/angular_devkit/core:node",
"@npm//rxjs",

"@npm//@types/node",
":architect",
":builder_builders_schema",
":builder_input_schema",
":builder_output_schema",
"//packages/angular_devkit/core",
"//packages/angular_devkit/core:node",
"@npm//@types/node",
"@npm//rxjs",
],
)

Expand All @@ -62,18 +64,18 @@ ts_library(
"**/*_spec_large.ts",
],
),
module_name = "@angular-devkit/architect",
module_root = "src/index.d.ts",
# strict_checks = False,
data = glob(["**/*.json"]),
module_name = "@angular-devkit/architect",
module_root = "src/index.d.ts",
deps = [
"//packages/angular_devkit/core",
"//packages/angular_devkit/core:node",
"@npm//rxjs",
"@npm//@types/node",
":builder_input_schema",
":builder_output_schema",
":progress_schema",
"//packages/angular_devkit/core",
"//packages/angular_devkit/core:node",
"@npm//@types/node",
"@npm//rxjs",
],
)

Expand All @@ -92,17 +94,15 @@ ts_library(
":architect",
"//packages/angular_devkit/core",
"//packages/angular_devkit/core:node",
"@npm//rxjs",

"@npm//@types/node",
"@npm//rxjs",
],
)


npm_package(
name = "npm_package",
deps = [
":architect",
":testing"
":testing",
],
)
5 changes: 2 additions & 3 deletions packages/angular_devkit/architect_cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ ts_library(
"//packages/angular_devkit/architect:node",
"//packages/angular_devkit/core",
"//packages/angular_devkit/core:node",
"@npm//rxjs",

"@npm//@types/node",
"@npm//@types/minimist",
"@npm//@types/node",
"@npm//@types/progress",
"@npm//rxjs",
],
)
Loading