Skip to content

Commit eca5619

Browse files
filipesilvavikerman
authored andcommitted
ci: use cache and workspace on windows
1 parent 33969d5 commit eca5619

File tree

1 file changed

+63
-42
lines changed

1 file changed

+63
-42
lines changed

.circleci/config.yml

Lines changed: 63 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ version: 2.1
1212
# Variables
1313

1414
## IMPORTANT
15-
# If you change the cache key prefix, also sync the restore_cache fallback to match.
15+
# If you change the cache key prefix, also sync the fallback_cache_key fallback to match.
1616
# Keep the static part of the cache key as prefix to enable correct fallbacks.
17+
# Windows needs its own cache key because binaries in node_modules are different.
1718
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
1819
var_1: &cache_key angular_devkit-0.11.0-{{ checksum "yarn.lock" }}
19-
var_2: &default_nodeversion "12.1"
20-
var_3: &attach_options
20+
var_2: &cache_key_fallback angular_devkit-0.11.0
21+
var_1_win: &cache_key_win angular_devkit-win-0.11.0-{{ checksum "yarn.lock" }}
22+
var_2_win: &cache_key_fallback_win angular_devkit-win-0.11.0
23+
var_3: &default_nodeversion "12.1"
24+
var_4: &attach_options
2125
at: .
22-
var_4: &ignore_pull_requests
26+
var_5: &ignore_pull_requests
2327
filters:
2428
branches:
2529
ignore:
@@ -60,24 +64,13 @@ executors:
6064
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands
6165
commands:
6266
setup_windows:
63-
steps:
64-
- checkout
67+
steps:
6568
- run:
66-
# Need to install node and yarn before, as the base windows image doesn't have anything.
67-
# TODO: remove when CircleCI provides preconfigured node images/VMs.
69+
# Need to install node and yarn before to ensure correct versions.
6870
name: Setup windows node environment
69-
command: ./.circleci/windows-env.ps1
70-
# TODO: remove commands other than the e2e runner when workspaces on windows are well supported.
71-
- run:
72-
name: Rebase PR on target branch
73-
command: >
74-
if (Test-Path env:CIRCLE_PR_NUMBER) {
75-
git config user.name "angular-ci"
76-
git config user.email "angular-ci"
77-
node tools\rebase-pr.js angular/angular-cli $env:CIRCLE_PR_NUMBER }
71+
command: ./.circleci/windows-env.ps1
7872
- run: node --version
7973
- run: yarn --version
80-
- run: yarn install --frozen-lockfile
8174

8275
setup_bazel_rbe:
8376
parameters:
@@ -108,7 +101,7 @@ commands:
108101
109102
# Job definitions
110103
jobs:
111-
install:
104+
setup:
112105
executor: action-executor
113106
steps:
114107
- checkout
@@ -127,8 +120,7 @@ jobs:
127120
- restore_cache:
128121
keys:
129122
- *cache_key
130-
# This fallback should be the cache_key without variables.
131-
- angular_devkit-0.11.0-
123+
- *cache_key_fallback
132124
- run: yarn install --frozen-lockfile
133125
- persist_to_workspace:
134126
root: .
@@ -292,19 +284,34 @@ jobs:
292284
# Windows jobs
293285
# CircleCI support for Windows jobs is still in preview.
294286
# Docs: https://github.com/CircleCI-Public/windows-preview-docs
287+
setup-and-build-win:
288+
executor: windows-executor
289+
steps:
290+
- attach_workspace: *attach_options
291+
- setup_windows
292+
- restore_cache:
293+
keys:
294+
- *cache_key_win
295+
- *cache_key_fallback_win
296+
- run: yarn install --frozen-lockfile
297+
- run: yarn build
298+
- save_cache:
299+
key: *cache_key_win
300+
paths:
301+
# Get cache dir on windows via `yarn cache dir`
302+
- C:\Users\circleci\AppData\Local\Yarn\Cache\v4
303+
# Only jobs downstream from this one will see the updated workspace
304+
# https://circleci.com/blog/deep-diving-into-circleci-workspaces/
305+
- persist_to_workspace:
306+
root: .
307+
paths:
308+
- ./*
309+
295310
test-win:
296311
executor: windows-executor
297-
# Skipping cache and workspace for now because it takes 10x longer than on linux.
298-
# TODO: when/if CircleCI makes them faster, use cache and workspaces fully.
299-
# Notes:
300-
# - windows needs its own cache key because binaries in node_modules are different.
301-
# - windows might need its own workspace for the same reason.
302-
# - get cache dir on windows via `yarn cache dir` (was `C:\Users\circleci\AppData\Local\Yarn\Cache\v4` last time)
303312
steps:
313+
- attach_workspace: *attach_options
304314
- setup_windows
305-
# Build and test should be on their own jobs, but restoring workspaces is too slow
306-
# so we do it here.
307-
- run: yarn build
308315
- run: yarn test --full
309316
# Run partial e2e suite on PRs only. Master will run the full e2e suite with sharding.
310317
- run: if (Test-Path env:CIRCLE_PR_NUMBER) { node tests\legacy-cli\run_e2e.js "--glob=tests/{basic,ivy}/**" }
@@ -314,23 +321,23 @@ jobs:
314321
parallelism: 4
315322
steps:
316323
- setup_windows
317-
- run: yarn build
318324
- run: node tests\legacy-cli\run_e2e.js --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX
319325

320326
workflows:
321327
version: 2
322328
default_workflow:
323329
jobs:
324-
- install
330+
# Linux jobs
331+
- setup
325332
- lint:
326333
requires:
327-
- install
334+
- setup
328335
- validate:
329336
requires:
330-
- install
337+
- setup
331338
- build:
332339
requires:
333-
- install
340+
- setup
334341
filters:
335342
branches:
336343
ignore:
@@ -341,9 +348,6 @@ workflows:
341348
- test:
342349
requires:
343350
- build
344-
- test-win:
345-
requires:
346-
- test
347351
- test-large:
348352
requires:
349353
- build
@@ -396,16 +400,33 @@ workflows:
396400
<<: *ignore_pull_requests
397401
requires:
398402
- e2e-cli
399-
- e2e-cli-win:
400-
<<: *ignore_pull_requests
401-
requires:
402-
- e2e-cli
403403
- test-browsers:
404404
requires:
405405
- build
406406
- flake-jail:
407407
requires:
408+
- build
409+
410+
# Windows jobs
411+
# These jobs only run after their non-windows counterparts finish successfully.
412+
# This isn't strictly necessary as there is no artifact dependency, but helps economize
413+
# CI resources by not attempting to build when we know it should fail.
414+
- setup-and-build-win:
415+
requires:
416+
# The Linux setup job also does checkout and rebase, which we get via the workspace.
417+
- setup
408418
- build
419+
- test-win:
420+
requires:
421+
- setup-and-build-win
422+
- test
423+
- e2e-cli-win:
424+
<<: *ignore_pull_requests
425+
requires:
426+
- setup-and-build-win
427+
- e2e-cli
428+
429+
# Publish jobs
409430
- snapshot_publish:
410431
<<: *ignore_pull_requests
411432
requires:

0 commit comments

Comments
 (0)