Skip to content

Commit 0b1bf14

Browse files
filipesilvaAndrewKushnir
authored andcommitted
ci: use circleci windows preview (angular#31266)
PR Close angular#31266
1 parent d1cc7a0 commit 0b1bf14

File tree

9 files changed

+202
-21
lines changed

9 files changed

+202
-21
lines changed

.bazelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test --test_output=errors
6262
# Settings for CircleCI #
6363
################################
6464

65-
# Bazel flags for CircleCI are in /.circleci/bazel.rc
65+
# Bazel flags for CircleCI are in /.circleci/bazel.linux.rc and /.circleci/bazel.windows.rc
6666

6767
################################
6868
# Temporary Settings for Ivy #

.circleci/bazel.rc renamed to .circleci/bazel.common.rc

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
# These options are enabled when running on CI
2-
# We do this by copying this file to /etc/bazel.bazelrc at the start of the build.
3-
# See documentation in /docs/BAZEL.md
4-
5-
# Save downloaded repositories in a location that can be cached by CircleCI. This helps us
6-
# speeding up the analysis time significantly with Bazel managed node dependencies on the CI.
7-
build --repository_cache=/home/circleci/bazel_repository_cache
1+
# Settings in this file should be OS agnostic. Use the bazel.<OS>.rc files for OS specific settings.
82

93
# Don't be spammy in the logs
104
build --noshow_progress
@@ -14,12 +8,6 @@ build --noshow_progress
148
# (e.g. /etc/bazel.bazelrc vs. tools/bazel.rc)
159
build --announce_rc
1610

17-
# Workaround https://github.com/bazelbuild/bazel/issues/3645
18-
# Bazel doesn't calculate the memory ceiling correctly when running under Docker.
19-
# Limit Bazel to consuming resources that fit in CircleCI "xlarge" class
20-
# https://circleci.com/docs/2.0/configuration-reference/#resource_class
21-
build --local_resources=14336,8.0,1.0
22-
2311
# Retry in the event of flakes, eg. https://circleci.com/gh/angular/angular/31309
2412
test --flaky_test_attempts=2
2513

.circleci/bazel.linux.rc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# These options are enabled when running on CI
2+
# We do this by copying this file to /etc/bazel.bazelrc at the start of the build.
3+
# See documentation in /docs/BAZEL.md
4+
5+
# Import config items common to both Linux and Windows setups.
6+
# https://docs.bazel.build/versions/master/guide.html#bazelrc-syntax-and-semantics
7+
import %workspace%/.circleci/bazel.common.rc
8+
9+
# Save downloaded repositories in a location that can be cached by CircleCI. This helps us
10+
# speeding up the analysis time significantly with Bazel managed node dependencies on the CI.
11+
build --repository_cache=/home/circleci/bazel_repository_cache
12+
13+
# Workaround https://github.com/bazelbuild/bazel/issues/3645
14+
# Bazel doesn't calculate the memory ceiling correctly when running under Docker.
15+
# Limit Bazel to consuming resources that fit in CircleCI "xlarge" class
16+
# https://circleci.com/docs/2.0/configuration-reference/#resource_class
17+
build --local_resources=14336,8.0,1.0

.circleci/bazel.windows.rc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# These options are enabled when running on CI
2+
# We do this by copying this file to $env:ProgramData\bazel.bazelrc at the start of the build.
3+
# See documentation in /docs/BAZEL.md
4+
5+
# Import config items common to both Linux and Windows setups.
6+
# https://docs.bazel.build/versions/master/guide.html#bazelrc-syntax-and-semantics
7+
import %workspace%/.circleci/bazel.common.rc
8+
9+
# Save downloaded repositories in a location that can be cached by CircleCI. This helps us
10+
# speeding up the analysis time significantly with Bazel managed node dependencies on the CI.
11+
build --repository_cache=C:/Users/circleci/bazel_repository_cache

.circleci/config.yml

+116-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var_2: &browsers_docker_image circleci/node:10.16-browsers
2727
# **NOTE 2 **: Keep the static part of the cache key as prefix to enable correct fallbacks.
2828
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
2929
var_3: &cache_key v3-angular-node-10.16-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "packages/bazel/package.bzl" }}-{{ checksum "aio/yarn.lock" }}
30+
var_3_win: &cache_key_win v4-angular-win-node-12.0-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "packages/bazel/package.bzl" }}-{{ checksum "aio/yarn.lock" }}
3031

3132
# Initializes the CI environment by setting up common environment variables.
3233
var_4: &init_environment
@@ -48,6 +49,12 @@ var_4: &init_environment
4849
git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true
4950
git config --global gc.auto 0 || true
5051
52+
var_4_win: &init_environment_win
53+
run:
54+
# Install Bazel pre-requisites that aren't in the preconfigured CircleCI Windows VM.
55+
name: Setup windows node environment
56+
command: ./.circleci/windows-env.ps1
57+
5158

5259
var_5: &setup_bazel_remote_execution
5360
run:
@@ -65,6 +72,24 @@ var_6: &job_defaults
6572
working_directory: ~/ng
6673
docker:
6774
- image: *default_docker_image
75+
var_6_win: &job_defaults_win
76+
working_directory: ~/ng
77+
resource_class: windows.medium
78+
# CircleCI windows VMs do have the GitBash shell available:
79+
# https://github.com/CircleCI-Public/windows-preview-docs#shells
80+
# But in this specific case we really should not use it because Bazel must not be ran from
81+
# GitBash. These issues discuss why:
82+
# https://github.com/bazelbuild/bazel/issues/5751
83+
# https://github.com/bazelbuild/bazel/issues/5724#issuecomment-410194038
84+
# https://github.com/bazelbuild/bazel/issues/6339#issuecomment-441600879
85+
shell: powershell.exe -ExecutionPolicy Bypass
86+
machine:
87+
# Preview image that includes the following:
88+
# - Visual Studio 2019 build tools
89+
# - Node 12
90+
# - yarn 1.17
91+
# - Python 3 3.7.4
92+
image: windows-server-2019-vs2019:201908-02
6893

6994
# After checkout, rebase on top of target branch.
7095
var_7: &post_checkout
@@ -80,6 +105,17 @@ var_7: &post_checkout
80105
else
81106
echo "This build is not over a PR, nothing to do."
82107
fi
108+
var_7_win: &post_checkout_win
109+
run:
110+
name: Rebase PR on target branch
111+
command: >
112+
if (Test-Path env:CIRCLE_PR_NUMBER) {
113+
git config user.name "angular-ci"
114+
git config user.email "angular-ci"
115+
node tools\rebase-pr.js angular/angular-cli $env:CIRCLE_PR_NUMBER
116+
} else {
117+
echo "This build is not over a PR, nothing to do."
118+
}
83119
84120
var_8: &yarn_install
85121
run:
@@ -95,14 +131,25 @@ var_8: &yarn_install
95131
var_9: &setup_circleci_bazel_config
96132
run:
97133
name: Setting up CircleCI bazel configuration
98-
command: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
134+
command: sudo cp .circleci/bazel.linux.rc /etc/bazel.bazelrc
135+
136+
var_9_win: &setup_circleci_bazel_config_win
137+
run:
138+
name: Setting up CircleCI bazel configuration
139+
command: copy .circleci\bazel.windows.rc $env:ProgramData\bazel.bazelrc
99140

100141
var_10: &restore_cache
101142
restore_cache:
102143
keys:
103144
- *cache_key
104145
# This fallback should be the cache_key without variables.
105146
- v3-angular-node-10.16-
147+
var_10_win: &restore_cache_win
148+
restore_cache:
149+
keys:
150+
- *cache_key_win
151+
# This fallback should be the cache_key without variables.
152+
- v4-angular-win-node-12.0-
106153

107154
# Branch filter that can be specified for jobs that should only run on publish branches
108155
# (e.g. master or the patch branch)
@@ -670,6 +717,55 @@ jobs:
670717
cp dist/bin/packages/zone.js/npm_package/dist/zone-patch-electron.js ./packages/zone.js/test/extra/ &&
671718
yarn --cwd packages/zone.js electrontest
672719

720+
# Windows jobs
721+
# Docs: https://circleci.com/docs/2.0/hello-world-windows/
722+
# Skipping workspace for now because it fails to extract on windows.
723+
# TODO: when CircleCI fixes it, split this single job into install/test ones.
724+
# Notes:
725+
# - windows needs its own cache key because binaries in node_modules are different.
726+
# - windows might need its own workspace for the same reason.
727+
test_win:
728+
<<: *job_defaults_win
729+
steps:
730+
- checkout
731+
- *init_environment_win
732+
- *post_checkout_win
733+
# TODO: windows cache restoration is currently failing. Re-enable when it's fixed.
734+
# Example failure: https://circleci.com/gh/angular/angular/423738
735+
# - *restore_cache_win
736+
- *setup_circleci_bazel_config_win
737+
- run: yarn install --frozen-lockfile --non-interactive
738+
# Install @bazel/bazel globally and use that for the first run.
739+
# Workaround for https://github.com/bazelbuild/rules_nodejs/issues/894
740+
- run: yarn global add @bazel/bazel@$env:BAZEL_VERSION
741+
- run: bazel info
742+
# Ran into a command parsing problem where `-browser:chromium-local` was converted to
743+
# `-browser: chromium-local` (a space was added) in https://circleci.com/gh/angular/angular/357511.
744+
# Probably a powershell command parsing thing. This way there's no problem.
745+
- run:
746+
command: yarn circleci-win-ve
747+
no_output_timeout: 45m
748+
# - save_cache:
749+
# key: *cache_key_win
750+
# paths:
751+
# - "node_modules"
752+
# - "C:/Users/circleci/bazel_repository_cache"
753+
test_ivy_aot_win:
754+
<<: *job_defaults_win
755+
steps:
756+
- checkout
757+
- *init_environment_win
758+
- *post_checkout_win
759+
# - *restore_cache_win
760+
- *setup_circleci_bazel_config_win
761+
- run: yarn install --frozen-lockfile --non-interactive
762+
- run: yarn global add @bazel/bazel@$env:BAZEL_VERSION
763+
- run: bazel info
764+
- run:
765+
command: yarn circleci-win-ivy
766+
no_output_timeout: 45m
767+
768+
673769
workflows:
674770
version: 2
675771
default_workflow:
@@ -767,6 +863,25 @@ workflows:
767863
- test_zonejs:
768864
requires:
769865
- setup
866+
# Windows jobs very slow so we run it on non-PRs only for now.
867+
# TODO: remove the filter when CircleCI makes Windows FS faster.
868+
# The Windows jobs are only run after their non-windows counterparts finish successfully.
869+
# This isn't strictly necessary as there is no artifact dependency, but helps economize
870+
# CI resources by not attempting to build when we know should fail.
871+
- test_win:
872+
requires:
873+
- test
874+
filters:
875+
branches:
876+
ignore:
877+
- /pull\/.*/
878+
- test_ivy_aot_win:
879+
requires:
880+
- test_ivy_aot
881+
filters:
882+
branches:
883+
ignore:
884+
- /pull\/.*/
770885

771886
aio_monitoring:
772887
jobs:

.circleci/windows-env.ps1

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Install Bazel pre-reqs on Windows
2+
# https://docs.bazel.build/versions/master/install-windows.html
3+
# https://docs.bazel.build/versions/master/windows.html
4+
# Install MSYS2 and packages
5+
choco install msys2 --version 20180531.0.0 --no-progress --package-parameters "/NoUpdate"
6+
C:\tools\msys64\usr\bin\bash.exe -l -c "pacman --needed --noconfirm -S zip unzip patch diffutils git"
7+
8+
# Add PATH modifications to the Powershell profile. This is the win equivalent of .bash_profile.
9+
# https://docs.microsoft.com/en-us/previous-versions//bb613488(v=vs.85)
10+
new-item -path $profile -itemtype file -force
11+
# Paths for nodejs, npm, yarn, and msys2. Use single quotes to prevent interpolation.
12+
# Add before the original path to use msys2 instead of the installed gitbash.
13+
Add-Content $profile '$Env:path = "${Env:ProgramFiles}\nodejs\;C:\Users\circleci\AppData\Roaming\npm\;${Env:ProgramFiles(x86)}\Yarn\bin\;C:\Users\circleci\AppData\Local\Yarn\bin\;C:\tools\msys64\usr\bin\;" + $Env:path'
14+
# Environment variables for Bazel
15+
Add-Content $profile '$Env:BAZEL_SH = "C:\tools\msys64\usr\bin\bash.exe"'
16+
17+
# Get the bazel version devdep and store it in a global var for use in the circleci job.
18+
$bazelVersion = & ${Env:ProgramFiles}\nodejs\node.exe -e "console.log(require('./package.json').devDependencies['@bazel/bazel'])"
19+
# This is a tricky situation: we want $bazelVersion to be evaluated but not $Env:BAZEL_VERSION.
20+
# Formatting works https://stackoverflow.com/questions/32127583/expand-variable-inside-single-quotes
21+
$bazelVersionGlobalVar = '$Env:BAZEL_VERSION = "{0}"' -f $bazelVersion
22+
Add-Content $profile $bazelVersionGlobalVar
23+
24+
# Remove the CircleCI checkout SSH override, because it breaks cloning repositories through Bazel.
25+
# See https://circleci.com/gh/angular/angular/401454 for an example.
26+
# TODO: is this really needed? Maybe there's a better way. It doesn't happen on Linux or on Codefresh.
27+
git config --global --unset url.ssh://git@github.com.insteadOf
28+
29+
# Print node and yarn versions.
30+
echo "Node version:"
31+
node -v
32+
echo "Yarn version:"
33+
yarn -v
34+
35+
36+
# These Bazel prereqs aren't needed because the CircleCI image already includes them.
37+
# choco install nodejs --version 10.16.0 --no-progress
38+
# choco install yarn --version 1.16.0 --no-progress
39+
# choco install vcredist2015 --version 14.0.24215.20170201
40+
41+
# We don't need VS Build Tools for the tested bazel targets.
42+
# If it's needed again, uncomment these lines.
43+
# VS Build Tools are needed for Bazel C++ targets (like com_google_protobuf)
44+
# choco install visualstudio2019buildtools --version 16.1.2.0 --no-progress --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.Component.VC.Runtime.UCRTSDK --add Microsoft.VisualStudio.Component.Windows10SDK.17763"
45+
# Add-Content $profile '$Env:BAZEL_VC = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\BuildTools\VC\"'
46+
# Python is needed for Bazel Python targets
47+
# choco install python --version 3.5.1 --no-progress

aio/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
},
8080
"//engines-comment": "Keep this in sync with ../package.json",
8181
"engines": {
82-
"node": ">=10.9.0 <11.0.0",
83-
"yarn": ">=1.12.1 <=1.16.0"
82+
"node": ">=10.9.0 <13.0.0",
83+
"yarn": ">=1.12.1 <=1.18.0"
8484
},
8585
"private": true,
8686
"dependencies": {

docs/BAZEL.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Contact Alex Eagle with questions.
177177

178178
1. In `.circleci/config.yml`, each CircleCI job downloads a proxy binary, which is built from https://github.com/notnoopci/bazel-remote-proxy. The download is done by running `.circleci/setup_cache.sh`. When the feature graduates from experimental, this proxy will be installed by default on every CircleCI worker, and this step will not be needed.
179179
1. Next, each job runs the `setup-bazel-remote-cache` anchor. This starts up the proxy running in the background. In the CircleCI UI, you'll see this step continues running while later steps run, and you can see logging from the proxy process.
180-
1. Bazel must be configured to connect to the proxy on a local port. This configuration lives in `.circleci/bazel.rc` and is enabled because we overwrite the system Bazel settings in /etc/bazel.bazelrc with this file.
180+
1. Bazel must be configured to connect to the proxy on a local port. This configuration lives in `.circleci/bazel.linux.rc` and is enabled because we overwrite the system Bazel settings in /etc/bazel.bazelrc with this file.
181181
1. Each `bazel` command in `.circleci/config.yml` picks up and uses the caching flags.
182182

183183
## Diagnosing slow builds

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"license": "MIT",
99
"//engines-comment": "Keep this in sync with aio/package.json",
1010
"engines": {
11-
"node": ">=10.9.0 <11.0.0",
12-
"yarn": ">=1.12.1 <=1.16.0"
11+
"node": ">=10.9.0 <13.0.0",
12+
"yarn": ">=1.12.1 <=1.18.0"
1313
},
1414
"repository": {
1515
"type": "git",
@@ -27,7 +27,10 @@
2727
"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",
2828
"test-fixme-ivy-aot": "bazel test --define=compile=aot --build_tag_filters=-no-ivy-aot --test_tag_filters=-no-ivy-aot",
2929
"list-fixme-ivy-targets": "bazel query --output=label 'attr(\"tags\", \"\\[.*fixme-ivy.*\\]\", //...) except kind(\"sh_binary\", //...) except kind(\"devmode_js_sources\", //...)' | sort",
30-
"bazel": "bazel"
30+
"bazel": "bazel",
31+
"//circleci-win-comment": "See the test-win circleci job for why these are needed. If they are not needed anymore, remove them.",
32+
"circleci-win-ve": "bazel test --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only,-browser:chromium-local //packages/compiler-cli/...",
33+
"circleci-win-ivy": "bazel test --define=compile=aot --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot --test_tag_filters=-no-ivy-aot,-fixme-ivy-aot,-browser:chromium-local //packages/compiler-cli/..."
3134
},
3235
"// 1": "dependencies are used locally and by bazel",
3336
"dependencies": {

0 commit comments

Comments
 (0)