fix/ci/playwright-browser-cache #104
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: Build Python Project | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| types: [ | |
| opened, | |
| synchronize, | |
| reopened, | |
| ready_for_review | |
| ] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| # PYTHON | |
| PYTHON_VERSION: '3.14' | |
| PIP_ROOT_USER_ACTION: ignore | |
| # POETRY | |
| POETRY_VERSION: '2.3.2' | |
| # PYTHONPATH so absolute imports work | |
| PYTHONPATH: . | |
| jobs: | |
| look_for_source_code_changes: | |
| if: github.event_name != 'pull_request' || github.event.pull_request.draft == false | |
| runs-on: ubuntu-latest | |
| outputs: | |
| run_tests: ${{ steps.filter.outputs.run_tests }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - id: filter | |
| uses: dorny/paths-filter@v4 | |
| with: | |
| filters: | | |
| run_tests: | |
| - 'src/**' | |
| - 'test/**' | |
| - 'poetry.lock' | |
| - 'pyproject.toml' | |
| - 'docker-compose.yml' | |
| - 'Dockerfile' | |
| - '.github/workflows/ci.yml' | |
| test: | |
| timeout-minutes: 6 | |
| runs-on: ubuntu-latest | |
| needs: [look_for_source_code_changes] | |
| if: needs.look_for_source_code_changes.outputs.run_tests == 'true' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Cache Poetry, pipx, and dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.local/pipx | |
| ~/.cache/pypoetry | |
| ~/.cache/pip | |
| key: setup-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }} | |
| restore-keys: | | |
| setup-${{ runner.os }}-${{ env.PYTHON_VERSION }}- | |
| - name: Ensure Poetry is available | |
| run: | | |
| python -m pip install --upgrade pip pipx | |
| pipx install poetry==${POETRY_VERSION} | |
| echo "$(pipx environment --value PIPX_BIN_DIR)" >> $GITHUB_PATH | |
| - name: Create virtual environment | |
| run: python -m venv .venv | |
| - name: Activate virtual environment and confirm it's active | |
| run: | | |
| source .venv/bin/activate | |
| PYTHON_PATH=$(which python) | |
| if [[ "$PYTHON_PATH" == *".venv"* ]]; then | |
| echo "Python is using a .venv environment: $PYTHON_PATH" | |
| else | |
| echo "Python is NOT using a .venv environment: $PYTHON_PATH" | |
| exit 1 | |
| fi | |
| - name: Install dependencies | |
| run: | | |
| source .venv/bin/activate | |
| poetry install --no-root --with test | |
| - name: Cache Playwright browsers | |
| id: cache-playwright | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | |
| - name: Install Playwright browser | |
| if: steps.cache-playwright.outputs.cache-hit != 'true' | |
| run: | | |
| source .venv/bin/activate | |
| poetry run playwright install chromium | |