-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: organize per-browser dependencies #5787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,9 @@ jobs: | |
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 10 | ||
- uses: microsoft/playwright-github-action@v1 | ||
- run: npm ci | ||
- run: npm run build | ||
- run: node lib/cli/cli install-deps ${{ matrix.browser }} chromium | ||
- run: mkdir -p coredumps | ||
# Set core dump file name pattern | ||
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern' | ||
|
@@ -64,9 +64,9 @@ jobs: | |
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 10 | ||
- uses: microsoft/playwright-github-action@v1 | ||
- run: npm ci | ||
- run: npm run build | ||
- run: node lib/cli/cli install-deps ${{ matrix.browser }} chromium | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
- run: npx folio test/ --workers=1 --forbid-only --global-timeout=5400000 --retries=3 --reporter=dot,json --shard=${{ matrix.shard }}/2 | ||
env: | ||
BROWSER: ${{ matrix.browser }} | ||
|
@@ -94,9 +94,9 @@ jobs: | |
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 10 | ||
- uses: microsoft/playwright-github-action@v1 | ||
- run: npm ci | ||
- run: npm run build | ||
- run: node lib/cli/cli install-deps | ||
- run: npx folio test/ --workers=1 --forbid-only --global-timeout=5400000 --retries=3 --reporter=dot,json | ||
shell: bash | ||
env: | ||
|
@@ -125,9 +125,9 @@ jobs: | |
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node_version }} | ||
- uses: microsoft/playwright-github-action@v1 | ||
- run: npm ci | ||
- run: npm run build | ||
- run: node lib/cli/cli install-deps | ||
- run: bash packages/installation-tests/installation-tests.sh | ||
|
||
headful_linux: | ||
|
@@ -142,9 +142,9 @@ jobs: | |
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 10 | ||
- uses: microsoft/playwright-github-action@v1 | ||
- run: npm ci | ||
- run: npm run build | ||
- run: node lib/cli/cli install-deps ${{ matrix.browser }} chromium | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
- run: mkdir -p coredumps | ||
# Set core dump file name pattern | ||
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern' | ||
|
@@ -177,9 +177,9 @@ jobs: | |
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 10 | ||
- uses: microsoft/playwright-github-action@v1 | ||
- run: npm ci | ||
- run: npm run build | ||
- run: node lib/cli/cli install-deps chromium | ||
- run: mkdir -p coredumps | ||
# Set core dump file name pattern | ||
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern' | ||
|
@@ -211,9 +211,9 @@ jobs: | |
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 10 | ||
- uses: microsoft/playwright-github-action@v1 | ||
- run: npm ci | ||
- run: npm run build | ||
- run: node lib/cli/cli install-deps ${{ matrix.browser }} chromium | ||
- run: mkdir -p coredumps | ||
# Set core dump file name pattern | ||
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern' | ||
|
@@ -240,9 +240,9 @@ jobs: | |
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
- uses: microsoft/playwright-github-action@v1 | ||
- run: npm ci | ||
- run: npm run build | ||
- run: node lib/cli/cli install-deps | ||
- name: Create Android Emulator | ||
run: utils/avd_recreate.sh | ||
- name: Start Android Emulator | ||
|
@@ -269,11 +269,11 @@ jobs: | |
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 10 | ||
- uses: microsoft/playwright-github-action@v1 | ||
- name: Install Chrome Stable | ||
run: sudo apt install google-chrome-stable | ||
- run: npm ci | ||
- run: npm run build | ||
- run: node lib/cli/cli install-deps chromium | ||
- run: mkdir -p coredumps | ||
# Set core dump file name pattern | ||
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ import { Page } from '../client/page'; | |
import { BrowserType } from '../client/browserType'; | ||
import { BrowserContextOptions, LaunchOptions } from '../client/types'; | ||
import { spawn } from 'child_process'; | ||
import { installDeps } from '../install/installDeps'; | ||
|
||
program | ||
.version('Version ' + require('../../package.json').version) | ||
|
@@ -82,20 +83,34 @@ program | |
program | ||
.command('install [browserType...]') | ||
.description('ensure browsers necessary for this version of Playwright are installed') | ||
.action(function(browserType) { | ||
const allBrowsers = new Set(['chromium', 'firefox', 'webkit']); | ||
for (const type of browserType) { | ||
if (!allBrowsers.has(type)) { | ||
console.log(`Invalid browser name: '${type}'. Expecting 'chromium', 'firefox' or 'webkit'.`); | ||
process.exit(1); | ||
.action(async function(browserType) { | ||
try { | ||
const allBrowsers = new Set(['chromium', 'firefox', 'webkit']); | ||
for (const type of browserType) { | ||
if (!allBrowsers.has(type)) { | ||
console.log(`Invalid browser name: '${type}'. Expecting 'chromium', 'firefox' or 'webkit'.`); | ||
process.exit(1); | ||
} | ||
} | ||
if (browserType.length && browserType.includes('chromium')) | ||
browserType = browserType.concat('ffmpeg'); | ||
await installBrowsers(browserType.length ? browserType : undefined); | ||
} catch (e) { | ||
console.log(`Failed to install browsers\n${e}`); | ||
process.exit(1); | ||
} | ||
if (browserType.length && browserType.includes('chromium')) | ||
browserType = browserType.concat('ffmpeg'); | ||
installBrowsers(browserType.length ? browserType : undefined).catch((e: any) => { | ||
}); | ||
|
||
program | ||
.command('install-deps [browserType...]') | ||
.description('install dependencies necessary to run browser') | ||
.action(async function(browserType) { | ||
try { | ||
await installDeps(browserType); | ||
} catch (e) { | ||
console.log(`Failed to install browsers\n${e}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll fix the message |
||
process.exit(1); | ||
}); | ||
} | ||
}); | ||
|
||
const browsers = [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import childProcess from 'child_process'; | ||
import os from 'os'; | ||
import { getUbuntuVersion } from '../utils/ubuntuVersion'; | ||
|
||
const { deps } = require('../nativeDeps'); | ||
|
||
export async function installDeps(browserTypes: string[]) { | ||
if (os.platform() !== 'linux') | ||
return; | ||
if (!browserTypes.length) | ||
browserTypes = ['chromium', 'firefox', 'webkit']; | ||
browserTypes.push('tools'); | ||
|
||
const ubuntuVersion = await getUbuntuVersion(); | ||
if (ubuntuVersion !== '18.04' && ubuntuVersion !== '20.04') { | ||
console.warn('Cannot install dependencies for this linux distribution!'); // eslint-disable-line no-console | ||
return; | ||
} | ||
|
||
const libraries: string[] = []; | ||
for (const browserType of browserTypes) { | ||
if (ubuntuVersion === '18.04') | ||
libraries.push(...deps['bionic'][browserType]); | ||
else if (ubuntuVersion === '20.04') | ||
libraries.push(...deps['focal'][browserType]); | ||
} | ||
const uniqueLibraries = Array.from(new Set(libraries)); | ||
console.log('Installing Ubuntu dependencies...'); // eslint-disable-line no-console | ||
const commands: string[] = []; | ||
commands.push('apt-get update'); | ||
commands.push(['apt-get', 'install', '-y', '--no-install-recommends', | ||
...uniqueLibraries, | ||
].join(' ')); | ||
const child = childProcess.spawn('sudo', ['--', 'sh', '-c', `${commands.join('; ')}`], { stdio: 'inherit' }); | ||
pavelfeldman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await new Promise(f => child.on('exit', f)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
chromium