diff --git a/.github/actions/playwright-install/action.yml b/.github/actions/playwright-install/action.yml new file mode 100644 index 000000000..bf935813a --- /dev/null +++ b/.github/actions/playwright-install/action.yml @@ -0,0 +1,20 @@ +name: Install Playwright browsers +description: Cache and install Playwright Chromium browser and system dependencies + +runs: + using: composite + steps: + - name: Cache Playwright browsers + id: playwright-cache + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - name: Install Playwright browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' + run: yarn playwright install --with-deps chromium + shell: bash + - name: Install Playwright system dependencies + if: steps.playwright-cache.outputs.cache-hit == 'true' + run: yarn playwright install-deps chromium + shell: bash diff --git a/.github/workflows/lint-build-test.yml b/.github/workflows/lint-build-test.yml index 7b20169ac..dabd8a939 100644 --- a/.github/workflows/lint-build-test.yml +++ b/.github/workflows/lint-build-test.yml @@ -17,8 +17,6 @@ jobs: cache-node-modules: true is-high-risk-environment: false node-version: ${{ matrix.node-version }} - env: - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 lint: name: Lint @@ -33,8 +31,6 @@ jobs: with: is-high-risk-environment: false node-version: ${{ matrix.node-version }} - env: - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 - run: yarn lint - name: Require clean working directory shell: bash @@ -57,8 +53,6 @@ jobs: with: is-high-risk-environment: false node-version: ${{ matrix.node-version }} - env: - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 - run: yarn changelog:validate - name: Require clean working directory shell: bash @@ -81,8 +75,6 @@ jobs: with: is-high-risk-environment: false node-version: ${{ matrix.node-version }} - env: - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 - run: yarn build - name: Require clean working directory shell: bash @@ -105,8 +97,7 @@ jobs: with: is-high-risk-environment: false node-version: ${{ matrix.node-version }} - env: - PLAYWRIGHT_ONLY_SHELL: 1 + - uses: ./.github/actions/playwright-install - run: yarn build - run: "yarn test --coverage=${{ matrix.node-version == '24.x' && 'true' || 'false' }}" - name: Upload coverage artifact @@ -137,8 +128,6 @@ jobs: with: is-high-risk-environment: false node-version: ${{ matrix.node-version }} - env: - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 - run: yarn build - run: yarn test:integration - name: Require clean working directory @@ -163,17 +152,7 @@ jobs: with: is-high-risk-environment: false node-version: ${{ matrix.node-version }} - - name: Cache Playwright browsers - id: playwright-cache - uses: actions/cache@v4 - with: - path: ~/.cache/ms-playwright - key: playwright-${{ runner.os }}-${{ hashFiles('yarn.lock') }} - - name: Install Playwright browsers - if: steps.playwright-cache.outputs.cache-hit != 'true' - run: yarn playwright install chromium - - name: Install Playwright system dependencies - run: yarn playwright install-deps chromium + - uses: ./.github/actions/playwright-install - run: VITE_DB_FOLDER=e2e yarn build - name: Run E2E tests id: e2e diff --git a/scripts/playwright-install.sh b/scripts/playwright-install.sh index 7a5251241..96839475f 100755 --- a/scripts/playwright-install.sh +++ b/scripts/playwright-install.sh @@ -1,24 +1,9 @@ #!/bin/bash -# Skip in Dependabot environments (not needed and causes failures) -if "$(dirname "$0")/utils/check-dependabot.sh"; then - echo "⏭️ Skipping Playwright install in Dependabot environment" - exit 0 -fi - -# Also respect PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD for CI environments -if [ "$PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD" = "1" ]; then - echo "⏭️ Skipping Playwright install (PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1)" +# In CI, browsers are installed separately via the playwright-install composite action +if [ "$CI" = "true" ]; then + echo "⏭️ Skipping Playwright install in CI" exit 0 fi -# Install Chromium (with system deps in CI, headless shell only if requested) -if [ "$CI" = "true" ]; then - if [ "$PLAYWRIGHT_ONLY_SHELL" = "1" ]; then - yarn playwright install --with-deps --only-shell chromium - else - yarn playwright install --with-deps chromium - fi -else - yarn playwright install chromium -fi +yarn playwright install --with-deps chromium