api-tracking #1519
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
| # This workflow will install Python dependencies, run tests and lint with a single version of Python | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
| name: Test Suite | |
| on: | |
| pull_request: | |
| branches: ['production', 'staging', 'transfer'] | |
| permissions: | |
| contents: read | |
| jobs: | |
| run-tests: | |
| runs-on: ubuntu-latest | |
| # Set shared env vars ONCE here for all steps | |
| env: | |
| MODE: development | |
| POSTGRES_HOST: localhost | |
| POSTGRES_PORT: 5432 | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: ocotilloapi_test | |
| DB_DRIVER: postgres | |
| BASE_URL: http://localhost:8000 | |
| SESSION_SECRET_KEY: supersecretkeyforunittests | |
| AUTHENTIK_DISABLE_AUTHENTICATION: 1 | |
| services: | |
| postgis: | |
| image: postgis/postgis:17-3.5 | |
| # don't test against latest. be explicit in version being tested to avoid breaking changes | |
| # image: postgis/postgis:latest | |
| # These env vars are ONLY for the service container itself | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_PORT: 5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| # Maps tcp port 5432 on service container to the host | |
| - 5432:5432 | |
| steps: | |
| - name: Check out source repository | |
| uses: actions/checkout@v6 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: "pyproject.toml" | |
| - name: Install the project | |
| run: uv sync --locked --all-extras --dev | |
| - name: Show Alembic heads | |
| run: uv run alembic heads | |
| - name: Create test database | |
| run: | | |
| PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -c "CREATE DATABASE ocotilloapi_test" | |
| PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d ocotilloapi_test -c "CREATE EXTENSION IF NOT EXISTS postgis" | |
| - name: Run tests | |
| run: uv run pytest -vv --durations=20 --cov --cov-report=xml --junitxml=junit.xml --ignore=tests/transfers | |
| - name: Run BDD tests | |
| run: | | |
| uv run behave tests/features --tags="@backend and @production and not @skip" --no-capture | |
| - name: Upload results to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| report_type: test_results | |
| token: ${{ secrets.CODECOV_TOKEN }} | |