Updates for PF6 unit tests #503
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: ["opened", "synchronize", "reopened"] | |
| create: | |
| # Auto-cancel outdated runs when new commits are pushed | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| setup-browsers: | |
| name: 🌐 Setup Playwright Browsers | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| outputs: | |
| playwright-version: ${{ steps.playwright-version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install hatch | |
| run: pip install hatch | |
| - name: Cache hatch environment | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.local/share/hatch | |
| key: hatch-${{ runner.os }}-3.11-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| hatch-${{ runner.os }}-3.11- | |
| - name: Create test environment | |
| run: hatch env create test | |
| - name: Get Playwright version | |
| id: playwright-version | |
| run: | | |
| echo "version=$(hatch run test:python -c 'import playwright; print(playwright.__version__)')" >> $GITHUB_OUTPUT | |
| - name: Cache Playwright browsers | |
| uses: actions/cache@v4 | |
| id: playwright-cache | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}-browsers | |
| restore-keys: | | |
| playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}- | |
| - name: Install browsers | |
| if: steps.playwright-cache.outputs.cache-hit != 'true' | |
| run: hatch run test:install-browsers | |
| test: | |
| name: pf-v${{ matrix.pf-version }} (🐍 ${{ matrix.python-version }}, ${{ matrix.browser }}) | |
| runs-on: ubuntu-latest | |
| needs: setup-browsers | |
| timeout-minutes: 30 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| browser: [chromium, firefox] | |
| python-version: ["3.12", "3.13"] | |
| # Values are the numeric suffix only so they compose directly into | |
| # the hatch script names pf5 / pf6 and the --pf-version=v5 / v6 flag. | |
| pf-version: ["5", "6"] | |
| # Run coverage only for one combination to keep CI lean | |
| include: | |
| - browser: chromium | |
| python-version: "3.13" | |
| pf-version: "6" | |
| run-coverage: true | |
| exclude: [] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install hatch | |
| run: pip install hatch | |
| - name: Cache hatch environment | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.local/share/hatch | |
| key: hatch-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| hatch-${{ runner.os }}-${{ matrix.python-version }}- | |
| - name: Create test environment | |
| run: hatch env create test | |
| - name: Restore Playwright browsers cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-${{ runner.os }}-${{ needs.setup-browsers.outputs.playwright-version }}-browsers | |
| fail-on-cache-miss: true | |
| - name: Test with pytest (with coverage) | |
| if: matrix.run-coverage == true | |
| timeout-minutes: 25 | |
| run: | | |
| hatch run test:pf${{ matrix.pf-version }} \ | |
| -n 2 --browser=${{ matrix.browser }} \ | |
| --reruns 2 --reruns-delay 5 \ | |
| --cov=./src --cov-report=xml | |
| - name: Test with pytest (without coverage) | |
| if: matrix.run-coverage != true | |
| timeout-minutes: 25 | |
| run: | | |
| hatch run test:pf${{ matrix.pf-version }} \ | |
| -n 2 --browser=${{ matrix.browser }} \ | |
| --reruns 2 --reruns-delay 5 | |
| - name: Upload coverage to Codecov | |
| if: matrix.run-coverage == true | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: coverage.xml | |
| flags: unittests | |
| name: ${{ github.run_id }}-py-${{ matrix.python-version }}-${{ matrix.browser }} |