diff --git a/.github/actions/setup-playwright/action.yml b/.github/actions/setup-playwright/action.yml new file mode 100644 index 0000000000..d64bb82ae1 --- /dev/null +++ b/.github/actions/setup-playwright/action.yml @@ -0,0 +1,36 @@ +name: "Setup Playwright" +description: "Install Playwright browsers and dependencies with caching" +inputs: + browsers: + description: "Space-separated list of browsers to install (e.g., 'chromium', 'chromium webkit')" + required: false + default: "chromium" +runs: + using: "composite" + steps: + - name: Get Playwright version + id: playwright-version + shell: bash + run: | + # Extract Playwright version from bun.lock + VERSION=$(grep -A1 '"playwright":' bun.lock | grep -oP '"\K[0-9]+\.[0-9]+\.[0-9]+' | head -1) + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Playwright version: $VERSION" + + - name: Cache Playwright browsers + id: cache-playwright + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}-${{ inputs.browsers }} + restore-keys: | + ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}- + + - name: Install Playwright browsers + if: steps.cache-playwright.outputs.cache-hit != 'true' + shell: bash + run: bun x playwright install ${{ inputs.browsers }} + + - name: Install Playwright system dependencies + shell: bash + run: bun x playwright install-deps ${{ inputs.browsers }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d63c54d58..86bcea98b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,8 +134,7 @@ jobs: - uses: ./.github/actions/setup-mux - - name: Install Playwright browsers - run: bun x playwright install --with-deps + - uses: ./.github/actions/setup-playwright - name: Build Storybook run: make storybook-build @@ -160,16 +159,12 @@ jobs: - uses: ./.github/actions/setup-mux - - name: Install system dependencies + - name: Install xvfb run: | sudo apt-get update sudo apt-get install -y xvfb - - name: Install Playwright runtime dependencies - run: bun x playwright install-deps - - - name: Install Playwright browsers - run: bun x playwright install --with-deps + - uses: ./.github/actions/setup-playwright - name: Run e2e tests run: xvfb-run -a make test-e2e