refactor/readme/improve-project-tagline (#60) #113
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' | |
| lint: | |
| timeout-minutes: 3 | |
| runs-on: ubuntu-latest | |
| 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 format | |
| - name: Check for successful installation | |
| run: | | |
| source .venv/bin/activate | |
| poetry check | |
| - name: Format and lint project | |
| run: | | |
| source .venv/bin/activate | |
| poetry run python tasks/format.py --dry-run | |
| test: | |
| timeout-minutes: 6 | |
| runs-on: ubuntu-latest | |
| needs: [look_for_source_code_changes, lint] | |
| if: needs.look_for_source_code_changes.outputs.run_tests == 'true' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build API image with cache | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| load: true | |
| tags: flask_api:ci | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Start Docker Compose | |
| run: docker compose up -d | |
| - 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: Run API tests | |
| run: poetry run pytest -rfsxE --capture=no --log-cli-level=DEBUG --maxfail=1 ./test/test__server__api.py | |
| - name: Cache Playwright browsers | |
| id: cache-playwright | |
| uses: actions/cache@v5 | |
| 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 --with-deps chromium | |
| - name: Run Web UI tests | |
| run: poetry run pytest -rfsxE --capture=no --log-cli-level=DEBUG --maxfail=1 --tracing=retain-on-failure ./test/test__server__web_ui.py | |
| - uses: actions/upload-artifact@v7 | |
| if: ${{ !cancelled() && hashFiles('test-results/**') != '' }} | |
| with: | |
| name: playwright-traces | |
| path: test-results/ |