From 17b6f06b98953e76df5279431fc88a63edd5e043 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 2 Jun 2021 10:47:10 -0700 Subject: [PATCH] feat: install media pack on windows with `npx playwright install-deps` (#6836) Chromium on Windows requires Media Pack to be installed. This patch moves media pack installation under the `npx playwright install-deps` umbrella. --- .github/workflows/tests_secondary.yml | 16 +--------------- bin/install_media_pack.ps1 | 1 + src/install/installDeps.ts | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 17 deletions(-) create mode 100644 bin/install_media_pack.ps1 diff --git a/.github/workflows/tests_secondary.yml b/.github/workflows/tests_secondary.yml index ad923734de..ef9d24cefa 100644 --- a/.github/workflows/tests_secondary.yml +++ b/.github/workflows/tests_secondary.yml @@ -85,9 +85,6 @@ jobs: browser: [chromium, firefox, webkit] runs-on: windows-latest steps: - - name: Install Media Pack - shell: powershell - run: Install-WindowsFeature Server-Media-Foundation - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: @@ -222,9 +219,6 @@ jobs: name: "Chrome Stable (Win)" runs-on: windows-latest steps: - - name: Install Media Pack - shell: powershell - run: Install-WindowsFeature Server-Media-Foundation - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: @@ -302,9 +296,6 @@ jobs: name: "Firefox Stable (Win)" runs-on: windows-latest steps: - - name: Install Media Pack - shell: powershell - run: Install-WindowsFeature Server-Media-Foundation - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: @@ -313,6 +304,7 @@ jobs: env: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 - run: npm run build + - run: node lib/cli/cli install-deps chromium - run: node lib/cli/cli install firefox-stable chromium - run: npm run ftest shell: bash @@ -355,9 +347,6 @@ jobs: name: "Edge Stable (Win)" runs-on: windows-latest steps: - - name: Install Media Pack - shell: powershell - run: Install-WindowsFeature Server-Media-Foundation - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: @@ -409,9 +398,6 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v2 - - name: Install Media Pack - shell: powershell - run: Install-WindowsFeature Server-Media-Foundation - uses: actions/setup-node@v2 with: node-version: 12 diff --git a/bin/install_media_pack.ps1 b/bin/install_media_pack.ps1 new file mode 100644 index 0000000000..7812422d5f --- /dev/null +++ b/bin/install_media_pack.ps1 @@ -0,0 +1 @@ +Install-WindowsFeature Server-Media-Foundation diff --git a/src/install/installDeps.ts b/src/install/installDeps.ts index cc858db735..2badc4cc80 100644 --- a/src/install/installDeps.ts +++ b/src/install/installDeps.ts @@ -16,15 +16,27 @@ import childProcess from 'child_process'; import os from 'os'; +import path from 'path'; import { getUbuntuVersion } from '../utils/ubuntuVersion'; +import * as utils from '../utils/utils'; const { deps } = require('../nativeDeps'); +const SCRIPTS_DIRECTORY = path.join(__dirname, '..', '..', 'bin'); + export async function installDeps(browserTypes: string[]) { - if (os.platform() !== 'linux') - return; if (!browserTypes.length) browserTypes = ['chromium', 'firefox', 'webkit']; + if (os.platform() === 'win32') { + if (browserTypes.includes('chromium')) { + const {code} = await utils.spawnAsync('powershell.exe', [path.join(SCRIPTS_DIRECTORY, 'install_media_pack.ps1')], { cwd: SCRIPTS_DIRECTORY, stdio: 'inherit' }); + if (code !== 0) + throw new Error('Failed to install windows dependencies!'); + } + return; + } + if (os.platform() !== 'linux') + return; browserTypes.push('tools'); const ubuntuVersion = await getUbuntuVersion();