build: use bazel version from node modules (#26691)

* No longer depends on a custom CircleCI docker image that comes with Bazel pre-installed. Since Bazel is now available through NPM, we should be able to use the version from `@bazel/bazel` in order to enforce a consistent environment on CI and locally.
* This also reduces the amount of packages that need to be published (ngcontainer is removed)

PR Close #26691
This commit is contained in:
Paul Gschwendtner 2018-10-27 09:25:45 +02:00 committed by Matias Niemelä
parent 66be3c9f51
commit 8fc4ae51fb
21 changed files with 214 additions and 146 deletions

View File

@ -13,7 +13,7 @@ a GitHub token that enables publishing snapshots.
To create the github_token file, we take this approach:
- Find the angular-builds:token in http://valentine
- Go inside the ngcontainer docker image so you use the same version of openssl as we will at runtime: `docker run --rm -it angular/ngcontainer`
- Go inside the CircleCI default docker image so you use the same version of openssl as we will at runtime: `docker run --rm -it circleci/node:10.12`
- echo "https://[token]:@github.com" > credentials
- openssl aes-256-cbc -e -in credentials -out .circleci/github_token -k $KEY
- If needed, base64-encode the result so you can copy-paste it out of docker: `base64 github_token`

View File

@ -7,50 +7,54 @@
# To validate changes, use an online parser, eg.
# http://yaml-online-parser.appspot.com/
# 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.
var_1: &docker_image angular/ngcontainer:0.7.0
var_2: &cache_key v2-angular-{{ .Branch }}-{{ checksum "yarn.lock" }}-0.7.0
# Note that the browser docker image comes with Chrome and Firefox preinstalled. This is just
# needed for jobs that run tests without Bazel. Bazel runs tests with browsers that will be
# fetched by the Webtesting rules. Therefore for jobs that run tests with Bazel, we don't need a
# docker image with browsers pre-installed.
# **NOTE**: If you change the version of the docker images, also change the `cache_key` suffix.
var_1: &default_docker_image circleci/node:10.12
var_2: &browsers_docker_image circleci/node:10.12-browsers
var_3: &cache_key v2-angular-{{ .Branch }}-{{ checksum "yarn.lock" }}-node-10.12
# Define common ENV vars
var_3: &define_env_vars
var_4: &define_env_vars
run:
name: Define environment variables
command: ./.circleci/env.sh
# See remote cache documentation in /docs/BAZEL.md
var_4: &setup-bazel-remote-cache
run:
name: Start up bazel remote cache proxy
command: ~/bazel-remote-proxy -backend circleci://
background: true
var_5: &setup_bazel_remote_execution
run:
name: "Setup bazel RBE remote execution"
command: openssl aes-256-cbc -d -in .circleci/gcp_token -k "$CI_REPO_NAME" -out /home/circleci/.gcp_credentials && echo "export GOOGLE_APPLICATION_CREDENTIALS=/home/circleci/.gcp_credentials" >> $BASH_ENV && sudo bash -c "cat .circleci/rbe-bazel.rc >> /etc/bazel.bazelrc"
# Settings common to each job
var_6: &job_defaults
working_directory: ~/ng
docker:
- image: *default_docker_image
var_7: &start-xvfb
run:
name: Running X virtual framebuffer
command: Xvfb :99 -screen 0 1280x1024x24
background: true
# Settings common to each job
anchor_1: &job_defaults
working_directory: ~/ng
docker:
- image: *docker_image
# After checkout, rebase on top of master.
# Similar to travis behavior, but not quite the same.
# See https://discuss.circleci.com/t/1662
anchor_2: &post_checkout
var_8: &post_checkout
post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge"
var_9: &yarn_install
run:
name: Running Yarn install
command: yarn install --frozen-lockfile --non-interactive
var_10: &setup_circleci_bazel_config
run:
name: Setting up CircleCI bazel configuration
command: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
version: 2
jobs:
lint:
@ -59,21 +63,18 @@ jobs:
steps:
- checkout:
<<: *post_checkout
- restore_cache:
key: *cache_key
- *define_env_vars
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- *setup_circleci_bazel_config
- *yarn_install
# Check BUILD.bazel formatting before we have a node_modules directory
# Then we don't need any exclude pattern to avoid checking those files
- run: 'yarn buildifier -mode=check ||
(echo "BUILD files not formatted. Please run ''yarn buildifier''" ; exit 1)'
# Run the skylark linter to check our Bazel rules
- run: 'yarn skylint ||
(echo -e "\n.bzl files have lint errors. Please run ''yarn skylint''"; exit 1)'
- restore_cache:
key: *cache_key
- run: yarn install --frozen-lockfile --non-interactive
- run: ./node_modules/.bin/gulp lint
test:
@ -82,17 +83,18 @@ jobs:
steps:
- checkout:
<<: *post_checkout
- restore_cache:
key: *cache_key
- *define_env_vars
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- *setup_circleci_bazel_config
- *yarn_install
- run: bazel info release
- run: bazel run @nodejs//:yarn
# Setup remote execution and run RBE-compatible tests.
- *setup_bazel_remote_execution
- run: bazel test //... --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only,-local
- run: yarn bazel test //... --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only,-local
# Now run RBE incompatible tests locally.
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- run: bazel test //... --build_tag_filters=-ivy-only,local --test_tag_filters=-ivy-only,local
- run: yarn bazel test //... --build_tag_filters=-ivy-only,local --test_tag_filters=-ivy-only,local
# 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.
@ -126,11 +128,13 @@ jobs:
steps:
- checkout:
<<: *post_checkout
- restore_cache:
key: *cache_key
- *define_env_vars
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- run: bazel run @yarn//:yarn
- *setup_circleci_bazel_config
- *yarn_install
- *setup_bazel_remote_execution
- run: yarn test-ivy-jit //...
test_ivy_aot:
@ -139,22 +143,27 @@ jobs:
steps:
- checkout:
<<: *post_checkout
- restore_cache:
key: *cache_key
- *define_env_vars
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- run: bazel run @yarn//:yarn
- *setup_circleci_bazel_config
- *yarn_install
- *setup_bazel_remote_execution
- run: yarn test-ivy-aot //...
test_aio:
<<: *job_defaults
docker:
# Needed because the AIO tests and the PWA score test depend on Chrome being available.
- image: *browsers_docker_image
steps:
- checkout:
<<: *post_checkout
- *define_env_vars
- *start-xvfb
- restore_cache:
key: *cache_key
- *define_env_vars
- *start-xvfb
# Build aio
- run: yarn --cwd aio build --progress=false
# Lint the code
@ -174,28 +183,34 @@ jobs:
deploy_aio:
<<: *job_defaults
docker:
# Needed because before deploying the deploy-production script runs the PWA score tests.
- image: *browsers_docker_image
steps:
- checkout:
<<: *post_checkout
- *define_env_vars
- *start-xvfb
- restore_cache:
key: *cache_key
- *define_env_vars
- *start-xvfb
# Deploy angular.io to production (if necessary)
- run: setPublicVar CI_STABLE_BRANCH "$(npm info @angular/core dist-tags.latest | sed -r 's/^\s*([0-9]+\.[0-9]+)\.[0-9]+.*$/\1.x/')"
- run: yarn --cwd aio deploy-production
test_aio_local:
<<: *job_defaults
docker:
# Needed because the AIO tests and the PWA score test depend on Chrome being available.
- image: *browsers_docker_image
steps:
- checkout:
<<: *post_checkout
- *define_env_vars
- *start-xvfb
- attach_workspace:
at: dist
- restore_cache:
key: *cache_key
- attach_workspace:
at: dist
- *define_env_vars
- *start-xvfb
# Build aio (with local Angular packages)
- run: yarn --cwd aio build-local --progress=false
# Run PWA-score tests
@ -211,11 +226,11 @@ jobs:
steps:
- checkout:
<<: *post_checkout
- *define_env_vars
- attach_workspace:
at: dist
- restore_cache:
key: *cache_key
- attach_workspace:
at: dist
- *define_env_vars
# Install
- run: yarn --cwd aio install --frozen-lockfile --non-interactive
- run: yarn --cwd aio extract-cli-command-docs
@ -225,17 +240,20 @@ jobs:
test_docs_examples_0:
<<: *job_defaults
docker:
# Needed because the example e2e tests depend on Chrome.
- image: *browsers_docker_image
steps:
- checkout:
<<: *post_checkout
- *define_env_vars
- *start-xvfb
- attach_workspace:
at: dist
- restore_cache:
key: *cache_key
- attach_workspace:
at: dist
- *define_env_vars
- *start-xvfb
# Install root
- run: yarn install --frozen-lockfile --non-interactive
- *yarn_install
# Install aio
- run: yarn --cwd aio install --frozen-lockfile --non-interactive
# Run examples tests
@ -243,17 +261,20 @@ jobs:
test_docs_examples_1:
<<: *job_defaults
docker:
# Needed because the example e2e tests depend on Chrome.
- image: *browsers_docker_image
steps:
- checkout:
<<: *post_checkout
- *define_env_vars
- *start-xvfb
- attach_workspace:
at: dist
- restore_cache:
key: *cache_key
- attach_workspace:
at: dist
- *define_env_vars
- *start-xvfb
# Install root
- run: yarn install --frozen-lockfile --non-interactive
- *yarn_install
# Install aio
- run: yarn --cwd aio install --frozen-lockfile --non-interactive
# Run examples tests
@ -267,10 +288,10 @@ jobs:
steps:
- checkout:
<<: *post_checkout
- *define_env_vars
- restore_cache:
key: *cache_key
- run: yarn install --frozen-lockfile --non-interactive
- *define_env_vars
- *yarn_install
- run: ./aio/scripts/build-artifacts.sh $AIO_SNAPSHOT_ARTIFACT_PATH $CI_PULL_REQUEST $CI_COMMIT
- store_artifacts:
path: *aio_preview_artifact_path
@ -281,13 +302,16 @@ jobs:
# This job should only be run on PR builds, where `CI_PULL_REQUEST` is not `false`.
test_aio_preview:
<<: *job_defaults
docker:
# Needed because the test-preview script runs e2e tests and the PWA score test with Chrome.
- image: *browsers_docker_image
steps:
- checkout:
<<: *post_checkout
- *define_env_vars
- *start-xvfb
- restore_cache:
key: *cache_key
- *define_env_vars
- *start-xvfb
- run: yarn install --cwd aio --frozen-lockfile --non-interactive
- run:
name: Wait for preview and run tests
@ -306,10 +330,13 @@ jobs:
steps:
- checkout:
<<: *post_checkout
- restore_cache:
key: *cache_key
- *define_env_vars
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
- run: bazel run @nodejs//:yarn
- *setup_circleci_bazel_config
- *yarn_install
- *setup_bazel_remote_execution
- run: scripts/build-packages-dist.sh
# Save the npm packages from //packages/... for other workflow jobs to read
@ -329,6 +356,9 @@ jobs:
# See comments inside the integration/run_tests.sh script.
integration_test:
<<: *job_defaults
docker:
# Needed because the integration tests expect Chrome to be installed (e.g cli-hello-world)
- image: *browsers_docker_image
# Note: we run Bazel in one of the integration tests, and it can consume >2G
# of memory. Together with the system under test, this can exhaust the RAM
# on a 4G worker so we use a larger machine here too.
@ -336,10 +366,12 @@ jobs:
steps:
- checkout:
<<: *post_checkout
- *define_env_vars
- *start-xvfb
- restore_cache:
key: *cache_key
- attach_workspace:
at: dist
- *define_env_vars
- *start-xvfb
- run: ./integration/run_tests.sh
# This job updates the content of repos like github.com/angular/core-builds
@ -373,13 +405,17 @@ jobs:
aio_monitoring:
<<: *job_defaults
docker:
# This job needs Chrome to be globally installed because the tests run with Protractor
# which does not load the browser through the Bazel webtesting rules.
- image: *browsers_docker_image
steps:
- checkout:
<<: *post_checkout
- *define_env_vars
- *start-xvfb
- restore_cache:
key: *cache_key
- *define_env_vars
- *start-xvfb
- run:
name: Run tests against the deployed apps
command: ./aio/scripts/test-production.sh $CI_AIO_MIN_PWA_SCORE

View File

@ -8,13 +8,6 @@ exports_files([
"protractor-perf.conf.js",
])
# Developers should always run `bazel run :install`
# This ensures that package.json in subdirectories get installed as well.
alias(
name = "install",
actual = "@nodejs//:yarn",
)
filegroup(
name = "web_test_bootstrap_scripts",
# do not sort

View File

@ -9,21 +9,14 @@ Bazel.
## Installation
Install Bazel from the distribution, see [install] instructions.
On Mac, just `brew install bazel`.
In order to ensure that everyone builds Angular in a _consistent_ way, Bazel
will be installed through NPM and therefore it's not necessary to install Bazel
manually.
Bazel will install a hermetic version of Node, npm, and Yarn when
you run the first build.
The binaries for Bazel will be provided by the [`@bazel/bazel`](https://github.com/bazelbuild/rules_nodejs/tree/master/packages)
NPM package and its platform-specific dependencies.
[install]: https://bazel.build/versions/master/docs/install.html
### Installation of ibazel
Install interactive bazel runner / fs watcher via:
```
yarn global add @bazel/ibazel
```
You can access Bazel with the `yarn bazel` command
## Configuration
@ -33,12 +26,6 @@ use to execute build steps, from `build_bazel_rules_typescript`.
The sources on [GitHub] are published from Google's internal
repository (google3).
That repository defines dependencies on specific versions of
all the tools. You can run the tools Bazel installed, for
example rather than `yarn install` (which depends on whatever
version you have installed on your machine), you can
`bazel run @nodejs//:yarn`.
Bazel accepts a lot of options. We check in some options in the
`.bazelrc` file. See the [bazelrc doc]. For example, if you don't
want Bazel to create several symlinks in your project directory
@ -50,8 +37,8 @@ want Bazel to create several symlinks in your project directory
## Building Angular
- Build a package: `bazel build packages/core`
- Build all packages: `bazel build packages/...`
- Build a package: `yarn bazel build packages/core`
- Build all packages: `yarn bazel build packages/...`
You can use [ibazel] to get a "watch mode" that continuously
keeps the outputs up-to-date as you save sources. Note this is
@ -61,9 +48,9 @@ new as of May 2017 and not very stable yet.
## Testing Angular
- Test package in node: `bazel test packages/core/test:test`
- Test package in karma: `bazel test packages/core/test:test_web`
- Test all packages: `bazel test packages/...`
- Test package in node: `yarn bazel test packages/core/test:test`
- Test package in karma: `yarn bazel test packages/core/test:test_web`
- Test all packages: `yarn bazel test packages/...`
You can use [ibazel] to get a "watch mode" that continuously
keeps the outputs up-to-date as you save sources.
@ -93,7 +80,7 @@ See also: [`//.bazelrc`](https://github.com/angular/angular/blob/master/.bazelrc
- Open chrome at: [chrome://inspect](chrome://inspect)
- Click on `Open dedicated DevTools for Node` to launch a debugger.
- Run test: `bazel test packages/core/test:test --config=debug`
- Run test: `yarn bazel test packages/core/test:test --config=debug`
The process should automatically connect to the debugger. For additional info and testing options, see the [nodejs_test documentation](https://bazelbuild.github.io/rules_nodejs/node/node.html#nodejs_test).
@ -130,7 +117,7 @@ First time setup:
**Setting breakpoints directly in your code files may not work in VSCode**. This is because the files you're actually debugging are built files that exist in a `./private/...` folder.
The easiest way to debug a test for now is to add a `debugger` statement in the code
and launch the bazel corresponding test (`bazel test <target> --config=debug`).
and launch the bazel corresponding test (`yarn bazel test <target> --config=debug`).
Bazel will wait on a connection. Go to the debug view (by clicking on the sidebar or
Apple+Shift+D on Mac) and click on the green play icon next to the configuration name
@ -138,7 +125,7 @@ Apple+Shift+D on Mac) and click on the green play icon next to the configuration
### Debugging a Karma Test
- Run test: `bazel run packages/core/test:test_web`
- Run test: `yarn bazel run packages/core/test:test_web`
- Open chrome at: [http://localhost:9876/debug.html](http://localhost:9876/debug.html)
- Open chrome inspector
@ -151,7 +138,7 @@ open $(bazel info output_base)/external
See subcommands that bazel executes (helpful for debugging):
```sh
bazel build //packages/core:package -s
yarn bazel build //packages/core:package -s
```
To debug nodejs_binary executable paths uncomment `find . -name rollup 1>&2` (~ line 96) in
@ -168,7 +155,7 @@ In our repo, here is how it's configured:
1) In `tools/bazel_stamp_vars.sh` we run the `git` commands to generate our versioning info.
1) In `.bazelrc` we register this script as the value for the `workspace_status_command` flag. Bazel will run the script when it needs to stamp a binary.
Note that Bazel has a `--stamp` argument to `bazel build`, but this has no effect since our stamping takes place in Skylark rules. See https://github.com/bazelbuild/bazel/issues/1054
Note that Bazel has a `--stamp` argument to `yarn bazel build`, but this has no effect since our stamping takes place in Skylark rules. See https://github.com/bazelbuild/bazel/issues/1054
## Remote cache
@ -206,7 +193,7 @@ See [bazelbuild/intellij#246](https://github.com/bazelbuild/intellij/issues/246)
If you see the following error:
```
$ bazel build packages/...
$ yarn bazel build packages/...
ERROR: /private/var/tmp/[...]/external/local_config_cc/BUILD:50:5: in apple_cc_toolchain rule @local_config_cc//:cc-compiler-darwin_x86_64: Xcode version must be specified to use an Apple CROSSTOOL
ERROR: Analysis of target '//packages/core/test/render3:render3' failed; build aborted: Analysis of target '@local_config_cc//:cc-compiler-darwin_x86_64' failed; build aborted
```
@ -228,7 +215,7 @@ If VSCode is not the root cause, you might try:
bazel clean --expunge
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license
bazel build //packages/core # Run a build outside VSCode to pre-build the xcode; then safe to run VSCode
yarn bazel build //packages/core # Run a build outside VSCode to pre-build the xcode; then safe to run VSCode
```
Source: https://stackoverflow.com/questions/45276830/xcode-version-must-be-specified-to-use-an-apple-crosstool

View File

@ -5,6 +5,9 @@
"license": "MIT",
"dependencies": {
},
"devDependencies": {
"@bazel/bazel": "file:../../node_modules/@bazel/bazel"
},
"scripts": {
"//": "deps are listed in src/package.json which is used by yarn_install",
"//": "this package.json file is only here so that `yarn test` can be called by /integration/run_tests.sh",

View File

@ -2,3 +2,24 @@
# yarn lockfile v1
"@bazel/bazel-darwin_x64@0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-darwin_x64/-/bazel-darwin_x64-0.18.0.tgz#bab437605a702279d42f59caa4741bb327eb7dbc"
integrity sha512-um2OzgLL2Gd/W6joOpvrSTcqpnupliPNpwe/uE7sB0huBSJ/4Im0w2IlCTI6C7OfgMcbpUj4YxgUa9T6u6WY6w==
"@bazel/bazel-linux_x64@0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-linux_x64/-/bazel-linux_x64-0.18.0.tgz#0c02b2404ec95c180e17615cc7079ee07df48a69"
integrity sha512-Rq8X8bL6SgQvbOHnfPhSgF6hp+f6Fbt2w6pRmBlFvV1J+CeUyrSrrRXfnnO1bjIuq05Ur3mV8ULA0qK6rtA5lQ==
"@bazel/bazel-win32_x64@0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-win32_x64/-/bazel-win32_x64-0.18.0.tgz#aa4575fb00066dcf59a6d464971774dea6a0bafd"
integrity sha512-U2TbfK8B7dc3JqXSFwj2oXCQrxEaSzCCUkAHjAOIGOKzx/HLKIKs+NJj9IQkLLr7BsMU+Qqzo8aqo11E+Vs+aA==
"@bazel/bazel@file:../../node_modules/@bazel/bazel":
version "0.18.0"
optionalDependencies:
"@bazel/bazel-darwin_x64" "0.18.0"
"@bazel/bazel-linux_x64" "0.18.0"
"@bazel/bazel-win32_x64" "0.18.0"

View File

@ -29,7 +29,8 @@
"test-ivy-jit": "bazel test --define=compile=jit --build_tag_filters=-no-ivy-jit,-fixme-ivy-jit --test_tag_filters=-no-ivy-jit,-fixme-ivy-jit",
"test-fixme-ivy-jit": "bazel test --define=compile=jit --build_tag_filters=-no-ivy-jit --test_tag_filters=-no-ivy-jit",
"test-ivy-aot": "bazel test --define=compile=aot --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot --test_tag_filters=-no-ivy-aot,-fixme-ivy-aot",
"test-fixme-ivy-aot": "bazel test --define=compile=aot --build_tag_filters=-no-ivy-aot --test_tag_filters=-no-ivy-aot"
"test-fixme-ivy-aot": "bazel test --define=compile=aot --build_tag_filters=-no-ivy-aot --test_tag_filters=-no-ivy-aot",
"bazel": "bazel"
},
"// 1": "dependencies are used locally and by bazel",
"dependencies": {
@ -87,6 +88,7 @@
},
"// 2": "devDependencies are not used under Bazel. Many can be removed after test.sh is deleted.",
"devDependencies": {
"@bazel/bazel": "^0.18.1",
"@bazel/ibazel": "^0.1.1",
"@bazel/karma": "0.20.3",
"@types/angular": "^1.6.47",

View File

@ -22,4 +22,4 @@ protractor_web_test = _protractor_web_test
protractor_web_test_suite = _protractor_web_test_suite
ng_setup_workspace = _ng_setup_workspace
# DO NOT ADD PUBLIC API without including in the documentation generation
# Run `bazel build //packages/bazel/docs` to verify
# Run `yarn bazel build //packages/bazel/docs` to verify

View File

@ -87,16 +87,11 @@ def rules_angular_dev_dependencies():
url = "https://github.com/bazelbuild/bazel/archive/0.18.0.zip",
)
# 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
BAZEL_BUILDTOOLS_VERSION = "49a6c199e3fbf5d94534b2771868677d3f9c6de9"
http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "edf39af5fc257521e4af4c40829fffe8fba6d0ebff9f4dd69a6f8f1223ae047b",
strip_prefix = "buildtools-%s" % BAZEL_BUILDTOOLS_VERSION,
url = "https://github.com/bazelbuild/buildtools/archive/%s.zip" % BAZEL_BUILDTOOLS_VERSION,
sha256 = "a82d4b353942b10c1535528b02bff261d020827c9c57e112569eddcb1c93d7f6",
strip_prefix = "buildtools-0.17.2",
url = "https://github.com/bazelbuild/buildtools/archive/0.17.2.zip",
)
#############################################

View File

@ -101,7 +101,7 @@ function runPackageGoldTest(testPackage: TestPackage) {
` Diff:\n` +
` ${patch}\n\n` +
` To accept the new golden file, run:\n` +
` bazel run ${process.env['BAZEL_TARGET']}.accept\n`;
` yarn bazel run ${process.env['BAZEL_TARGET']}.accept\n`;
fail(failureMessage);
}

View File

@ -10,7 +10,7 @@ This conversion will allow such "legacy" packages to be used by the Ivy renderin
The project is built using Bazel:
```bash
bazel build //packages/compiler-cli/src/ngcc
yarn bazel build //packages/compiler-cli/src/ngcc
```
## Unit Testing
@ -18,7 +18,7 @@ bazel build //packages/compiler-cli/src/ngcc
The unit tests are built and run using Bazel:
```bash
bazel test //packages/compiler-cli/src/ngcc/test
yarn bazel test //packages/compiler-cli/src/ngcc/test
```
## Integration Testing
@ -26,5 +26,5 @@ bazel test //packages/compiler-cli/src/ngcc/test
There are tests that check the behaviour of the overall executable:
```bash
bazel test //packages/compiler-cli/test/ngcc
yarn bazel test //packages/compiler-cli/test/ngcc
```

View File

@ -1,3 +1,5 @@
Tests in this directory should be run with:
bazel test --define=compile=aot packages/compiler-cli/test/compliance:compliance
```
yarn bazel test --define=compile=aot packages/compiler-cli/test/compliance:compliance
```

View File

@ -12,7 +12,10 @@ cd "$(dirname "$0")"
# basedir is the workspace root
readonly basedir=$(pwd)/..
readonly bin=$(bazel info bazel-bin)
# We need to resolve the Bazel binary in the node modules because running Bazel
# through `yarn bazel` causes additional output that throws off command stdout.
readonly bazelBin=$(yarn bin)/bazel
readonly bin=$(${bazelBin} info bazel-bin)
function buildTargetPackages() {
targets="$1"
@ -20,13 +23,13 @@ function buildTargetPackages() {
compileMode="$3"
desc="$4"
echo "##################################"
echo "scripts/build-packages-dist.sh:"
echo " building @angular/* npm packages"
echo " mode: ${desc}"
echo "##################################"
echo "##################################"
echo "scripts/build-packages-dist.sh:"
echo " building @angular/* npm packages"
echo " mode: ${desc}"
echo "##################################"
echo "$targets" | xargs bazel build --define=compile=$compileMode
echo "$targets" | xargs ${bazelBin} build --define=compile=$compileMode
[ -d "${basedir}/${destPath}" ] || mkdir -p $basedir/${destPath}
@ -49,7 +52,7 @@ echo "##################################"
# packages in their deps[].
# Until then, we have to manually run bazel first to create the npm packages we
# want to test.
BAZEL_TARGETS=`bazel query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
BAZEL_TARGETS=`${bazelBin} query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
buildTargetPackages "$BAZEL_TARGETS" "dist/packages-dist" "legacy" "Production"
# We don't use the ivy build in the integration tests, only when publishing

View File

@ -7,12 +7,12 @@ set -u -e -o pipefail
# Publish them to npm (tagged next)
# query for all npm packages to be released as part of the framework release
NPM_PACKAGE_LABELS=`bazel query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
NPM_PACKAGE_LABELS=`yarn bazel query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
# build all npm packages in parallel
bazel build $NPM_PACKAGE_LABELS
yarn bazel build $NPM_PACKAGE_LABELS
# publish all packages in sequence to make it easier to spot any errors or warnings
for packageLabel in $NPM_PACKAGE_LABELS; do
echo "publishing $packageLabel"
bazel run -- ${packageLabel}.publish --access public --tag latest
yarn bazel run -- ${packageLabel}.publish --access public --tag latest
done

View File

@ -7,11 +7,11 @@ set -u -e -o pipefail
# Publish them to npm (tagged next)
# query for all npm packages to be released as part of the framework release
NPM_PACKAGE_LABELS=`bazel query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
NPM_PACKAGE_LABELS=`yarn bazel query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
# build all npm packages in parallel
bazel build $NPM_PACKAGE_LABELS
yarn bazel build $NPM_PACKAGE_LABELS
# publish all packages in sequence to make it easier to spot any errors or warnings
for packageLabel in $NPM_PACKAGE_LABELS; do
echo "publishing $packageLabel"
bazel run -- ${packageLabel}.publish --access public --tag next
yarn bazel run -- ${packageLabel}.publish --access public --tag next
done

View File

@ -22,7 +22,7 @@ if [[ "$(git tag)" == "" ]]; then
echo "Either fetch the tags:"
echo " git fetch git@github.com:angular/angular.git --tags"
echo "or build without stamping by giving an empty workspace_status_command:"
echo " bazel build --workspace_status_command= ..."
echo " yarn bazel build --workspace_status_command= ..."
echo ""
fi

View File

@ -164,7 +164,7 @@ def ts_web_test_suite(bootstrap = [], deps = [], **kwargs):
deps = local_deps,
# Run unit tests on local Chromium by default.
# You can exclude tests based on tags, e.g. to skip Firefox testing,
# `bazel test --test_tag_filters=-browser:firefox-local [targets]`
# `yarn bazel test --test_tag_filters=-browser:firefox-local [targets]`
browsers = [
"@io_bazel_rules_webtesting//browsers:chromium-local",
# Don't test on local Firefox by default, for faster builds.

View File

@ -2,6 +2,9 @@
This docker container provides everything needed to build and test Angular applications:
**Note**: This docker image will be no longer actively updated. Consider using other Docker
images that come with Node installed. Bazel can be installed through the `@bazel/bazel` NPM package.
- node 10.9.0
- npm 6.2.0
- yarn 1.9.2

View File

@ -7,7 +7,6 @@
*/
import * as fs from 'fs';
import * as path from 'path';
import {SymbolExtractor} from './symbol_extractor';
if (require.main === module) {
@ -44,7 +43,7 @@ function main(argv: [string, string, string] | [string, string]): boolean {
const defineFlag = (compile !== 'legacy') ? `--define=compile=${compile} ` : '';
console.error(`TEST FAILED!`);
console.error(` To update the golden file run: `);
console.error(` bazel run ${defineFlag}${process.env['BAZEL_TARGET']}.accept`);
console.error(` yarn bazel run ${defineFlag}${process.env['BAZEL_TARGET']}.accept`);
}
}
return passed;

View File

@ -23,8 +23,8 @@ ts-api-guardian --verifyDir api_guard [--rootDir .] core/index.d.ts core/testing
Build and test this library:
```sh
$ bazel run //:install
$ bazel test //tools/ts-api-guardian:all
$ yarn bazel run //:install
$ yarn bazel test //tools/ts-api-guardian:all
```
Publish to NPM:
@ -32,5 +32,5 @@ Publish to NPM:
```sh
$ npm whoami # should be logged in as angular
$ grep version tools/ts-api-guardian/package.json # advance as needed
$ bazel run //tools/ts-api-guardian:ts-api-guardian.publish
$ yarn bazel run //tools/ts-api-guardian:ts-api-guardian.publish
```

View File

@ -20,6 +20,30 @@
"@angular-devkit/core" "0.5.13"
rxjs "^6.0.0"
"@bazel/bazel-darwin_x64@0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-darwin_x64/-/bazel-darwin_x64-0.18.0.tgz#bab437605a702279d42f59caa4741bb327eb7dbc"
integrity sha512-um2OzgLL2Gd/W6joOpvrSTcqpnupliPNpwe/uE7sB0huBSJ/4Im0w2IlCTI6C7OfgMcbpUj4YxgUa9T6u6WY6w==
"@bazel/bazel-linux_x64@0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-linux_x64/-/bazel-linux_x64-0.18.0.tgz#0c02b2404ec95c180e17615cc7079ee07df48a69"
integrity sha512-Rq8X8bL6SgQvbOHnfPhSgF6hp+f6Fbt2w6pRmBlFvV1J+CeUyrSrrRXfnnO1bjIuq05Ur3mV8ULA0qK6rtA5lQ==
"@bazel/bazel-win32_x64@0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-win32_x64/-/bazel-win32_x64-0.18.0.tgz#aa4575fb00066dcf59a6d464971774dea6a0bafd"
integrity sha512-U2TbfK8B7dc3JqXSFwj2oXCQrxEaSzCCUkAHjAOIGOKzx/HLKIKs+NJj9IQkLLr7BsMU+Qqzo8aqo11E+Vs+aA==
"@bazel/bazel@^0.18.1":
version "0.18.1"
resolved "https://registry.yarnpkg.com/@bazel/bazel/-/bazel-0.18.1.tgz#97c235bcc4d40139dd9029b232273b69270ad3a5"
integrity sha512-2KjB0umWsW5or78hTG/RVLmAKmeouyDjqjNsGlOY3pzpj9yqDMG5iDPJh4Q1/hXxiDmF2qZWwqWIEh55LFZXaQ==
optionalDependencies:
"@bazel/bazel-darwin_x64" "0.18.0"
"@bazel/bazel-linux_x64" "0.18.0"
"@bazel/bazel-win32_x64" "0.18.0"
"@bazel/ibazel@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.1.1.tgz#f970c08b4e4efb0ab17e04ade3cc610554f33bed"