ci: use circleci windows preview (#31266)

PR Close #31266
This commit is contained in:
Filipe Silva 2019-07-25 15:47:02 +01:00 committed by Andrew Kushnir
parent d1cc7a0b26
commit 0b1bf14cd8
9 changed files with 202 additions and 21 deletions

View File

@ -62,7 +62,7 @@ test --test_output=errors
# Settings for CircleCI #
################################
# Bazel flags for CircleCI are in /.circleci/bazel.rc
# Bazel flags for CircleCI are in /.circleci/bazel.linux.rc and /.circleci/bazel.windows.rc
################################
# Temporary Settings for Ivy #

View File

@ -1,10 +1,4 @@
# These options are enabled when running on CI
# We do this by copying this file to /etc/bazel.bazelrc at the start of the build.
# See documentation in /docs/BAZEL.md
# Save downloaded repositories in a location that can be cached by CircleCI. This helps us
# speeding up the analysis time significantly with Bazel managed node dependencies on the CI.
build --repository_cache=/home/circleci/bazel_repository_cache
# Settings in this file should be OS agnostic. Use the bazel.<OS>.rc files for OS specific settings.
# Don't be spammy in the logs
build --noshow_progress
@ -14,12 +8,6 @@ build --noshow_progress
# (e.g. /etc/bazel.bazelrc vs. tools/bazel.rc)
build --announce_rc
# Workaround https://github.com/bazelbuild/bazel/issues/3645
# Bazel doesn't calculate the memory ceiling correctly when running under Docker.
# Limit Bazel to consuming resources that fit in CircleCI "xlarge" class
# https://circleci.com/docs/2.0/configuration-reference/#resource_class
build --local_resources=14336,8.0,1.0
# Retry in the event of flakes, eg. https://circleci.com/gh/angular/angular/31309
test --flaky_test_attempts=2

17
.circleci/bazel.linux.rc Normal file
View File

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

View File

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

View File

@ -27,6 +27,7 @@ var_2: &browsers_docker_image circleci/node:10.16-browsers
# **NOTE 2 **: Keep the static part of the cache key as prefix to enable correct fallbacks.
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
var_3: &cache_key v3-angular-node-10.16-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "packages/bazel/package.bzl" }}-{{ checksum "aio/yarn.lock" }}
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" }}
# Initializes the CI environment by setting up common environment variables.
var_4: &init_environment
@ -48,6 +49,12 @@ var_4: &init_environment
git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true
git config --global gc.auto 0 || true
var_4_win: &init_environment_win
run:
# Install Bazel pre-requisites that aren't in the preconfigured CircleCI Windows VM.
name: Setup windows node environment
command: ./.circleci/windows-env.ps1
var_5: &setup_bazel_remote_execution
run:
@ -65,6 +72,24 @@ var_6: &job_defaults
working_directory: ~/ng
docker:
- image: *default_docker_image
var_6_win: &job_defaults_win
working_directory: ~/ng
resource_class: windows.medium
# CircleCI windows VMs do have the GitBash shell available:
# https://github.com/CircleCI-Public/windows-preview-docs#shells
# But in this specific case we really should not use it because Bazel must not be ran from
# GitBash. These issues discuss why:
# https://github.com/bazelbuild/bazel/issues/5751
# https://github.com/bazelbuild/bazel/issues/5724#issuecomment-410194038
# https://github.com/bazelbuild/bazel/issues/6339#issuecomment-441600879
shell: powershell.exe -ExecutionPolicy Bypass
machine:
# Preview image that includes the following:
# - Visual Studio 2019 build tools
# - Node 12
# - yarn 1.17
# - Python 3 3.7.4
image: windows-server-2019-vs2019:201908-02
# After checkout, rebase on top of target branch.
var_7: &post_checkout
@ -80,6 +105,17 @@ var_7: &post_checkout
else
echo "This build is not over a PR, nothing to do."
fi
var_7_win: &post_checkout_win
run:
name: Rebase PR on target branch
command: >
if (Test-Path env:CIRCLE_PR_NUMBER) {
git config user.name "angular-ci"
git config user.email "angular-ci"
node tools\rebase-pr.js angular/angular-cli $env:CIRCLE_PR_NUMBER
} else {
echo "This build is not over a PR, nothing to do."
}
var_8: &yarn_install
run:
@ -95,7 +131,12 @@ var_8: &yarn_install
var_9: &setup_circleci_bazel_config
run:
name: Setting up CircleCI bazel configuration
command: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
command: sudo cp .circleci/bazel.linux.rc /etc/bazel.bazelrc
var_9_win: &setup_circleci_bazel_config_win
run:
name: Setting up CircleCI bazel configuration
command: copy .circleci\bazel.windows.rc $env:ProgramData\bazel.bazelrc
var_10: &restore_cache
restore_cache:
@ -103,6 +144,12 @@ var_10: &restore_cache
- *cache_key
# This fallback should be the cache_key without variables.
- v3-angular-node-10.16-
var_10_win: &restore_cache_win
restore_cache:
keys:
- *cache_key_win
# This fallback should be the cache_key without variables.
- v4-angular-win-node-12.0-
# Branch filter that can be specified for jobs that should only run on publish branches
# (e.g. master or the patch branch)
@ -670,6 +717,55 @@ jobs:
cp dist/bin/packages/zone.js/npm_package/dist/zone-patch-electron.js ./packages/zone.js/test/extra/ &&
yarn --cwd packages/zone.js electrontest
# Windows jobs
# Docs: https://circleci.com/docs/2.0/hello-world-windows/
# Skipping workspace for now because it fails to extract on windows.
# TODO: when CircleCI fixes it, split this single job into install/test ones.
# Notes:
# - windows needs its own cache key because binaries in node_modules are different.
# - windows might need its own workspace for the same reason.
test_win:
<<: *job_defaults_win
steps:
- checkout
- *init_environment_win
- *post_checkout_win
# TODO: windows cache restoration is currently failing. Re-enable when it's fixed.
# Example failure: https://circleci.com/gh/angular/angular/423738
# - *restore_cache_win
- *setup_circleci_bazel_config_win
- run: yarn install --frozen-lockfile --non-interactive
# Install @bazel/bazel globally and use that for the first run.
# Workaround for https://github.com/bazelbuild/rules_nodejs/issues/894
- run: yarn global add @bazel/bazel@$env:BAZEL_VERSION
- run: bazel info
# Ran into a command parsing problem where `-browser:chromium-local` was converted to
# `-browser: chromium-local` (a space was added) in https://circleci.com/gh/angular/angular/357511.
# Probably a powershell command parsing thing. This way there's no problem.
- run:
command: yarn circleci-win-ve
no_output_timeout: 45m
# - save_cache:
# key: *cache_key_win
# paths:
# - "node_modules"
# - "C:/Users/circleci/bazel_repository_cache"
test_ivy_aot_win:
<<: *job_defaults_win
steps:
- checkout
- *init_environment_win
- *post_checkout_win
# - *restore_cache_win
- *setup_circleci_bazel_config_win
- run: yarn install --frozen-lockfile --non-interactive
- run: yarn global add @bazel/bazel@$env:BAZEL_VERSION
- run: bazel info
- run:
command: yarn circleci-win-ivy
no_output_timeout: 45m
workflows:
version: 2
default_workflow:
@ -767,6 +863,25 @@ workflows:
- test_zonejs:
requires:
- setup
# Windows jobs very slow so we run it on non-PRs only for now.
# TODO: remove the filter when CircleCI makes Windows FS faster.
# The Windows jobs are only run after their non-windows counterparts finish successfully.
# This isn't strictly necessary as there is no artifact dependency, but helps economize
# CI resources by not attempting to build when we know should fail.
- test_win:
requires:
- test
filters:
branches:
ignore:
- /pull\/.*/
- test_ivy_aot_win:
requires:
- test_ivy_aot
filters:
branches:
ignore:
- /pull\/.*/
aio_monitoring:
jobs:

47
.circleci/windows-env.ps1 Normal file
View File

@ -0,0 +1,47 @@
# Install Bazel pre-reqs on Windows
# https://docs.bazel.build/versions/master/install-windows.html
# https://docs.bazel.build/versions/master/windows.html
# Install MSYS2 and packages
choco install msys2 --version 20180531.0.0 --no-progress --package-parameters "/NoUpdate"
C:\tools\msys64\usr\bin\bash.exe -l -c "pacman --needed --noconfirm -S zip unzip patch diffutils git"
# Add PATH modifications to the Powershell profile. This is the win equivalent of .bash_profile.
# https://docs.microsoft.com/en-us/previous-versions//bb613488(v=vs.85)
new-item -path $profile -itemtype file -force
# Paths for nodejs, npm, yarn, and msys2. Use single quotes to prevent interpolation.
# Add before the original path to use msys2 instead of the installed gitbash.
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'
# Environment variables for Bazel
Add-Content $profile '$Env:BAZEL_SH = "C:\tools\msys64\usr\bin\bash.exe"'
# Get the bazel version devdep and store it in a global var for use in the circleci job.
$bazelVersion = & ${Env:ProgramFiles}\nodejs\node.exe -e "console.log(require('./package.json').devDependencies['@bazel/bazel'])"
# This is a tricky situation: we want $bazelVersion to be evaluated but not $Env:BAZEL_VERSION.
# Formatting works https://stackoverflow.com/questions/32127583/expand-variable-inside-single-quotes
$bazelVersionGlobalVar = '$Env:BAZEL_VERSION = "{0}"' -f $bazelVersion
Add-Content $profile $bazelVersionGlobalVar
# Remove the CircleCI checkout SSH override, because it breaks cloning repositories through Bazel.
# See https://circleci.com/gh/angular/angular/401454 for an example.
# TODO: is this really needed? Maybe there's a better way. It doesn't happen on Linux or on Codefresh.
git config --global --unset url.ssh://git@github.com.insteadOf
# Print node and yarn versions.
echo "Node version:"
node -v
echo "Yarn version:"
yarn -v
# These Bazel prereqs aren't needed because the CircleCI image already includes them.
# choco install nodejs --version 10.16.0 --no-progress
# choco install yarn --version 1.16.0 --no-progress
# choco install vcredist2015 --version 14.0.24215.20170201
# We don't need VS Build Tools for the tested bazel targets.
# If it's needed again, uncomment these lines.
# VS Build Tools are needed for Bazel C++ targets (like com_google_protobuf)
# 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"
# Add-Content $profile '$Env:BAZEL_VC = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\BuildTools\VC\"'
# Python is needed for Bazel Python targets
# choco install python --version 3.5.1 --no-progress

View File

@ -79,8 +79,8 @@
},
"//engines-comment": "Keep this in sync with ../package.json",
"engines": {
"node": ">=10.9.0 <11.0.0",
"yarn": ">=1.12.1 <=1.16.0"
"node": ">=10.9.0 <13.0.0",
"yarn": ">=1.12.1 <=1.18.0"
},
"private": true,
"dependencies": {

View File

@ -177,7 +177,7 @@ Contact Alex Eagle with questions.
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.
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.
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.
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.
1. Each `bazel` command in `.circleci/config.yml` picks up and uses the caching flags.
## Diagnosing slow builds

View File

@ -8,8 +8,8 @@
"license": "MIT",
"//engines-comment": "Keep this in sync with aio/package.json",
"engines": {
"node": ">=10.9.0 <11.0.0",
"yarn": ">=1.12.1 <=1.16.0"
"node": ">=10.9.0 <13.0.0",
"yarn": ">=1.12.1 <=1.18.0"
},
"repository": {
"type": "git",
@ -27,7 +27,10 @@
"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",
"list-fixme-ivy-targets": "bazel query --output=label 'attr(\"tags\", \"\\[.*fixme-ivy.*\\]\", //...) except kind(\"sh_binary\", //...) except kind(\"devmode_js_sources\", //...)' | sort",
"bazel": "bazel"
"bazel": "bazel",
"//circleci-win-comment": "See the test-win circleci job for why these are needed. If they are not needed anymore, remove them.",
"circleci-win-ve": "bazel test --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only,-browser:chromium-local //packages/compiler-cli/...",
"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/..."
},
"// 1": "dependencies are used locally and by bazel",
"dependencies": {