Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Browser binary caching does not work in GitHub actions #2133

Closed
1 task done
nefrob opened this issue Oct 24, 2023 · 2 comments
Closed
1 task done

[BUG] Browser binary caching does not work in GitHub actions #2133

nefrob opened this issue Oct 24, 2023 · 2 comments

Comments

@nefrob
Copy link

nefrob commented Oct 24, 2023

System info

  • Playwright Version: v1.39.0
  • Operating System: Ubuntu
  • Browser: All
  • Other info: Github Actions

Source code

  • I provided exact source code that allows reproducing the issue locally.

GitHub Action file

Following the approach outlined in this issue for the node version of playwright: microsoft/playwright#7249.

name: Demo

on:
    workflow_dispatch:

env:
    PLAYWRIGHT_BROWSERS_PATH: '~/.cache/ms-playwright'

jobs:
    test:
        runs-on: 'ubuntu-22.04'

        steps:
            - name: Git - Get Sources
              uses: actions/checkout@v3
              with:
                  fetch-depth: 0

            - name: Set up Python 3.11
              uses: actions/setup-python@v4
              with:
                  cache-dependency-path: "requirements.txt"
                  cache: "pip"
                  python-version: "3.11"

            - name: Install Python dependencies
              run: pip install -r requirements.txt

            - name: Set playwright version
              run: |
                PLAYWRIGHT_VERSION=$(playwright --version)
                echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV

            - name: Cache playwright browser binaries
              uses: actions/cache@v3
              id: playwright-cache
              with:
                path: ~/.cache/ms-playwright
                key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}

            - name: Install playwright OS dependencies
              if: steps.playwright-cache.outputs.cache-hit == 'true'
              run: playwright install-deps

            - name: Install playwright browser binaries & OS dependencies
              if: steps.playwright-cache.outputs.cache-hit != 'true'
              run: playwright install --with-deps chromium

            - name: Run tests
              run: pytest

Steps

  • Run the action via manual dispatch

Expected

  • First run install the dependencies and browsers
  • Repeated runs skips the browser installs
  • Tests successfully run either way

Actual

Dependencies and browsers are installed but playwright complains:
Screenshot 2023-10-24 at 3 50 37 PM

E       playwright._impl._api_types.Error: Executable doesn't exist at /home/runner/work/tilt-repo/tilt-repo/automation/~/.cache/ms-playwright/chromium-1084/chrome-linux/chrome
E       ╔════════════════════════════════════════════════════════════╗
E       ║ Looks like Playwright was just installed or updated.       ║
E       ║ Please run the following command to download new browsers: ║
E       ║                                                            ║
E       ║     playwright install                                     ║
E       ║                                                            ║
E       ║ <3 Playwright Team                                         ║
E       ╚════════════════════════════════════════════════════════════╝

If this behavior is not intended please update the docs: https://playwright.dev/python/docs/ci-intro#on-pushpull_request.

@mxschmitt
Copy link
Member

We strongly discourage caching browsers as per here. If you want to have the browsers pre-installed, we recommend using our container: https://playwright.dev/python/docs/ci-intro#via-containers

@mxschmitt mxschmitt closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
@nefrob
Copy link
Author

nefrob commented Oct 25, 2023

Thanks for the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants