From 5da90e9075b304adf14c40643b1bdd0ec057f3cd Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Tue, 25 Jun 2019 13:07:00 -0700 Subject: [PATCH] ci: setup RBE on CI --- .bazelrc | 54 +++++++++++++++++++++++++++++ .circleci/config.yml | 22 ++++++++++++ .circleci/gcp_token | Bin 0 -> 2352 bytes WORKSPACE | 31 +++++++++++++++++ packages/angular_devkit/core/BUILD | 2 ++ packages/schematics/update/BUILD | 2 ++ tools/BUILD | 13 +++++++ 7 files changed, 124 insertions(+) create mode 100644 .circleci/gcp_token diff --git a/.bazelrc b/.bazelrc index 722747468c..776a8225c3 100644 --- a/.bazelrc +++ b/.bazelrc @@ -6,3 +6,57 @@ build --strategy=TypeScriptCompile=worker build --watchfs test --test_output=errors + +################################ +# Remote Execution Setup # +################################ + + # Use the Angular team internal GCP instance for remote execution. +build:remote --remote_instance_name=projects/internal-200822/instances/default_instance +build:remote --project_id=internal-200822 + + # Setup the build strategy for various types of actions. Mixing "local" and "remote" +# can cause unexpected results and we want to run everything remotely if possible. +build:remote --spawn_strategy=remote +build:remote --strategy=Javac=remote +build:remote --strategy=Closure=remote +build:remote --strategy=Genrule=remote +build:remote --define=EXECUTOR=remote + + # Setup the remote build execution servers. +build:remote --remote_cache=remotebuildexecution.googleapis.com +build:remote --remote_executor=remotebuildexecution.googleapis.com +build:remote --tls_enabled=true +build:remote --auth_enabled=true +build:remote --remote_timeout=3600 +build:remote --jobs=50 + + # Setup the toolchain and platform for the remote build execution. The platform +# is automatically configured by the "rbe_autoconfig" rule in the project workpsace. +build:remote --host_javabase=@rbe_ubuntu1604_angular//java:jdk +build:remote --javabase=@rbe_ubuntu1604_angular//java:jdk +build:remote --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 +build:remote --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 +build:remote --crosstool_top=@rbe_ubuntu1604_angular//cc:toolchain +build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 +build:remote --extra_toolchains=@rbe_ubuntu1604_angular//config:cc-toolchain +build:remote --extra_execution_platforms=//tools:rbe_ubuntu1604-angular +build:remote --host_platform=//tools:rbe_ubuntu1604-angular +build:remote --platforms=//tools:rbe_ubuntu1604-angular + + # Setup Build Event Service +build:remote --bes_backend=buildeventservice.googleapis.com +build:remote --bes_timeout=30s +build:remote --bes_results_url="https://source.cloud.google.com/results/invocations/" + + # Set remote caching settings +build:remote --remote_accept_cached=true + +#################################################### +# User bazel configuration +# NOTE: This needs to be the *last* entry in the config. +#################################################### + +# Load any settings which are specific to the current user. Needs to be *last* statement +# in this config, as the user configuration should be able to overwrite flags from this file. +try-import .bazelrc.user diff --git a/.circleci/config.yml b/.circleci/config.yml index 291a72a17b..a262535ecd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -71,6 +71,27 @@ anchor_6: &ignore_pull_requests branches: ignore: - /pull\/.*/ +anchor_7: &setup_bazel_remote_execution + run: + name: "Setup bazel RBE remote execution" + command: | + touch .bazelrc.user; + # We need ensure that the same default digest is used for encoding and decoding + # with openssl. Openssl versions might have different default digests which can + # cause decryption failures based on the openssl version. https://stackoverflow.com/a/39641378/4317734 + openssl aes-256-cbc -d -in .circleci/gcp_token -md md5 -k "${CIRCLE_PROJECT_REPONAME}" -out /home/circleci/.gcp_credentials; + sudo bash -c "echo -e 'build --google_credentials=/home/circleci/.gcp_credentials' >> .bazelrc.user"; + # Upload/don't upload local results to cache based on environment + if [[ -n "{$CIRCLE_PR_NUMBER}" ]]; then + sudo bash -c "echo -e 'build:remote --remote_upload_local_results=false\n' >> .bazelrc.user"; + echo "Not uploading local build results to remote cache."; + else + sudo bash -c "echo -e 'build:remote --remote_upload_local_results=true\n' >> .bazelrc.user"; + echo "Uploading local build results to remote cache."; + fi + # Enable remote builds + sudo bash -c "echo -e 'build --config=remote' >> .bazelrc.user"; + echo "Reading from remote cache for bazel remote jobs."; # Job definitions version: 2.1 @@ -204,6 +225,7 @@ jobs: resource_class: xlarge steps: - attach_workspace: *attach_options + - *setup_bazel_remote_execution - run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc - run: yarn bazel:test diff --git a/.circleci/gcp_token b/.circleci/gcp_token new file mode 100644 index 0000000000000000000000000000000000000000..06773903e8d854c81189f19d5db30380de71c5f5 GIT binary patch literal 2352 zcmV-03D5RZVQh3|WM5xLFak`XkkRX1|29dfyw?5eewT>mKEM8Y^Z70anA#cpL~ z1w~VTBsjj^dQJy(yTVmnI^_OhHwzHa#{6&wC}E1CCt)D%w#>7qf=HD69$jUp*gdI~ zm>P!IeQihhLi#S!-XOADbRsWWnDggItO(JNx3yOf=YUBI1p^XlS-?6nDYL@H0Qz~z z$Jn%LTX?dV)n!WIcRYgEROMgI?QC8m_nX0~(q^oW^#JFmb#zUw;Fzj$ABYnDK_W&1 zpOCk4wvN_-Vh{jk7>QZ5Z_prIRgu0JwEuug+bG8x%$L@LRJU^kR=~at@x45Ry8(dc zP;1<1mSy(8DZ$j(K(0!>!YF>fMwwk@zv$bp6|!o@q@FY=ZR?y6_;Ui&7RtAzvd`Tr zZ z`GPTuDR~t16Ol`K1@S=_FOs2%`byotftll`B20LV1+~*BzOfYCe2?jR`6HC5$hn?2 zG$ZO?Pk$e$?efB{IJmDz?tI|m-powtB3_QUCc32PiM-9dC=bSXY%|L}1_|u>lMDE( zla#^L7Z-%AW-MvSV9iZ-<-O#2GRoVX%Pwn)#fbjY8CY}Gr9$FV4s?hH+1N@dD4^2a z@uRn_`N!?7t&S1X$ik=(tLQE^TO~`9atvqdr%+5yDwMytvgd$=(bd06Xz60b^PAJa z28uRMJ%MW_0|UBk$gjlDB~p0OC@HL3tSlT~o2-=RcO2A#&F!RH%(f$jO9xGP8thg`u{nFi{q4lrIB}_ir;QOz6fx*%a3D`yZ@fWn#iZNO0hGa2bvSxnm+O%yO{Y+i z_Ql*P@odkEu^JHuyzQ+A^26D1%fjPdnr@MS^$+nLi3FCQ=5U{w7dBi-{O2oAl$LEy zy;WPX#4MqFSb&dQ!E@|vFm)HRCYDSnIy<^Luzy5qtA};U%^x2ivd<26(1NCie^o1U z(ypIdIS(J@WT+VJ{-a8$ouDh;k6=U@yvBYDo=;PP&omT+sWr2=Z zWLa)ELHsDy4q@A_7Uy_rt+$=!Ot>$m^$b&a@471wYi39i`7JZ5!`9PMB50ACwX26u z{$%0>?|sOGXgGEFq(%cX2{D0>{%1Bf3;t39xbyZjp1>}8=NfVtH)k-)?WsH!nNrr( z74_XwRsuBTjM(}C*Mh~eKn+pno?oK{V+N&nGlm30xOW}gzh9CiXD47FE9AV&4t8S= zx$Td>X1wWK70BV_ETQop{n@~KQOe!*mDNZ%Ff|AhhT z5ddSN^CGhAB(pzW)+%EltwIDZ8BGO^+(_f)*`}qaLhw8_hZhimjw?4!5i8kQRLo%& z)mrRARx&BN*>04^9K_n_RF~&|y$P*Dju=z#PRZ(x4aw#`gme7a-Ldgh3S zu@_jM@m$L*7$?JjPvfkHz@(gA;qk1vo3wF@afaZA0!*Z8$@%#Xr5azxQIs}}^0fEm zMBd@shSZHW93?Lr+-#;n#+zh7bggosPF9#b@^Vze>efjmXz)X(zA)}VsM+IBam{p zcqPe!Lup`?$yrC0@5pXQ@*cTnx}oGlmCxO>DS6jJnK&s{;I%Cp`Zt=x7=K< zYyz&i+qBY@OEa6H=}MO^kf1%y&5}-4?5h+m{&9QHpym=AAt%BmIrY+lf*RVrT-`I6jx!>IXBaaKBC$H literal 0 HcmV?d00001 diff --git a/WORKSPACE b/WORKSPACE index 3feedcb097..cdcdc0042c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -80,3 +80,34 @@ rules_karma_dependencies() load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories") web_test_repositories() + +########################## +# Remote Execution Setup # +########################## +# Bring in bazel_toolchains for RBE setup configuration. +http_archive( + name = "bazel_toolchains", + sha256 = "142bcbd8cb751ce1193a1d7fef4e328493cd0a69cc0555183ad237f81418ba40", + strip_prefix = "bazel-toolchains-628224f6cf48e81116d0ee0bf65424eaa630d5b3", + urls = ["https://github.com/xingao267/bazel-toolchains/archive/628224f6cf48e81116d0ee0bf65424eaa630d5b3.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", + # 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: + # and marketplace.gcr.io/google/rbe-ubuntu16-04: 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", + env = clang_env(), + registry = "marketplace.gcr.io", + repository = "google/rbe-ubuntu16-04-webtest", +) diff --git a/packages/angular_devkit/core/BUILD b/packages/angular_devkit/core/BUILD index d6e45f65c3..8710c39430 100644 --- a/packages/angular_devkit/core/BUILD +++ b/packages/angular_devkit/core/BUILD @@ -70,6 +70,8 @@ ts_library( jasmine_node_test( name = "core_test", srcs = [":core_test_lib"], + # TODO: Audit tests to determine if tests can be run in RBE environments + local = True, deps = [ "@npm//jasmine", "@npm//source-map", diff --git a/packages/schematics/update/BUILD b/packages/schematics/update/BUILD index dc2b8c99d7..25f8733983 100644 --- a/packages/schematics/update/BUILD +++ b/packages/schematics/update/BUILD @@ -79,6 +79,8 @@ ts_library( jasmine_node_test( name = "update_test", srcs = [":update_test_lib"], + # TODO: Audit tests to determine if tests can be run in RBE environments + local = True, deps = [ "@npm//jasmine", "@npm//npm-registry-client", diff --git a/tools/BUILD b/tools/BUILD index 707a630934..642792dc24 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -21,4 +21,17 @@ nodejs_binary( "--node_options=--preserve-symlinks", ], ) + +platform( + name = "rbe_ubuntu1604-angular", + parents = ["@rbe_ubuntu1604_angular//config:platform"], + remote_execution_properties = """ + {PARENT_REMOTE_EXECUTION_PROPERTIES} + properties: { + name: "dockerAddCapabilities" + value: "SYS_ADMIN" + } + """, +) + # @external_end