Skip to content

Commit 5a84729

Browse files
filipesilvaKeen Yee Liau
authored and
Keen Yee Liau
committed
ci: use puppeteer
1 parent 3a70eb7 commit 5a84729

File tree

15 files changed

+132
-53
lines changed

15 files changed

+132
-53
lines changed

.appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ install:
1111
- ps: Install-Product node $env:nodejs_version
1212
# --network-timeout is a workaround for https://github.com/yarnpkg/yarn/issues/6221
1313
- yarn --frozen-lockfile --network-timeout=500000
14-
- yarn webdriver-update-appveyor
14+
- yarn webdriver-update
1515

1616
test_script:
1717
- node --version

.buildkite/pipeline.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ steps:
1111
# Actual CI commands
1212
# --network-timeout is a workaround for https://github.com/yarnpkg/yarn/issues/6221
1313
- yarn install --frozen-lockfile --non-interactive --network-timeout 500000
14-
- yarn webdriver-update-appveyor
14+
- yarn webdriver-update
1515
- node --version
1616
- yarn --version
1717
- yarn test

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
parallelism: 4
7575
steps:
7676
- attach_workspace: *attach_options
77-
- run: npm run webdriver-update-circleci
77+
- run: npm run webdriver-update
7878
- run: npm run test-large -- --full --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX}
7979

8080
e2e-cli:

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM node:10.12
2+
ENTRYPOINT [ "sh" ]

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
"validate-commits": "./bin/devkit-admin validate-commits",
3636
"prepush": "node ./bin/devkit-admin hooks/pre-push",
3737
"preinstall": "node ./tools/yarn/check-yarn.js",
38-
"webdriver-update-appveyor": "webdriver-manager update --standalone false --gecko false --versions.chrome 2.37",
39-
"webdriver-update-circleci": "webdriver-manager update --standalone false --gecko false --versions.chrome $CHROMEDRIVER_VERSION_ARG "
38+
"webdriver-update": "webdriver-manager update --standalone false --gecko false --versions.chrome 2.45"
4039
},
4140
"repository": {
4241
"type": "git",
@@ -66,6 +65,7 @@
6665
"dependencies": {
6766
"glob": "^7.0.3",
6867
"node-fetch": "^2.2.0",
68+
"puppeteer": "1.11.0",
6969
"quicktype-core": "^6.0.15",
7070
"temp": "^0.9.0",
7171
"tslint": "^5.11.0",

packages/angular_devkit/core/src/json/schema/registry_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { addUndefinedDefaults } from './transforms';
1414

1515
describe('CoreSchemaRegistry', () => {
1616
it('works asynchronously', done => {
17-
if (process.env.BUILDKITE === 'true') {
17+
if (process.platform.startsWith('win')) {
1818
// This test consistently fails on Windows BuildKite, but doesn't fail on local Windows
1919
// or in Appveyor. Many tests test the async behaviour of the registry, but this is the only
2020
// one that also fetches an async ref. Perhaps that is why.

tests/angular_devkit/build_angular/hello-world-app/angular.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"polyfills": "src/polyfills.ts",
9898
"tsConfig": "src/tsconfig.spec.json",
9999
"karmaConfig": "karma.conf.js",
100-
"browsers": "ChromeHeadless",
100+
"browsers": "ChromeHeadlessCI",
101101
"progress": false,
102102
"watch": false,
103103
"styles": [

tests/angular_devkit/build_angular/hello-world-app/karma.conf.js

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ module.exports = function (config) {
3535
logLevel: config.LOG_INFO,
3636
autoWatch: true,
3737
browsers: ['Chrome'],
38+
customLaunchers: {
39+
ChromeHeadlessCI: {
40+
base: 'ChromeHeadless',
41+
flags: ['--disable-gpu']
42+
}
43+
},
3844
singleRun: false
3945
});
4046
};

tests/angular_devkit/build_angular/hello-world-app/protractor.conf.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ exports.config = {
1919
capabilities: {
2020
'browserName': 'chrome',
2121
chromeOptions: {
22-
args: ["--headless", "--disable-gpu", "--window-size=800,600"]
22+
args: ['--headless', '--disable-gpu', '--window-size=800,600'],
23+
binary: require('puppeteer').executablePath()
2324
}
2425
},
2526
directConnect: true,

tests/angular_devkit/build_ng_packagr/ng-packaged/angular.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"main": "projects/lib/src/test.ts",
2020
"tsConfig": "projects/lib/tsconfig.spec.json",
2121
"karmaConfig": "projects/lib/karma.conf.js",
22-
"browsers": "ChromeHeadless",
22+
"browsers": "ChromeHeadlessCI",
2323
"progress": false,
2424
"watch": false
2525
}

tests/angular_devkit/build_ng_packagr/ng-packaged/projects/lib/karma.conf.js

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ module.exports = function (config) {
3333
logLevel: config.LOG_INFO,
3434
autoWatch: true,
3535
browsers: ['Chrome'],
36+
customLaunchers: {
37+
ChromeHeadlessCI: {
38+
base: 'ChromeHeadless',
39+
flags: ['--disable-gpu']
40+
}
41+
},
3642
singleRun: false
3743
});
3844
};

tests/legacy-cli/e2e/tests/generate/application/application-basic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export default function() {
88
.then(() => expectFileToMatch('angular.json', /\"app2\":/))
99
.then(() => useCIChrome('projects/app2'))
1010
.then(() => useCIChrome('projects/app2-e2e'))
11-
.then(() => ng('test', 'app2', '--watch=false'));
11+
.then(() => ng('test', 'app2', '--watch=false', '--browsers=ChromeHeadlessCI'));
1212
}

tests/legacy-cli/e2e/tests/generate/library/library-basic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ export default function () {
77
.then(() => expectFileToMatch('angular.json', /\"my-lib\":/))
88
.then(() => useCIChrome('projects/my-lib'))
99
.then(() => ng('build', 'my-lib'))
10-
.then(() => ng('test', 'my-lib', '--watch=false'));
10+
.then(() => ng('test', 'my-lib', '--watch=false', '--browsers=ChromeHeadlessCI'));
1111
}

tests/legacy-cli/e2e/utils/project.ts

+44-40
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { readFile, writeFile, replaceInFile } from './fs';
1+
import * as fs from 'fs-extra';
2+
import { readFile, writeFile, replaceInFile, prependToFile } from './fs';
23
import { execAndWaitForOutputToMatch, npm, silentNpm, ng } from './process';
34
import { getGlobalVariable } from './env';
45

@@ -186,58 +187,61 @@ export function useCIDefaults(projectName = 'test-project') {
186187
const appTargets = project.targets || project.architect;
187188
appTargets.build.options.progress = false;
188189
appTargets.test.options.progress = false;
190+
// Use the CI chrome setup in karma.
191+
appTargets.test.options.browsers = 'ChromeHeadlessCI';
189192
// Disable auto-updating webdriver in e2e.
190193
const e2eProject = workspaceJson.projects[projectName + '-e2e'];
191194
const e2eTargets = e2eProject.targets || e2eProject.architect;
192195
e2eTargets.e2e.options.webdriverUpdate = false;
193196
})
194197
.then(() => updateJsonFile('package.json', json => {
195-
// We want to always use the same version of webdriver but can only do so on CircleCI.
196-
// Appveyor and Travis will use latest Chrome stable.
197-
// CircleCI (via ngcontainer:0.1.1) uses Chrome 63.0.3239.84.
198-
// Appveyor (via chocolatey) cannot use older versions of Chrome at all:
199-
// https://github.com/chocolatey/chocolatey-coreteampackages/tree/master/automatic/googlechrome
200-
// webdriver 2.33 matches Chrome 63.0.3239.84.
201-
// webdriver 2.37 matches Chrome 65.0.3325.18100 (latest stable).
202-
// The webdriver versions for latest stable will need to be manually updated.
203-
const webdriverVersion = process.env['CIRCLECI'] ? '2.33' : '2.37';
204-
const driverOption = process.env['CHROMEDRIVER_VERSION_ARG']
205-
|| `--versions.chrome ${webdriverVersion}`;
198+
// Use matching versions of Chrome and Webdriver.
206199
json['scripts']['webdriver-update'] = 'webdriver-manager update' +
207-
` --standalone false --gecko false ${driverOption}`;
200+
` --standalone false --gecko false --versions.chrome 2.45`; // Supports Chrome v70-72
201+
208202
}))
209203
.then(() => npm('run', 'webdriver-update'));
210204
}
211205

212206
export function useCIChrome(projectDir: string) {
213-
// There's a race condition happening in Chrome. Enabling logging in chrome used by
214-
// protractor actually fixes it. Logging is piped to a file so it doesn't affect our setup.
215-
// --no-sandbox is needed for Circle CI.
216-
// Travis can use headless chrome, but not appveyor.
207+
const protractorConf = `${projectDir}/protractor.conf.js`;
208+
const karmaConf = `${projectDir}/karma.conf.js`;
209+
217210
return Promise.resolve()
218-
.then(() => replaceInFile(`${projectDir}/protractor.conf.js`,
219-
`'browserName': 'chrome'`,
220-
`'browserName': 'chrome',
221-
chromeOptions: {
222-
args: [
223-
"--enable-logging",
224-
// "--no-sandbox",
225-
// "--headless"
226-
]
227-
}
228-
`))
229-
// Not a problem if the file can't be found.
230-
// .catch(() => null)
231-
// .then(() => replaceInFile(`${projectDir}/karma.conf.js`, `browsers: ['Chrome'],`,
232-
// `browsers: ['ChromeCI'],
233-
// customLaunchers: {
234-
// ChromeCI: {
235-
// base: 'ChromeHeadless',
236-
// flags: ['--no-sandbox']
237-
// }
238-
// },
239-
// `))
240-
.catch(() => null);
211+
.then(() => updateJsonFile('package.json', json => {
212+
// Use matching versions of Chrome and Webdriver.
213+
json['devDependencies']['puppeteer'] = '1.11.0'; // Chromium 72.0.3618.0 (r609904)
214+
json['devDependencies']['karma-chrome-launcher'] = '~2.2.0'; // Minimum for ChromeHeadless.
215+
}))
216+
// Use Pupeteer in protractor if a config is found on the project.
217+
.then(() => {
218+
if (fs.existsSync(protractorConf)) {
219+
return replaceInFile(protractorConf,
220+
`'browserName': 'chrome'`,
221+
`'browserName': 'chrome',
222+
chromeOptions: {
223+
args: ['--headless'],
224+
binary: require('puppeteer').executablePath()
225+
}
226+
`);
227+
}
228+
})
229+
// Use Pupeteer in karma if a config is found on the project.
230+
.then(() => {
231+
if (fs.existsSync(karmaConf)) {
232+
return prependToFile(karmaConf,
233+
`process.env.CHROME_BIN = require('puppeteer').executablePath();`)
234+
.then(() => replaceInFile(karmaConf,
235+
`browsers: ['Chrome']`,
236+
`browsers: ['Chrome'],
237+
customLaunchers: {
238+
ChromeHeadlessCI: {
239+
base: 'ChromeHeadless',
240+
}
241+
}
242+
`));
243+
}
244+
});
241245
}
242246

243247
// Convert a Angular 5 project to Angular 2.

yarn.lock

+62-2
Original file line numberDiff line numberDiff line change
@@ -2293,7 +2293,7 @@ [email protected]:
22932293
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
22942294
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
22952295

2296-
concat-stream@^1.5.0, concat-stream@^1.5.2, concat-stream@~1.6.0:
2296+
concat-stream@1.6.2, concat-stream@^1.5.0, concat-stream@^1.5.2, concat-stream@~1.6.0:
22972297
version "1.6.2"
22982298
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34"
22992299
integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==
@@ -3610,6 +3610,16 @@ extglob@^2.0.4:
36103610
snapdragon "^0.8.1"
36113611
to-regex "^3.0.1"
36123612

3613+
extract-zip@^1.6.6:
3614+
version "1.6.7"
3615+
resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9"
3616+
integrity sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=
3617+
dependencies:
3618+
concat-stream "1.6.2"
3619+
debug "2.6.9"
3620+
mkdirp "0.5.1"
3621+
yauzl "2.4.1"
3622+
36133623
36143624
version "1.3.0"
36153625
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05"
@@ -3674,6 +3684,13 @@ faye-websocket@~0.11.1:
36743684
dependencies:
36753685
websocket-driver ">=0.5.1"
36763686

3687+
fd-slicer@~1.0.1:
3688+
version "1.0.1"
3689+
resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65"
3690+
integrity sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=
3691+
dependencies:
3692+
pend "~1.2.0"
3693+
36773694
fecha@^2.3.3:
36783695
version "2.3.3"
36793696
resolved "https://registry.yarnpkg.com/fecha/-/fecha-2.3.3.tgz#948e74157df1a32fd1b12c3a3c3cdcb6ec9d96cd"
@@ -6328,6 +6345,11 @@ mime@^1.3.4, mime@^1.4.1:
63286345
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
63296346
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==
63306347

6348+
mime@^2.0.3:
6349+
version "2.4.0"
6350+
resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.0.tgz#e051fd881358585f3279df333fe694da0bcffdd6"
6351+
integrity sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==
6352+
63316353
mime@^2.3.1:
63326354
version "2.3.1"
63336355
resolved "https://registry.yarnpkg.com/mime/-/mime-2.3.1.tgz#b1621c54d63b97c47d3cfe7f7215f7d64517c369"
@@ -6470,7 +6492,7 @@ mixin-object@^2.0.1:
64706492
for-in "^0.1.3"
64716493
is-extendable "^0.1.1"
64726494

6473-
[email protected], "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0:
6495+
[email protected].1, [email protected].x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0:
64746496
version "0.5.1"
64756497
resolved "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
64766498
integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=
@@ -7520,6 +7542,11 @@ pbkdf2@^3.0.3:
75207542
safe-buffer "^5.0.1"
75217543
sha.js "^2.4.8"
75227544

7545+
pend@~1.2.0:
7546+
version "1.2.0"
7547+
resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50"
7548+
integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA=
7549+
75237550
performance-now@^2.1.0:
75247551
version "2.1.0"
75257552
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
@@ -7703,6 +7730,11 @@ process@^0.11.10:
77037730
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
77047731
integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI=
77057732

7733+
progress@^2.0.1:
7734+
version "2.0.3"
7735+
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
7736+
integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==
7737+
77067738
promise-inflight@^1.0.1:
77077739
version "1.0.1"
77087740
resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
@@ -7870,6 +7902,20 @@ punycode@^2.1.0:
78707902
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
78717903
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
78727904

7905+
7906+
version "1.11.0"
7907+
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.11.0.tgz#63cdbe12b07275cd6e0b94bce41f3fcb20305770"
7908+
integrity sha512-iG4iMOHixc2EpzqRV+pv7o3GgmU2dNYEMkvKwSaQO/vMZURakwSOn/EYJ6OIRFYOque1qorzIBvrytPIQB3YzQ==
7909+
dependencies:
7910+
debug "^4.1.0"
7911+
extract-zip "^1.6.6"
7912+
https-proxy-agent "^2.2.1"
7913+
mime "^2.0.3"
7914+
progress "^2.0.1"
7915+
proxy-from-env "^1.0.0"
7916+
rimraf "^2.6.1"
7917+
ws "^6.1.0"
7918+
78737919
78747920
version "1.4.1"
78757921
resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e"
@@ -10641,6 +10687,13 @@ write-file-atomic@^2.0.0:
1064110687
imurmurhash "^0.1.4"
1064210688
signal-exit "^3.0.2"
1064310689

10690+
ws@^6.1.0:
10691+
version "6.1.2"
10692+
resolved "https://registry.yarnpkg.com/ws/-/ws-6.1.2.tgz#3cc7462e98792f0ac679424148903ded3b9c3ad8"
10693+
integrity sha512-rfUqzvz0WxmSXtJpPMX2EeASXabOrSMk1ruMOV3JBTBjo4ac2lDjGGsbQSyxj8Odhw5fBib8ZKEjDNvgouNKYw==
10694+
dependencies:
10695+
async-limiter "~1.0.0"
10696+
1064410697
ws@~3.3.1:
1064510698
version "3.3.3"
1064610699
resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2"
@@ -10810,6 +10863,13 @@ yargs@^7.0.0:
1081010863
y18n "^3.2.1"
1081110864
yargs-parser "^5.0.0"
1081210865

10866+
10867+
version "2.4.1"
10868+
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005"
10869+
integrity sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=
10870+
dependencies:
10871+
fd-slicer "~1.0.1"
10872+
1081310873
1081410874
version "0.1.2"
1081510875
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"

0 commit comments

Comments
 (0)