Skip to content

Commit 7f79a49

Browse files
committed
ci: add circleci windows preview
1 parent 410b56e commit 7f79a49

File tree

7 files changed

+93
-8
lines changed

7 files changed

+93
-8
lines changed

.circleci/config.yml

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ anchor_1: &defaults
2323
working_directory: ~/ng
2424
docker:
2525
- image: *default_docker_image
26+
anchor_1_win: &defaults_win
27+
working_directory: ~/ng
28+
resource_class: windows.medium
29+
shell: powershell.exe -ExecutionPolicy Bypass
30+
machine:
31+
image: windows-server-2019
2632

2733
# After checkout, rebase on top of target branch.
2834
anchor_2: &post_checkout
@@ -38,6 +44,14 @@ anchor_2: &post_checkout
3844
else
3945
echo "This build is not over a PR, nothing to do."
4046
fi
47+
anchor_2_win: &post_checkout_win
48+
run:
49+
name: Rebase PR on target branch
50+
command: >
51+
if (Test-Path env:CIRCLE_PR_NUMBER) {
52+
git config user.name "angular-ci"
53+
git config user.email "angular-ci"
54+
node tools\rebase-pr.js angular/angular-cli $env:CIRCLE_PR_NUMBER }
4155
anchor_3: &restore_cache
4256
restore_cache:
4357
keys:
@@ -46,9 +60,15 @@ anchor_3: &restore_cache
4660
- angular_devkit-0.7.0-
4761
anchor_4: &attach_options
4862
at: .
63+
anchor_5: &env_win
64+
run:
65+
# Need to install node and yarn before, as the base windows image doesn't have anything.
66+
# TODO: remove when CircleCI provides preconfigured node images/VMs.
67+
name: Setup windows node environment
68+
command: ./.circleci/windows-env.ps1
4969

5070
# Job definitions
51-
version: 2
71+
version: 2.1
5272
jobs:
5373
install:
5474
<<: *defaults
@@ -202,6 +222,45 @@ jobs:
202222
command: |
203223
npm run admin -- publish --verbose
204224
225+
# Windows jobs
226+
# CircleCI support for Windows jobs is still in preview.
227+
# Docs: https://github.com/CircleCI-Public/windows-preview-docs
228+
test-win:
229+
<<: *defaults_win
230+
# Skipping cache and workspace for now because it takes 10x longer than on linux.
231+
# TODO: when/if CircleCI makes them faster, use cache and workspaces fully.
232+
# Notes:
233+
# - windows needs its own cache key because binaries in node_modules are different.
234+
# - windows might need its own workspace for the same reason.
235+
# - get cache dir on windows via `yarn cache dir` (was `C:\Users\circleci\AppData\Local\Yarn\Cache\v4` last time)
236+
steps:
237+
- checkout
238+
- *env_win
239+
- *post_checkout_win
240+
- run: node --version
241+
- run: yarn --version
242+
- run: yarn install --frozen-lockfile
243+
# Build and test should be on their own jobs, but restoring workspaces is too slow
244+
# so we do it here.
245+
- run: npm run admin -- build
246+
- run: npm run test -- --full
247+
# Run partial e2e suite on PRs only. Master will run the full e2e suite with sharding.
248+
- run: if (Test-Path env:CIRCLE_PR_NUMBER) { node tests\legacy-cli\run_e2e.js "--glob=tests/{basic,ivy}/**" }
249+
250+
e2e-cli-win:
251+
<<: *defaults_win
252+
parallelism: 4
253+
steps:
254+
- checkout
255+
- *env_win
256+
# TODO: remove commands other than the e2e runner when workspaces on windows are well supported.
257+
- *post_checkout_win
258+
- run: node --version
259+
- run: yarn --version
260+
- run: yarn install --frozen-lockfile
261+
- run: npm run admin -- build
262+
- run: node tests\legacy-cli\run_e2e.js --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX
263+
205264
workflows:
206265
version: 2
207266
default_workflow:
@@ -237,7 +296,7 @@ workflows:
237296
- build
238297
- e2e-cli-ivy:
239298
requires:
240-
- build
299+
- build
241300
- snapshot_publish_docs:
242301
requires:
243302
- install
@@ -248,6 +307,15 @@ workflows:
248307
- e2e-cli-ng-snapshots:
249308
requires:
250309
- build
310+
- test-win:
311+
requires:
312+
- test
313+
- e2e-cli-win:
314+
requires:
315+
- e2e-cli
316+
branches:
317+
ignore:
318+
- /pull\/.*/
251319
- snapshot_publish:
252320
requires:
253321
- test

.circleci/windows-env.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Install nodejs and yarn via Chocolatey.
2+
choco install nodejs --version 12.1.0 --no-progress
3+
choco install yarn --version 1.16.0 --no-progress
4+
5+
# Add PATH modifications to the Powershell profile. This is the win equivalent of .bash_profile.
6+
# https://docs.microsoft.com/en-us/previous-versions//bb613488(v=vs.85)
7+
new-item -path $profile -itemtype file -force
8+
# Paths for nodejs, npm, and yarn. Use single quotes to prevent interpolation.
9+
Add-Content $profile '$Env:path += ";C:\Program Files\nodejs\;C:\Users\circleci\AppData\Roaming\npm\;C:\Program Files (x86)\Yarn\bin\;"'

lib/bootstrap-local.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ const oldRequireTs = require.extensions['.ts'];
8787
require.extensions['.ts'] = function (m, filename) {
8888
// If we're in node module, either call the old hook or simply compile the
8989
// file without transpilation. We do not touch node_modules/**.
90-
// We do touch `Angular DevK` files anywhere though.
91-
if (!filename.match(/@angular\/cli\b/) && filename.match(/node_modules/)) {
90+
// To account for Yarn workspaces symlinks, we much check the real path.
91+
if (fs.realpathSync(filename).match(/node_modules/)) {
9292
if (oldRequireTs) {
9393
return oldRequireTs(m, filename);
9494
}
95-
return m._compile(fs.readFileSync(filename), filename);
95+
return m._compile(fs.readFileSync(filename).toString(), filename);
9696
}
9797

9898
debugBuildTs(filename);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"url": "https://github.com/angular/angular-cli.git"
4444
},
4545
"engines": {
46-
"node": ">=10.9.0 <11.0.0",
46+
"node": ">=10.9.0 <13.0.0",
4747
"yarn": ">=1.9.0 <2.0.0"
4848
},
4949
"author": "Angular Authors",

packages/schematics/angular/universal/index_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ describe('Universal Schematic', () => {
164164
const filePath = '/projects/bar/src/main.ts';
165165
const contents = tree.readContent(filePath);
166166
expect(contents)
167-
.toMatch(/document.addEventListener\('DOMContentLoaded', \(\) => {[\w\W]+;[\r\n]}\);/);
167+
.toMatch(/document.addEventListener\('DOMContentLoaded', \(\) => {/);
168168
});
169169

170170
it('should wrap the bootstrap declaration in a DOMContentLoaded event handler', async () => {

tests/legacy-cli/e2e/tests/generate/directive/directive-prefix.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {join} from 'path';
22
import {ng} from '../../../utils/process';
33
import {expectFileToMatch} from '../../../utils/fs';
4-
import { updateJsonFile } from '../../../utils/project';
4+
import { updateJsonFile, useCIChrome, useCIDefaults } from '../../../utils/project';
55

66

77
export default function() {
@@ -17,6 +17,8 @@ export default function() {
1717
.then(() => expectFileToMatch(join(directiveDir, 'test2-directive.directive.ts'),
1818
/selector: '\[preW/))
1919
.then(() => ng('generate', 'application', 'app-two', '--skip-install'))
20+
.then(() => useCIDefaults('app-two'))
21+
.then(() => useCIChrome('./projects/app-two'))
2022
.then(() => updateJsonFile('angular.json', configJson => {
2123
configJson.projects['test-project'].schematics = {
2224
'@schematics/angular:directive': { prefix: 'preP' }

tests/legacy-cli/e2e/tests/misc/title.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { execAndWaitForOutputToMatch, execWithEnv, killAllProcesses } from '../.
22

33

44
export default async function() {
5+
if (process.platform.startsWith('win')) {
6+
// "On Windows, process.title affects the console title, but not the name of the process in the task manager."
7+
// https://stackoverflow.com/questions/44756196/how-to-change-the-node-js-process-name-on-windows-10#comment96259375_44756196
8+
return Promise.resolve();
9+
}
10+
511
try {
612
await execAndWaitForOutputToMatch('ng', ['build', '--watch'], /./);
713

0 commit comments

Comments
 (0)