Skip to content

Commit

Permalink
build: allow bazel build //... (angular#22168)
Browse files Browse the repository at this point in the history
Also switch our CircleCI commands to just
bazel build //...
bazel test //...
as this is easier to understand.

Note, the reason this commit removes `firebase-tools` is:

1) firebase-tools has an optional dependency on
https://www.npmjs.com/package/@google-cloud/functions-emulator
2) yarn's `--ignore-optional` doesn't work for transitive deps, so
there's no way to yarn install without getting that functions-emulator
package
3) functions-emulator has a transitive dep on `grpc`
4) the version of `grpc` we get has `BUILD` files and no `WORKSPACE`
file so it always breaks `bazel build ...`

It could be solved by any of:
1) remove firebase-tools - this is what I did
2) fix yarn so you can omit optional deps of a transitive dep
3) make functions-emulator depend transitively on a more recent `grpc`
version
4) patch `grpc` after install by doing an `rm` command in our
postinstall or something

In its place we must install protobufjs. This is needed by the
ngc-wrapped test, which needs jasmine as well as bazel's worker mode
dependencies, and therefore cannot simply rely on
node_modules =
"@build_bazel_rules_typescript_tsc_wrapped_deps//:node_modules"

PR Close angular#22168
  • Loading branch information
alexeagle authored and mhevery committed Mar 23, 2018
1 parent 65f296a commit 4f0cae0
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 1,600 deletions.
10 changes: 7 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ jobs:
- run: ls /home/circleci/bazel_repository_cache || true
- run: bazel info release
- run: bazel run @yarn//:yarn
# Use bazel query so that we explicitly ask for all buildable targets to be built as well
# This avoids waiting for a build command to finish before running the first test
# We could use bazel query so that we explicitly ask for all buildable targets to be built as well
# This would avoid waiting for a build command to finish before running the first test
# See https://github.com/bazelbuild/bazel/issues/4257
- run: bazel query --output=label '//modules/... union //packages/... union //tools/...' | xargs bazel test
# - run: bazel query --output=label //... | xargs bazel test
# However it makes it more confusing for Angular developers who are still novice at Bazel
# So keep it simple for now
- run: bazel build //...
- run: bazel test //...

# CircleCI will allow us to go back and view/download these artifacts from past builds.
# Also we can use a service like https://buildsize.org/ to automatically track binary size of these artifacts.
Expand Down
7 changes: 7 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ local_repository(
path = "node_modules/rxjs/src",
)

# Point to the integration test workspace just so that Bazel doesn't descend into it
# when expanding the //... pattern
local_repository(
name = "bazel_integration_test",
path = "integration/bazel",
)

# This commit matches the version of buildifier in angular/ngcontainer
# If you change this, also check if it matches the version in the angular/ngcontainer
# version in /.circleci/config.yml
Expand Down
8 changes: 7 additions & 1 deletion integration/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ cd ${currentDir}
readonly thisDir=$(cd $(dirname $0); pwd)

# Track payload size functions
source ../scripts/ci/payload-size.sh
# TODO(alexeagle): finish migrating these to buildsize.org
if [[ -v TRAVIS ]]; then
# We don't install this by default because it contains some broken Bazel setup
# and also it's a very big dependency that we never use except on Travis.
yarn add -D firebase-tools@3.12.0
source ../scripts/ci/payload-size.sh
fi

# Workaround https://github.com/yarnpkg/yarn/issues/2165
# Yarn will cache file://dist URIs and not update Angular code
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
"diff": "^3.5.0",
"domino": "2.0.1",
"entities": "1.1.1",
"firebase-tools": "3.12.0",
"firefox-profile": "1.0.3",
"fs-extra": "4.0.2",
"glob": "7.1.2",
Expand All @@ -94,6 +93,7 @@
"minimist": "1.2.0",
"mutation-observer": "^1.0.3",
"node-uuid": "1.4.8",
"protobufjs": "5.0.0",
"protractor": "5.1.2",
"rewire": "2.5.2",
"rollup": "0.47.4",
Expand Down

0 comments on commit 4f0cae0

Please sign in to comment.