ci: add circleci windows preview

This commit is contained in:
Filipe Silva 2019-06-06 11:05:44 +01:00 committed by Alex Eagle
parent a208cf4b31
commit 97970026f1
7 changed files with 94 additions and 8 deletions

View File

@ -23,6 +23,12 @@ anchor_1: &defaults
working_directory: ~/ng working_directory: ~/ng
docker: docker:
- image: *default_docker_image - image: *default_docker_image
anchor_1_win: &defaults_win
working_directory: ~/ng
resource_class: windows.medium
shell: powershell.exe -ExecutionPolicy Bypass
machine:
image: windows-server-2019
# After checkout, rebase on top of target branch. # After checkout, rebase on top of target branch.
anchor_2: &post_checkout anchor_2: &post_checkout
@ -38,6 +44,14 @@ anchor_2: &post_checkout
else else
echo "This build is not over a PR, nothing to do." echo "This build is not over a PR, nothing to do."
fi fi
anchor_2_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 }
anchor_3: &restore_cache anchor_3: &restore_cache
restore_cache: restore_cache:
keys: keys:
@ -46,9 +60,15 @@ anchor_3: &restore_cache
- angular_devkit-0.7.0- - angular_devkit-0.7.0-
anchor_4: &attach_options anchor_4: &attach_options
at: . at: .
anchor_5: &env_win
run:
# Need to install node and yarn before, as the base windows image doesn't have anything.
# TODO: remove when CircleCI provides preconfigured node images/VMs.
name: Setup windows node environment
command: ./.circleci/windows-env.ps1
# Job definitions # Job definitions
version: 2 version: 2.1
jobs: jobs:
install: install:
<<: *defaults <<: *defaults
@ -202,6 +222,45 @@ jobs:
command: | command: |
npm run admin -- publish --verbose npm run admin -- publish --verbose
# Windows jobs
# CircleCI support for Windows jobs is still in preview.
# Docs: https://github.com/CircleCI-Public/windows-preview-docs
test-win:
<<: *defaults_win
# Skipping cache and workspace for now because it takes 10x longer than on linux.
# TODO: when/if CircleCI makes them faster, use cache and workspaces fully.
# Notes:
# - windows needs its own cache key because binaries in node_modules are different.
# - windows might need its own workspace for the same reason.
# - get cache dir on windows via `yarn cache dir` (was `C:\Users\circleci\AppData\Local\Yarn\Cache\v4` last time)
steps:
- checkout
- *env_win
- *post_checkout_win
- run: node --version
- run: yarn --version
- run: yarn install --frozen-lockfile
# Build and test should be on their own jobs, but restoring workspaces is too slow
# so we do it here.
- run: npm run admin -- build
- run: npm run test -- --full
# Run partial e2e suite on PRs only. Master will run the full e2e suite with sharding.
- run: if (Test-Path env:CIRCLE_PR_NUMBER) { node tests\legacy-cli\run_e2e.js "--glob=tests/{basic,ivy}/**" }
e2e-cli-win:
<<: *defaults_win
parallelism: 4
steps:
- checkout
- *env_win
# TODO: remove commands other than the e2e runner when workspaces on windows are well supported.
- *post_checkout_win
- run: node --version
- run: yarn --version
- run: yarn install --frozen-lockfile
- run: npm run admin -- build
- run: node tests\legacy-cli\run_e2e.js --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX
workflows: workflows:
version: 2 version: 2
default_workflow: default_workflow:
@ -237,7 +296,7 @@ workflows:
- build - build
- e2e-cli-ivy: - e2e-cli-ivy:
requires: requires:
- build - build
- snapshot_publish_docs: - snapshot_publish_docs:
requires: requires:
- install - install
@ -248,6 +307,16 @@ workflows:
- e2e-cli-ng-snapshots: - e2e-cli-ng-snapshots:
requires: requires:
- build - build
- test-win:
requires:
- test
- e2e-cli-win:
requires:
- e2e-cli
filters:
branches:
ignore:
- /pull\/.*/
- snapshot_publish: - snapshot_publish:
requires: requires:
- test - test

View File

@ -0,0 +1,9 @@
# Install nodejs and yarn via Chocolatey.
choco install nodejs --version 12.1.0 --no-progress
choco install yarn --version 1.16.0 --no-progress
# 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, and yarn. Use single quotes to prevent interpolation.
Add-Content $profile '$Env:path += ";C:\Program Files\nodejs\;C:\Users\circleci\AppData\Roaming\npm\;C:\Program Files (x86)\Yarn\bin\;"'

View File

@ -87,12 +87,12 @@ const oldRequireTs = require.extensions['.ts'];
require.extensions['.ts'] = function (m, filename) { require.extensions['.ts'] = function (m, filename) {
// If we're in node module, either call the old hook or simply compile the // If we're in node module, either call the old hook or simply compile the
// file without transpilation. We do not touch node_modules/**. // file without transpilation. We do not touch node_modules/**.
// We do touch `Angular DevK` files anywhere though. // To account for Yarn workspaces symlinks, we much check the real path.
if (!filename.match(/@angular\/cli\b/) && filename.match(/node_modules/)) { if (fs.realpathSync(filename).match(/node_modules/)) {
if (oldRequireTs) { if (oldRequireTs) {
return oldRequireTs(m, filename); return oldRequireTs(m, filename);
} }
return m._compile(fs.readFileSync(filename), filename); return m._compile(fs.readFileSync(filename).toString(), filename);
} }
debugBuildTs(filename); debugBuildTs(filename);

View File

@ -43,7 +43,7 @@
"url": "https://github.com/angular/angular-cli.git" "url": "https://github.com/angular/angular-cli.git"
}, },
"engines": { "engines": {
"node": ">=10.9.0 <11.0.0", "node": ">=10.9.0 <13.0.0",
"yarn": ">=1.9.0 <2.0.0" "yarn": ">=1.9.0 <2.0.0"
}, },
"author": "Angular Authors", "author": "Angular Authors",

View File

@ -164,7 +164,7 @@ describe('Universal Schematic', () => {
const filePath = '/projects/bar/src/main.ts'; const filePath = '/projects/bar/src/main.ts';
const contents = tree.readContent(filePath); const contents = tree.readContent(filePath);
expect(contents) expect(contents)
.toMatch(/document.addEventListener\('DOMContentLoaded', \(\) => {[\w\W]+;[\r\n]}\);/); .toMatch(/document.addEventListener\('DOMContentLoaded', \(\) => {/);
}); });
it('should wrap the bootstrap declaration in a DOMContentLoaded event handler', async () => { it('should wrap the bootstrap declaration in a DOMContentLoaded event handler', async () => {

View File

@ -1,7 +1,7 @@
import {join} from 'path'; import {join} from 'path';
import {ng} from '../../../utils/process'; import {ng} from '../../../utils/process';
import {expectFileToMatch} from '../../../utils/fs'; import {expectFileToMatch} from '../../../utils/fs';
import { updateJsonFile } from '../../../utils/project'; import { updateJsonFile, useCIChrome, useCIDefaults } from '../../../utils/project';
export default function() { export default function() {
@ -17,6 +17,8 @@ export default function() {
.then(() => expectFileToMatch(join(directiveDir, 'test2-directive.directive.ts'), .then(() => expectFileToMatch(join(directiveDir, 'test2-directive.directive.ts'),
/selector: '\[preW/)) /selector: '\[preW/))
.then(() => ng('generate', 'application', 'app-two', '--skip-install')) .then(() => ng('generate', 'application', 'app-two', '--skip-install'))
.then(() => useCIDefaults('app-two'))
.then(() => useCIChrome('./projects/app-two'))
.then(() => updateJsonFile('angular.json', configJson => { .then(() => updateJsonFile('angular.json', configJson => {
configJson.projects['test-project'].schematics = { configJson.projects['test-project'].schematics = {
'@schematics/angular:directive': { prefix: 'preP' } '@schematics/angular:directive': { prefix: 'preP' }

View File

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