From 39818135d38f11db6375a08e8ebab0ef4049952e Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 11 Jul 2019 11:45:17 +0200 Subject: [PATCH] build: do not run bazel through yarn and nodejs We don't want to run Bazel through Yarn or NodeJS as that could mean that Bazel runs with limited memory. --- .circleci/config.yml | 32 ++++++++++++++++++-------- scripts/circleci/setup_bazel_binary.sh | 10 ++++++++ scripts/deploy/publish-docs-content.sh | 2 +- 3 files changed, 34 insertions(+), 10 deletions(-) create mode 100755 scripts/circleci/setup_bazel_binary.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 14a57a72b63..ac2d2396682 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -116,6 +116,13 @@ var_16: &setup_bazel_remote_execution name: "Setup bazel RBE remote execution" command: ./scripts/circleci/bazel/setup-remote-execution.sh +# Sets up the bazel binary globally. We don't want to access bazel through Yarn and NodeJS +# because it could mean that the Bazel child process only has access to limited memory. +var_17: &setup_bazel_binary + run: + name: "Setting up global Bazel binary" + command: ./scripts/circleci/setup_bazel_binary.sh + # ----------------------------- # Container version of CircleCI # ----------------------------- @@ -138,12 +145,13 @@ jobs: steps: - *checkout_code - *restore_cache + - *setup_bazel_binary - *setup_bazel_ci_config - *setup_bazel_remote_execution - *yarn_download - *yarn_install - - run: yarn bazel build src/... --build_tag_filters=-docs-package + - run: bazel build src/... --build_tag_filters=-docs-package # -------------------------------------------------------------------------------------------- # Job that runs ts-api-guardian against our API goldens in "tools/public_api_guard". @@ -157,12 +165,13 @@ jobs: steps: - *checkout_code - *restore_cache + - *setup_bazel_binary - *setup_bazel_ci_config - *setup_bazel_remote_execution - *yarn_download - *yarn_install - - run: yarn bazel test tools/public_api_guard/... + - run: bazel test tools/public_api_guard/... # ----------------------------------------------------------------- # Job that runs the e2e tests with Protractor and Chromium headless @@ -175,12 +184,13 @@ jobs: steps: - *checkout_code - *restore_cache + - *setup_bazel_binary - *setup_bazel_ci_config - *setup_bazel_remote_execution - *yarn_download - *yarn_install - - run: yarn bazel test src/... --test_tag_filters=e2e + - run: bazel test src/... --test_tag_filters=e2e # ------------------------------------------------------------------------------------------ # Job that runs the unit tests on locally installed browsers (Chrome and Firefox headless). @@ -194,12 +204,13 @@ jobs: steps: - *checkout_code - *restore_cache + - *setup_bazel_binary - *setup_bazel_ci_config - *setup_bazel_remote_execution - *yarn_download - *yarn_install - - run: yarn bazel test src/... --build_tag_filters=-e2e --test_tag_filters=-e2e + - run: bazel test src/... --build_tag_filters=-e2e --test_tag_filters=-e2e # ---------------------------------------------------------------------------- # Job that runs the unit tests on Browserstack. The browsers that will be used @@ -343,6 +354,7 @@ jobs: - *checkout_code - *restore_cache - *attach_release_output + - *setup_bazel_binary - *setup_bazel_ci_config - *setup_bazel_remote_execution - *yarn_download @@ -355,7 +367,7 @@ jobs: # TODO(devversion): Ideally the "build_release_packages" job should build all packages with # Bazel, but for now we mix up the Gulp and bazel setup, so we need to build the package here. - - run: yarn bazel build src/material-examples:npm_package --config=release + - run: bazel build src/material-examples:npm_package --config=release - run: ./scripts/circleci/publish-snapshots.sh @@ -392,6 +404,7 @@ jobs: steps: - *checkout_code - *restore_cache + - *setup_bazel_binary - *setup_bazel_ci_config - *setup_bazel_remote_execution - *yarn_download @@ -409,8 +422,8 @@ jobs: # Issue is tracked with FW-1004. - run: sed -i "s/\(_ENABLE_NG_TYPE_CHECKING = \)True/\1False/g" tools/defaults.bzl # Run project tests with ngtsc and the Ivy Angular packages. - - run: yarn bazel build src/... --build_tag_filters=-docs-package --define=compile=aot - - run: yarn bazel test src/... --build_tag_filters=-docs-package --define=compile=aot --test_tag_filters=-e2e + - run: bazel build src/... --build_tag_filters=-docs-package --define=compile=aot + - run: bazel test src/... --build_tag_filters=-docs-package --define=compile=aot --test_tag_filters=-e2e # ---------------------------------------------------------------------------- # Job that runs all Bazel tests against Ivy from angular/angular#master. @@ -423,6 +436,7 @@ jobs: steps: - *checkout_code - *restore_cache + - *setup_bazel_binary - *setup_bazel_ci_config - *setup_bazel_remote_execution - *yarn_download @@ -435,8 +449,8 @@ jobs: # Issue is tracked with FW-1004. - run: sed -i "s/\(_ENABLE_NG_TYPE_CHECKING = \)True/\1False/g" tools/defaults.bzl # Run project tests with ngtsc and the Ivy Angular packages. - - run: yarn bazel build src/... --build_tag_filters=-docs-package --define=compile=aot - - run: yarn bazel test src/... --build_tag_filters=-docs-package --define=compile=aot --test_tag_filters=-e2e + - run: bazel build src/... --build_tag_filters=-docs-package --define=compile=aot + - run: bazel test src/... --build_tag_filters=-docs-package --define=compile=aot --test_tag_filters=-e2e # ---------------------------------------------------------------------------------------- # Workflow definitions. A workflow usually groups multiple jobs together. This is useful if diff --git a/scripts/circleci/setup_bazel_binary.sh b/scripts/circleci/setup_bazel_binary.sh new file mode 100755 index 00000000000..1c61cdcd22c --- /dev/null +++ b/scripts/circleci/setup_bazel_binary.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +bazelBin=$(node -p "require('@bazel/bazel').getNativeBinary()") + +# Provide the bazel binary globally. We don't want to access the binary +# through Node as it could result in limited memory. +sudo chmod a+x ${bazelBin} +sudo ln -fs ${bazelBin} /usr/local/bin/bazel diff --git a/scripts/deploy/publish-docs-content.sh b/scripts/deploy/publish-docs-content.sh index 1b39ff0770f..e6793e4f805 100755 --- a/scripts/deploy/publish-docs-content.sh +++ b/scripts/deploy/publish-docs-content.sh @@ -24,7 +24,7 @@ docsDistPath="${projectPath}/dist/docs" docsContentPath="${projectPath}/tmp/material2-docs-content" # Path to the release output of the Bazel "@angular/material-examples" NPM package. -examplesPackagePath="$(yarn -s bazel info bazel-bin)/src/material-examples/npm_package" +examplesPackagePath="$(bazel info bazel-bin)/src/material-examples/npm_package" # Git clone URL for the material2-docs-content repository. docsContentRepoUrl="https://github.com/angular/material2-docs-content"