Skip to content

Commit

Permalink
chore: migrate from gha to explicit npx playwright install
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Mar 10, 2021
1 parent fea6669 commit 57df900
Show file tree
Hide file tree
Showing 3 changed files with 288 additions and 18 deletions.
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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
22 changes: 13 additions & 9 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,18 +83,21 @@ 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 {
await installDeps();
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);
}
}
}
installBrowsers(browserType.length ? browserType : undefined).catch((e: any) => {
await installBrowsers(browserType.length ? browserType : undefined);
} catch (e) {
console.log(`Failed to install browsers\n${e}`);
process.exit(1);
});
}
});

const browsers = [
Expand Down
Loading

0 comments on commit 57df900

Please sign in to comment.