Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove 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'
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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 }}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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'
Expand Down
35 changes: 25 additions & 10 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}`);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix the message

process.exit(1);
});
}
});

const browsers = [
Expand Down
52 changes: 52 additions & 0 deletions src/install/installDeps.ts
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' });
await new Promise(f => child.on('exit', f));
}
Loading