diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e48cb0749..240afe8f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,8 +103,12 @@ jobs: python-version: '3.12' browser: chromium runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: microsoft/playwright/.github/actions/ci-env@main - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: @@ -127,34 +131,17 @@ jobs: id: install run: python -m playwright install --with-deps ${{ matrix.browser }} - name: Common Tests - run: | - ${{ runner.os == 'Windows' && '. ./scripts/windows-normal-io.ps1' || '' }} - pytest tests/common --browser=${{ matrix.browser }} + run: $CI_ENV_EXEC pytest tests/common --browser=${{ matrix.browser }} - name: Test Reference count - run: | - ${{ runner.os == 'Windows' && '. ./scripts/windows-normal-io.ps1' || '' }} - pytest tests/test_reference_count_async.py --browser=${{ matrix.browser }} + run: $CI_ENV_EXEC pytest tests/test_reference_count_async.py --browser=${{ matrix.browser }} - name: Test Wheel Installation - run: | - ${{ runner.os == 'Windows' && '. ./scripts/windows-normal-io.ps1' || '' }} - pytest tests/test_installation.py --browser=${{ matrix.browser }} - - name: Test Sync API - if: runner.os != 'Linux' - run: | - ${{ runner.os == 'Windows' && '. ./scripts/windows-normal-io.ps1' || '' }} - pytest tests/sync --browser=${{ matrix.browser }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes + run: $CI_ENV_EXEC pytest tests/test_installation.py --browser=${{ matrix.browser }} - name: Test Sync API - if: runner.os == 'Linux' - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" pytest tests/sync --browser=${{ matrix.browser }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes + run: $CI_ENV_EXEC pytest tests/sync --browser=${{ matrix.browser }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes - name: Test Async API # Also after a failed sync step: the two suites report on their own. - if: ${{ !cancelled() && steps.install.outcome == 'success' && runner.os != 'Linux' }} - run: | - ${{ runner.os == 'Windows' && '. ./scripts/windows-normal-io.ps1' || '' }} - pytest tests/async --browser=${{ matrix.browser }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes - - name: Test Async API - if: ${{ !cancelled() && steps.install.outcome == 'success' && runner.os == 'Linux' }} - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" pytest tests/async --browser=${{ matrix.browser }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes + if: ${{ !cancelled() && steps.install.outcome == 'success' }} + run: $CI_ENV_EXEC pytest tests/async --browser=${{ matrix.browser }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes test-stable: name: Stable @@ -173,8 +160,12 @@ jobs: - os: playwright-x64-server2025-64-core browser-channel: msedge runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: microsoft/playwright/.github/actions/ci-env@main - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: @@ -197,26 +188,13 @@ jobs: id: install run: python -m playwright install ${{ matrix.browser-channel }} --with-deps - name: Common Tests - run: | - ${{ runner.os == 'Windows' && '. ./scripts/windows-normal-io.ps1' || '' }} - pytest tests/common --browser=chromium --browser-channel=${{ matrix.browser-channel }} + run: $CI_ENV_EXEC pytest tests/common --browser=chromium --browser-channel=${{ matrix.browser-channel }} - name: Test Sync API - if: runner.os != 'Linux' - run: | - ${{ runner.os == 'Windows' && '. ./scripts/windows-normal-io.ps1' || '' }} - pytest tests/sync --browser=chromium --browser-channel=${{ matrix.browser-channel }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes - - name: Test Sync API - if: runner.os == 'Linux' - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" pytest tests/sync --browser=chromium --browser-channel=${{ matrix.browser-channel }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes + run: $CI_ENV_EXEC pytest tests/sync --browser=chromium --browser-channel=${{ matrix.browser-channel }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes - name: Test Async API # Also after a failed sync step: the two suites report on their own. - if: ${{ !cancelled() && steps.install.outcome == 'success' && runner.os != 'Linux' }} - run: | - ${{ runner.os == 'Windows' && '. ./scripts/windows-normal-io.ps1' || '' }} - pytest tests/async --browser=chromium --browser-channel=${{ matrix.browser-channel }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes - - name: Test Async API - if: ${{ !cancelled() && steps.install.outcome == 'success' && runner.os == 'Linux' }} - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" pytest tests/async --browser=chromium --browser-channel=${{ matrix.browser-channel }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes + if: ${{ !cancelled() && steps.install.outcome == 'success' }} + run: $CI_ENV_EXEC pytest tests/async --browser=chromium --browser-channel=${{ matrix.browser-channel }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes test_examples: name: Examples diff --git a/scripts/windows-normal-io.ps1 b/scripts/windows-normal-io.ps1 deleted file mode 100644 index f1308b638..000000000 --- a/scripts/windows-normal-io.ps1 +++ /dev/null @@ -1,44 +0,0 @@ -# Dot-source at the start of a Windows test step: the self-hosted runner starts steps at -# I/O priority Low, which the driver and the browsers inherit, and Firefox storage flushes -# then stall until tests time out. See https://github.com/microsoft/playwright/issues/43704. - -$ErrorActionPreference = 'Stop' - -Add-Type -TypeDefinition @' -using System; -using System.Runtime.InteropServices; - -public static class TestProcessIOPriority { - [DllImport("ntdll.dll")] - public static extern int NtSetInformationProcess( - IntPtr process, int informationClass, ref int information, int size); - - [DllImport("ntdll.dll")] - public static extern int NtQueryInformationProcess( - IntPtr process, int informationClass, out int information, int size, out int length); -} -'@ - -$priority = 0 -$length = 0 -$status = [TestProcessIOPriority]::NtQueryInformationProcess( - [IntPtr](-1), 33, [ref]$priority, 4, [ref]$length) -if ($status -ne 0) { - throw ('Reading I/O priority failed: NTSTATUS 0x{0:X8}' -f $status) -} -$inheritedPriority = $priority -$priority = 2 -$status = [TestProcessIOPriority]::NtSetInformationProcess( - [IntPtr](-1), 33, [ref]$priority, 4) -if ($status -ne 0) { - throw ('Setting normal I/O priority failed: NTSTATUS 0x{0:X8}' -f $status) -} -$status = [TestProcessIOPriority]::NtQueryInformationProcess( - [IntPtr](-1), 33, [ref]$priority, 4, [ref]$length) -if ($status -ne 0) { - throw ('Reading I/O priority failed: NTSTATUS 0x{0:X8}' -f $status) -} -if ($priority -ne 2) { - throw "Expected normal I/O priority (2), got $priority" -} -Write-Host "Test launcher I/O priority: $inheritedPriority -> $priority (Normal)"