Skip to content

Commit fe42930

Browse files
gregmagolankara
authored andcommitted
test: use puppeteer in aio build instead to remove CI_CHROMEDRIVER_VERSION_ARG (#35049)
PR Close #35049
1 parent c99165f commit fe42930

File tree

7 files changed

+107
-37
lines changed

7 files changed

+107
-37
lines changed

.circleci/config.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,7 @@ commands:
121121
at: *workspace_location
122122

123123
# Install shared libs used by Chrome that is either provisioned by
124-
# rules_webtesting or by puppeteer. These are now needed in all containers
125-
# as the webdriver-manager update script which is run in the root postinstall
126-
# now starts puppeteer's Chrome in headless to check its version so the correct
127-
# chromedriver is downloaded. See `/scripts/webdriver-manager-update.js`.
124+
# rules_webtesting or by puppeteer.
128125
install_chrome_libs:
129126
description: Install shared Chrome libs
130127
steps:
@@ -368,11 +365,11 @@ jobs:
368365
no_output_timeout: 20m
369366

370367
test_aio:
371-
# Needed because the AIO tests and the PWA score test depend on Chrome being available.
372-
executor: browsers-executor
368+
executor: default-executor
373369
steps:
374370
- custom_attach_workspace
375371
- init_environment
372+
- install_chrome_libs
376373
# Compile dependencies to ivy
377374
# Running `ngcc` here (instead of implicitly via `ng build`) allows us to take advantage of
378375
# the parallel, async mode speed-up (~20-25s on CI).
@@ -395,11 +392,11 @@ jobs:
395392
- run: yarn --cwd aio redirects-test
396393

397394
deploy_aio:
398-
# Needed because before deploying the deploy-production script runs the PWA score tests.
399-
executor: browsers-executor
395+
executor: default-executor
400396
steps:
401397
- custom_attach_workspace
402398
- init_environment
399+
- install_chrome_libs
403400
# Deploy angular.io to production (if necessary)
404401
- run: setPublicVar_CI_STABLE_BRANCH
405402
- run: yarn --cwd aio deploy-production
@@ -409,11 +406,11 @@ jobs:
409406
viewengine:
410407
type: boolean
411408
default: false
412-
# Needed because the AIO tests and the PWA score test depend on Chrome being available.
413-
executor: browsers-executor
409+
executor: default-executor
414410
steps:
415411
- custom_attach_workspace
416412
- init_environment
413+
- install_chrome_libs
417414
# Build aio (with local Angular packages)
418415
- run: yarn --cwd aio build-local<<# parameters.viewengine >>-with-viewengine<</ parameters.viewengine >>-ci
419416
# Run unit tests
@@ -484,11 +481,11 @@ jobs:
484481

485482
# This job should only be run on PR builds, where `CI_PULL_REQUEST` is not `false`.
486483
test_aio_preview:
487-
# Needed because the test-preview script runs e2e tests and the PWA score test with Chrome.
488-
executor: browsers-executor
484+
executor: default-executor
489485
steps:
490486
- custom_attach_workspace
491487
- init_environment
488+
- install_chrome_libs
492489
- run: yarn --cwd aio install --frozen-lockfile --non-interactive
493490
- run:
494491
name: Wait for preview and run tests
@@ -551,7 +548,8 @@ jobs:
551548
# See comments inside the integration/run_tests.sh script.
552549
integration_test:
553550
executor:
554-
# Needed because the integration tests expect Chrome to be installed (e.g cli-hello-world)
551+
# Needed because the integration/bazel-schematics test expects Chrome to be installed
552+
# TODO(gregmagolan): remove the dependency on local chrome from that test
555553
name: browsers-executor
556554
# Note: we run Bazel in one of the integration tests, and it can consume >2G
557555
# of memory. Together with the system under test, this can exhaust the RAM
@@ -561,7 +559,6 @@ jobs:
561559
steps:
562560
- custom_attach_workspace
563561
- init_environment
564-
- install_chrome_libs
565562
# Runs the integration tests in parallel across multiple CircleCI container instances. The
566563
# amount of container nodes for this job is controlled by the "parallelism" option.
567564
- run: ./integration/run_tests.sh ${CIRCLE_NODE_INDEX} ${CIRCLE_NODE_TOTAL}
@@ -652,12 +649,11 @@ jobs:
652649
webhook_url_env_var: SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
653650

654651
aio_monitoring_next:
655-
# This job needs Chrome to be globally installed because the tests run with Protractor
656-
# which does not load the browser through the Bazel webtesting rules.
657-
executor: browsers-executor
652+
executor: default-executor
658653
steps:
659654
- custom_attach_workspace
660655
- init_environment
656+
- install_chrome_libs
661657
- run:
662658
name: Run tests against https://next.angular.io/
663659
command: ./aio/scripts/test-production.sh https://next.angular.io/ $CI_AIO_MIN_PWA_SCORE

aio/karma.conf.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Karma configuration file, see link for more information
22
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
process.env.CHROME_BIN = require('puppeteer').executablePath();
34

45
module.exports = function (config) {
56
config.set({
@@ -30,7 +31,14 @@ module.exports = function (config) {
3031
colors: true,
3132
logLevel: config.LOG_INFO,
3233
autoWatch: true,
33-
browsers: ['Chrome'],
34+
customLaunchers: {
35+
ChromeHeadlessNoSandbox: {
36+
base: 'ChromeHeadless',
37+
// See /integration/README.md#browser-tests for more info on these args
38+
flags: ['--no-sandbox', '--headless', '--disable-gpu', '--disable-dev-shm-usage', '--hide-scrollbars', '--mute-audio']
39+
}
40+
},
41+
browsers: [process.env['CI'] ? 'ChromeHeadlessNoSandbox' : 'Chrome'],
3442
browserNoActivityTimeout: 60000,
3543
singleRun: false,
3644
restartOnFileChange: true,

aio/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"generate-stackblitz": "node ./tools/stackblitz-builder/generateStackblitz",
7373
"generate-zips": "node ./tools/example-zipper/generateZips",
7474
"build-404-page": "node scripts/build-404-page",
75-
"update-webdriver": "webdriver-manager update --standalone false --gecko false $CI_CHROMEDRIVER_VERSION_ARG",
75+
"update-webdriver": "node ../scripts/webdriver-manager-update.js",
7676
"~~audit-web-app": "node scripts/audit-web-app",
7777
"~~check-env": "node scripts/check-environment",
7878
"~~clean-generated": "node --eval \"require('shelljs').rm('-rf', 'src/generated')\"",
@@ -118,7 +118,6 @@
118118
"archiver": "^1.3.0",
119119
"canonical-path": "1.0.0",
120120
"chalk": "^2.1.0",
121-
"chrome-launcher": "^0.10.7",
122121
"cjson": "^0.5.0",
123122
"codelyzer": "^5.1.2",
124123
"cross-spawn": "^5.1.0",
@@ -155,6 +154,7 @@
155154
"lunr": "^2.1.0",
156155
"npm-run-all": "^4.1.5",
157156
"protractor": "^5.4.2",
157+
"puppeteer": "2.1.1",
158158
"rehype": "^6.0.0",
159159
"rehype-slug": "^2.0.0",
160160
"remark": "^9.0.0",

aio/scripts/audit-web-app.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@
2727
*/
2828

2929
// Imports
30-
const chromeLauncher = require('chrome-launcher');
30+
const puppeteer = require('puppeteer');
3131
const lighthouse = require('lighthouse');
3232
const printer = require('lighthouse/lighthouse-cli/printer');
3333
const logger = require('lighthouse-logger');
3434

3535
// Constants
3636
const AUDIT_CATEGORIES = ['accessibility', 'best-practices', 'performance', 'pwa', 'seo'];
37-
const CHROME_LAUNCH_OPTS = {chromeFlags: ['--headless']};
3837
const LIGHTHOUSE_FLAGS = {logLevel: process.env.CI ? 'error' : 'info'}; // Be less verbose on CI.
3938
const SKIPPED_HTTPS_AUDITS = ['redirects-http', 'uses-http2'];
4039
const VIEWER_URL = 'https://googlechrome.github.io/lighthouse/viewer';
@@ -84,13 +83,15 @@ function formatScore(score) {
8483
}
8584

8685
async function launchChromeAndRunLighthouse(url, flags, config) {
87-
const chrome = await chromeLauncher.launch(CHROME_LAUNCH_OPTS);
88-
flags.port = chrome.port;
86+
const browser = await puppeteer.launch({
87+
headless: true,
88+
args: ['--remote-debugging-port=9222']});
89+
flags.port = browser.port;
8990

9091
try {
9192
return await lighthouse(url, flags, config);
9293
} finally {
93-
await chrome.kill();
94+
await browser.close();
9495
}
9596
}
9697

aio/tests/deployment/e2e/protractor.conf.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ exports.config = {
1414
suite: 'full',
1515
capabilities: {
1616
browserName: 'chrome',
17+
chromeOptions: process.env['CI'] ? {
18+
binary: require('puppeteer').executablePath(),
19+
// See /integration/README.md#browser-tests for more info on these args
20+
args: ['--no-sandbox', '--headless', '--disable-gpu', '--disable-dev-shm-usage', '--hide-scrollbars', '--mute-audio']
21+
} : {},
1722
},
1823
directConnect: true,
1924
framework: 'jasmine',

aio/tests/e2e/protractor.conf.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ exports.config = {
1414
],
1515
capabilities: {
1616
browserName: 'chrome',
17+
chromeOptions: process.env['CI'] ? {
18+
binary: require('puppeteer').executablePath(),
19+
// See /integration/README.md#browser-tests for more info on these args
20+
args: ['--no-sandbox', '--headless', '--disable-gpu', '--disable-dev-shm-usage', '--hide-scrollbars', '--mute-audio']
21+
} : {},
1722
},
1823
directConnect: true,
1924
baseUrl: 'http://localhost:4200/',

aio/yarn.lock

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,11 @@
12301230
resolved "https://registry.yarnpkg.com/@types/lunr/-/lunr-2.3.2.tgz#d4a51703315ed0e53c43257216f1014ce6491562"
12311231
integrity sha512-zcUZYquYDUEegRRPQtkZ068U9CoIjW6pJMYCVDRK25r76FEWvMm1oHqZQUfQh4ayIZ42lipXOpXEiAtGXc1XUg==
12321232

1233+
"@types/mime-types@^2.1.0":
1234+
version "2.1.0"
1235+
resolved "https://registry.yarnpkg.com/@types/mime-types/-/mime-types-2.1.0.tgz#9ca52cda363f699c69466c2a6ccdaad913ea7a73"
1236+
integrity sha1-nKUs2jY/aZxpRmwqbM2q2RPqenM=
1237+
12331238
"@types/minimatch@*":
12341239
version "3.0.3"
12351240
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
@@ -3280,20 +3285,20 @@ concat-map@0.0.1:
32803285
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
32813286
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
32823287

3283-
concat-stream@^1.4.7, concat-stream@^1.5.2:
3284-
version "1.6.0"
3285-
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7"
3288+
concat-stream@1.6.2, concat-stream@^1.5.0:
3289+
version "1.6.2"
3290+
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34"
3291+
integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==
32863292
dependencies:
3293+
buffer-from "^1.0.0"
32873294
inherits "^2.0.3"
32883295
readable-stream "^2.2.2"
32893296
typedarray "^0.0.6"
32903297

3291-
concat-stream@^1.5.0:
3292-
version "1.6.2"
3293-
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34"
3294-
integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==
3298+
concat-stream@^1.4.7, concat-stream@^1.5.2:
3299+
version "1.6.0"
3300+
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7"
32953301
dependencies:
3296-
buffer-from "^1.0.0"
32973302
inherits "^2.0.3"
32983303
readable-stream "^2.2.2"
32993304
typedarray "^0.0.6"
@@ -4960,6 +4965,16 @@ extglob@^2.0.4:
49604965
snapdragon "^0.8.1"
49614966
to-regex "^3.0.1"
49624967

4968+
extract-zip@^1.6.6:
4969+
version "1.6.7"
4970+
resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9"
4971+
integrity sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=
4972+
dependencies:
4973+
concat-stream "1.6.2"
4974+
debug "2.6.9"
4975+
mkdirp "0.5.1"
4976+
yauzl "2.4.1"
4977+
49634978
extsprintf@1.3.0:
49644979
version "1.3.0"
49654980
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05"
@@ -5025,6 +5040,13 @@ faye-websocket@~0.11.1:
50255040
dependencies:
50265041
websocket-driver ">=0.5.1"
50275042

5043+
fd-slicer@~1.0.1:
5044+
version "1.0.1"
5045+
resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65"
5046+
integrity sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=
5047+
dependencies:
5048+
pend "~1.2.0"
5049+
50285050
figgy-pudding@^3.4.1, figgy-pudding@^3.5.1:
50295051
version "3.5.1"
50305052
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.1.tgz#862470112901c727a0e495a80744bd5baa1d6790"
@@ -8311,7 +8333,7 @@ mime-db@1.43.0:
83118333
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.38.0.tgz#1a2aab16da9eb167b49c6e4df2d9c68d63d8e2ad"
83128334
integrity sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==
83138335

8314-
mime-types@^2.1.12, mime-types@^2.1.16, mime-types@~2.1.17, mime-types@~2.1.18, mime-types@~2.1.19:
8336+
mime-types@^2.1.12, mime-types@^2.1.16, mime-types@^2.1.25, mime-types@~2.1.17, mime-types@~2.1.18, mime-types@~2.1.19:
83158337
version "2.1.26"
83168338
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.26.tgz#9c921fc09b7e149a65dfdc0da4d20997200b0a06"
83178339
integrity sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==
@@ -8335,7 +8357,7 @@ mime@1.6.0, mime@^1.4.1:
83358357
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
83368358
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==
83378359

8338-
mime@^2.2.0, mime@^2.3.1, mime@^2.4.4:
8360+
mime@^2.0.3, mime@^2.2.0, mime@^2.3.1, mime@^2.4.4:
83398361
version "2.4.4"
83408362
resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.4.tgz#bd7b91135fc6b01cde3e9bae33d659b63d8857e5"
83418363
integrity sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==
@@ -9535,6 +9557,11 @@ pbkdf2@^3.0.3:
95359557
safe-buffer "^5.0.1"
95369558
sha.js "^2.4.8"
95379559

9560+
pend@~1.2.0:
9561+
version "1.2.0"
9562+
resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50"
9563+
integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA=
9564+
95389565
performance-now@^2.1.0:
95399566
version "2.1.0"
95409567
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
@@ -10002,7 +10029,7 @@ progress@^1.1.8:
1000210029
version "1.1.8"
1000310030
resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be"
1000410031

10005-
progress@^2.0.3:
10032+
progress@^2.0.1, progress@^2.0.3:
1000610033
version "2.0.3"
1000710034
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
1000810035
integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==
@@ -10095,6 +10122,11 @@ proxy-addr@~2.0.5:
1009510122
forwarded "~0.1.2"
1009610123
ipaddr.js "1.9.0"
1009710124

10125+
proxy-from-env@^1.0.0:
10126+
version "1.0.0"
10127+
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee"
10128+
integrity sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=
10129+
1009810130
prr@~1.0.1:
1009910131
version "1.0.1"
1010010132
resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476"
@@ -10161,6 +10193,22 @@ punycode@^2.1.0:
1016110193
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
1016210194
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
1016310195

10196+
puppeteer@2.1.1:
10197+
version "2.1.1"
10198+
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-2.1.1.tgz#ccde47c2a688f131883b50f2d697bd25189da27e"
10199+
integrity sha512-LWzaDVQkk1EPiuYeTOj+CZRIjda4k2s5w4MK4xoH2+kgWV/SDlkYHmxatDdtYrciHUKSXTsGgPgPP8ILVdBsxg==
10200+
dependencies:
10201+
"@types/mime-types" "^2.1.0"
10202+
debug "^4.1.0"
10203+
extract-zip "^1.6.6"
10204+
https-proxy-agent "^4.0.0"
10205+
mime "^2.0.3"
10206+
mime-types "^2.1.25"
10207+
progress "^2.0.1"
10208+
proxy-from-env "^1.0.0"
10209+
rimraf "^2.6.1"
10210+
ws "^6.1.0"
10211+
1016410212
q@1.4.1:
1016510213
version "1.4.1"
1016610214
resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e"
@@ -13526,7 +13574,7 @@ ws@^1.0.1:
1352613574
options ">=0.0.5"
1352713575
ultron "1.0.x"
1352813576

13529-
ws@^6.2.1:
13577+
ws@^6.1.0, ws@^6.2.1:
1353013578
version "6.2.1"
1353113579
resolved "https://registry.yarnpkg.com/ws/-/ws-6.2.1.tgz#442fdf0a47ed64f59b6a5d8ff130f4748ed524fb"
1353213580
integrity sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==
@@ -13742,6 +13790,13 @@ yargs@^7.0.2:
1374213790
y18n "^3.2.1"
1374313791
yargs-parser "^5.0.0"
1374413792

13793+
yauzl@2.4.1:
13794+
version "2.4.1"
13795+
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005"
13796+
integrity sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=
13797+
dependencies:
13798+
fd-slicer "~1.0.1"
13799+
1374513800
yeast@0.1.2:
1374613801
version "0.1.2"
1374713802
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"

0 commit comments

Comments
 (0)