fix test assertion to expect prefixed ScoreEventID in aux storage #267
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: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| ENV: TEST | |
| PYTHONDONTWRITEBYTECODE: 1 | |
| permissions: | |
| contents: read | |
| packages: write | |
| pull-requests: write | |
| jobs: | |
| quality: | |
| name: Lint, Format & Type Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Install dependencies | |
| run: uv sync --dev | |
| - name: Check code formatting with ruff | |
| run: uv run ruff format --check . | |
| - name: Run ruff linter | |
| run: uv run ruff check . | |
| - name: Run pyright type checker | |
| run: uv run pyright | |
| migration-validation: | |
| name: Migration Validation | |
| runs-on: ubuntu-latest | |
| env: | |
| ENABLE_ADMIN_API: true | |
| ENABLE_CLIENT_API: true | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_DB: ${{ vars.DB_NAME }} | |
| POSTGRES_USER: ${{ vars.DB_USER }} | |
| POSTGRES_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Install dependencies | |
| run: uv sync --dev | |
| - name: Test fresh migration from base | |
| env: | |
| DB_NAME: ${{ vars.DB_NAME }} | |
| DB_USER: ${{ vars.DB_USER }} | |
| DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| run: | | |
| # Apply all migrations to fresh database | |
| uv run alembic upgrade head | |
| echo "✅ All migrations applied successfully to fresh database" | |
| - name: Verify no pending migrations | |
| env: | |
| DB_NAME: ${{ vars.DB_NAME }} | |
| DB_USER: ${{ vars.DB_USER }} | |
| DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| run: | | |
| # Check that there are no uncommitted model changes | |
| uv run alembic check | |
| echo "✅ No pending migrations detected" | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| needs: quality | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_DB: ${{ vars.DB_NAME }} | |
| POSTGRES_USER: ${{ vars.DB_USER }} | |
| POSTGRES_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Install dependencies | |
| run: uv sync --dev | |
| - name: Run tests with coverage | |
| id: tests | |
| continue-on-error: true | |
| env: | |
| DB_NAME: ${{ vars.DB_NAME }} | |
| DB_USER: ${{ vars.DB_USER }} | |
| DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| ENABLE_ADMIN_API: true | |
| ENABLE_CLIENT_API: true | |
| run: | | |
| uv run pytest -x \ | |
| --cov=src \ | |
| tests -n 2 --dist loadgroup \ | |
| -p no:pastebin -p no:nose -p no:doctest | |
| echo "pytest_exit_code=$?" >> $GITHUB_OUTPUT | |
| - name: Generate coverage report | |
| id: coverage | |
| if: always() | |
| run: | | |
| uv run coverage report --format=markdown --sort=Cover --skip-covered > coverage_report.md | |
| uv run coverage report --sort=Cover | |
| echo "=== coverage_report.md contents ===" | |
| cat coverage_report.md | |
| echo "=== file info ===" | |
| ls -la coverage_report.md | |
| echo "coverage_exit_code=$?" >> $GITHUB_OUTPUT | |
| - name: Comment coverage report on PR | |
| if: always() && github.event_name == 'pull_request' | |
| run: | | |
| gh pr comment ${{ github.event.pull_request.number }} --body-file coverage_report.md | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if tests and coverage passed | |
| if: always() | |
| run: | | |
| if [ "${{ steps.tests.outputs.pytest_exit_code }}" != "0" ]; then | |
| echo "Tests failed with exit code ${{ steps.tests.outputs.pytest_exit_code }}" | |
| exit 1 | |
| fi | |
| if [ "${{ steps.coverage.outputs.coverage_exit_code }}" != "0" ]; then | |
| echo "Coverage check failed with exit code ${{ steps.coverage.outputs.coverage_exit_code }}" | |
| exit 1 | |
| fi | |
| build: | |
| name: Build Docker Image | |
| runs-on: ubuntu-latest | |
| needs: [test, migration-validation] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set outputs | |
| id: vars | |
| run: | | |
| SHORT_SHA=$(git rev-parse --short HEAD) | |
| REPO_NAME=${{ github.repository }} | |
| echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_OUTPUT | |
| echo "IMG_URL=ghcr.io/${REPO_NAME,,}:${SHORT_SHA}" >> $GITHUB_OUTPUT | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./docker/api.Dockerfile | |
| push: true | |
| tags: | | |
| ${{ steps.vars.outputs.IMG_URL }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Comment on PR with image location | |
| if: github.event_name == 'pull_request' | |
| uses: thollander/actions-comment-pull-request@v2 | |
| with: | |
| message: | | |
| ## 🐳 Docker Image Built | |
| The Docker image for this PR has been built and pushed: | |
| ``` | |
| ${{ steps.vars.outputs.IMG_URL }} | |
| ``` |