name: Test permissions: contents: read concurrency: group: test-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true on: push: tags-ignore: - "*" branches: ["main"] pull_request: branches: ["main"] paths: - "src/**" - ".github/workflows/test.yml" - "pyproject.toml" - "justfile" merge_group: workflow_call: workflow_dispatch: inputs: debug: description: "Open ssh debug session." required: true default: false type: boolean clear_cache: description: "Clear GitHub Tool cache." required: true default: false type: boolean schedule: # Every Sunday at 9:00 AM Los Angeles time. # GitHub cron is UTC; 09:00 PT == 17:00 UTC (PST). - cron: "0 17 * * 0" jobs: postgres: runs-on: ubuntu-latest permissions: contents: read # Service containers to run with `container-job` strategy: fail-fast: false matrix: python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] postgres-version: ["12", "14", "latest"] psycopg-version: ["psycopg2", "psycopg3"] django-version: - "dj42" # LTS April 2026 - "dj52" # LTS April 2028 - "dj61" # exclude: - python-version: "3.10" django-version: "dj61" - python-version: "3.11" django-version: "dj61" - python-version: "3.13" django-version: "dj42" - python-version: "3.14" django-version: "dj42" - python-version: "3.14" django-version: "dj52" - postgres-version: "12" django-version: "dj52" - postgres-version: "12" django-version: "dj61" - postgres-version: "14" django-version: "dj61" - postgres-version: "latest" django-version: "dj42" - postgres-version: "12" psycopg-version: "psycopg3" - postgres-version: "latest" psycopg-version: "psycopg2" # https://github.com/psycopg/psycopg2/pull/1695 - python-version: "3.13" psycopg-version: "psycopg2" - python-version: "3.14" psycopg-version: "psycopg2" # pin each image to its digest (satisfies zizmor unpinned-images) # while keeping postgres-version driving the matrix include: - postgres-version: "12" postgres-image: "postgres:12@sha256:2f2a8c2a7d10862e7fba2602e304523554f9df8244c632dafe2628ccb398fb5c" - postgres-version: "14" postgres-image: "postgres:14@sha256:bbb8851608e3ff4901156bf6a4bf90735a9d44ae014c03811bfdb2f9c354b18b" - postgres-version: "latest" postgres-image: "postgres:latest@sha256:8ff36f3c66371cba71d20ceedccfc3de9669a68737607888c4ef0af93abe8e39" env: RDBMS: postgres POSTGRES_PASSWORD: postgres PGPASSWORD: postgres POSTGRES_USER: postgres POSTGRES_HOST: localhost POSTGRES_PORT: 5432 COVERAGE_FILE: linux-py${{ matrix.python-version }}-${{ matrix.django-version }}-${{ matrix.psycopg-version }}-pg${{ matrix.postgres-version }}.coverage TEST_PYTHON_VERSION: ${{ matrix.python-version }} TEST_DJANGO_VERSION: ${{ matrix.django-version }} TEST_DATABASE_CLIENT_VERSION: ${{ matrix.psycopg-version }} TEST_DATABASE_VERSION: ${{ matrix.postgres-version }} # Service containers to run with `runner-job` services: # Label used to access the service container postgres: # Docker Hub image image: ${{ matrix.postgres-image }} # Provide the password for postgres env: POSTGRES_PASSWORD: postgres # Set health checks to wait until postgres has started 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: Clear Tool cache if: ${{ github.event.inputs.clear_cache == 'true' }} run: sudo rm -rf /opt/hostedtoolcache - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false - name: Set up Python ${{ matrix.python-version }} id: sp uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 with: python-version: ${{ matrix.python-version }} allow-prereleases: true - name: Create test databases run: | psql -h localhost -p 5432 -U postgres -d postgres -c "CREATE DATABASE test1;" psql -h localhost -p 5432 -U postgres -d postgres -c "CREATE DATABASE test2;" - name: Install uv uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 with: enable-cache: false - name: Setup Just uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 - name: Install Emacs if: ${{ github.event.inputs.debug == 'true' }} run: | sudo apt install emacs - name: Setup tmate session if: ${{ github.event.inputs.debug == 'true' }} uses: mxschmitt/action-tmate@35b54afac29c97fb54faba5b513f8fbd1882f113 timeout-minutes: 60 - name: Run Unit Tests env: TEST_PYTHON: ${{ steps.sp.outputs.python-path }} run: | just test-all --group "$TEST_DATABASE_CLIENT_VERSION" -p "$TEST_PYTHON" --group "$TEST_DJANGO_VERSION" - name: Store coverage files uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: name: ${{ env.COVERAGE_FILE }} path: ${{ env.COVERAGE_FILE }} sqlite: runs-on: ubuntu-latest permissions: contents: read env: RDBMS: sqlite COVERAGE_FILE: linux-py${{ matrix.python-version }}-${{ matrix.django-version }}-sqlite.coverage TEST_PYTHON_VERSION: ${{ matrix.python-version }} TEST_DJANGO_VERSION: ${{ matrix.django-version }} TEST_DATABASE_VERSION: "sqlite" strategy: fail-fast: false matrix: python-version: ["3.10", "3.12", "3.14"] django-version: - "dj42" # LTS April 2026 - "dj52" # LTS April 2028 - "dj61" # exclude: - python-version: "3.10" django-version: "dj52" - python-version: "3.10" django-version: "dj61" - python-version: "3.12" django-version: "dj42" - python-version: "3.12" django-version: "dj61" - python-version: "3.14" django-version: "dj42" - python-version: "3.14" django-version: "dj52" steps: - name: Clear Tool cache if: ${{ github.event.inputs.clear_cache == 'true' }} run: sudo rm -rf /opt/hostedtoolcache - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 id: sp with: python-version: ${{ matrix.python-version }} allow-prereleases: true - name: Install uv uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 with: enable-cache: false - name: Setup Just uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 - name: Install Emacs if: ${{ github.event.inputs.debug == 'true' }} run: | sudo apt install emacs - name: Setup tmate session if: ${{ github.event.inputs.debug == 'true' }} uses: mxschmitt/action-tmate@35b54afac29c97fb54faba5b513f8fbd1882f113 timeout-minutes: 60 - name: Run Unit Tests env: TEST_PYTHON: ${{ steps.sp.outputs.python-path }} run: | just test-all -p "$TEST_PYTHON" --group "$TEST_DJANGO_VERSION" - name: Store coverage files uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: name: ${{ env.COVERAGE_FILE }} path: ${{ env.COVERAGE_FILE }} mysql: runs-on: ubuntu-latest permissions: contents: read strategy: fail-fast: false matrix: python-version: ["3.10", "3.12", "3.14"] mysql-version: ["8.0", "latest"] mysqlclient-version: ["mysqlclient14", "mysqlclient2x"] django-version: - "dj42" # LTS April 2024 - "dj52" # LTS April 2028 - "dj61" # exclude: - django-version: "dj42" mysql-version: "latest" - django-version: "dj61" mysql-version: "8.0" - mysql-version: "latest" mysqlclient-version: "mysqlclient14" - python-version: "3.12" django-version: "dj42" - python-version: "3.14" django-version: "dj42" - python-version: "3.10" django-version: "dj52" - python-version: "3.14" django-version: "dj52" - django-version: "dj52" mysqlclient-version: "mysqlclient14" - python-version: "3.10" django-version: "dj61" - python-version: "3.12" django-version: "dj61" # pin each image to its digest (satisfies zizmor unpinned-images) # while keeping mysql-version driving the matrix include: - mysql-version: "8.0" mysql-image: "mysql:8.0@sha256:7dcddc01f13bab2f15cde676d44d01f61fc9f99fe7785e86196dfc07d358ae2b" - mysql-version: "latest" mysql-image: "mysql:latest@sha256:c11782aa2a96624c1efc121768641d96954faa136d6aa82751b032d8c426ffbc" env: RDBMS: mysql MYSQL_VERSION: ${{ matrix.mysql-version }} COVERAGE_FILE: linux-py${{ matrix.python-version }}-${{ matrix.django-version }}-${{ matrix.mysqlclient-version }}-mysql${{ matrix.mysql-version }}.coverage TEST_PYTHON_VERSION: ${{ matrix.python-version }} TEST_DJANGO_VERSION: ${{ matrix.django-version }} TEST_DATABASE_CLIENT_VERSION: ${{ matrix.mysqlclient-version }} TEST_DATABASE_VERSION: ${{ matrix.mysql-version }} services: mysql: # Docker Hub image image: ${{ matrix.mysql-image }} # Provide the password for mysql env: MYSQL_ROOT_PASSWORD: root MYSQL_MULTIPLE_DATABASES: test1,test2 # Set health checks to wait until mysql has started options: >- --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5 ports: # Maps tcp port 3306 on service container to the host - 3306:3306 steps: # make text comparisons case sensitive (some tests) - name: Set default collation for MySQL run: | mysql -h 127.0.0.1 -u root -proot <- --health-cmd="${{ matrix.mariadb-healthcheck }}" --health-interval 10s --health-timeout 5s --health-retries 5 ports: # Maps tcp port 3306 on service container to the host - 3306:3306 steps: # make text comparisons case sensitive (some tests) - name: Set default collation for MariaDB run: | mysql -h 127.0.0.1 -u root -proot <- --health-cmd healthcheck.sh --health-interval 10s --health-timeout 5s --health-retries 10 oracle2: image: ${{ matrix.oracle-image }} env: ORACLE_PASSWORD: password ORACLE_DATABASE: test2 # Forward Oracle port ports: - 1522:1521 # Provide healthcheck script options for startup options: >- --health-cmd healthcheck.sh --health-interval 10s --health-timeout 5s --health-retries 10 steps: - name: Set coverage file run: | ORACLE_TAG=$(echo "$TEST_DATABASE_VERSION" | cut -d':' -f2) echo "COVERAGE_FILE=linux-py${TEST_PYTHON_VERSION}-${TEST_DJANGO_VERSION}-oracle${ORACLE_TAG}.coverage" >> $GITHUB_ENV - name: Clear Tool cache if: ${{ github.event.inputs.clear_cache == 'true' }} run: sudo rm -rf /opt/hostedtoolcache - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false - name: Set up Python ${{ matrix.python-version }} id: sp uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 with: python-version: ${{ matrix.python-version }} allow-prereleases: true - name: Install Emacs if: ${{ github.event.inputs.debug == 'true' }} run: | sudo apt install emacs - name: Setup tmate session if: ${{ github.event.inputs.debug == 'true' }} uses: mxschmitt/action-tmate@35b54afac29c97fb54faba5b513f8fbd1882f113 timeout-minutes: 60 - name: Install uv uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 with: enable-cache: false - name: Setup Just uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 - name: Install Oracle Client # https://askubuntu.com/questions/1512196/libaio1-on-noble run: | sudo apt install alien libaio1t64 sudo ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1 if [[ "$TEST_DATABASE_VERSION" == oracle-xe* ]]; then curl --output oracle-client.rpm https://download.oracle.com/otn_software/linux/instantclient/2116000/oracle-instantclient-basiclite-21.16.0.0.0-1.el8.x86_64.rpm sudo alien -i oracle-client.rpm sudo sh -c "echo /usr/lib/oracle/21/client64/lib/ > /etc/ld.so.conf.d/oracle.conf" else curl --output oracle-client.rpm https://download.oracle.com/otn_software/linux/instantclient/2326000/oracle-instantclient-basiclite-23.26.0.0.0-1.el9.x86_64.rpm sudo alien -i oracle-client.rpm sudo sh -c "echo /usr/lib/oracle/23/client64/lib/ > /etc/ld.so.conf.d/oracle.conf" fi sudo ldconfig # we don't run integration tests against Oracle in CI, these are slow enough - name: Run Full Unit Tests env: TEST_PYTHON: ${{ steps.sp.outputs.python-path }} run: | if [[ "$TEST_DATABASE_VERSION" == oracle-xe* ]]; then just test-all --group cx_oracle -p "$TEST_PYTHON" --group "$TEST_DJANGO_VERSION" else just test-all --group oracledb -p "$TEST_PYTHON" --group "$TEST_DJANGO_VERSION" fi - name: Store coverage files uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: name: ${{ env.COVERAGE_FILE }} path: ${{ env.COVERAGE_FILE }} windows: runs-on: windows-latest permissions: contents: read env: RDBMS: sqlite COVERAGE_FILE: windows-py${{ matrix.python-version }}-${{ matrix.django-version }}-sqlite.coverage TEST_PYTHON_VERSION: ${{ matrix.python-version }} TEST_DJANGO_VERSION: ${{ matrix.django-version }} TEST_DATABASE_VERSION: "sqlite" strategy: fail-fast: false matrix: python-version: ["3.10", "3.12", "3.14"] django-version: - "dj42" # LTS April 2026 - "dj52" # LTS April 2028 - "dj61" # exclude: - python-version: "3.10" django-version: "dj52" - python-version: "3.10" django-version: "dj61" - python-version: "3.12" django-version: "dj42" - python-version: "3.12" django-version: "dj61" - python-version: "3.14" django-version: "dj42" - python-version: "3.14" django-version: "dj52" steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 id: sp with: python-version: ${{ matrix.python-version }} allow-prereleases: true - name: Install uv uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 with: enable-cache: false - name: Setup Just uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 - name: install-vim-windows if: ${{ github.event.inputs.debug == 'true' }} uses: rhysd/action-setup-vim@febef33995d6649302e9d88dda81e071b68f16a7 - name: Setup tmate session if: ${{ github.event.inputs.debug == 'true' }} uses: mxschmitt/action-tmate@35b54afac29c97fb54faba5b513f8fbd1882f113 timeout-minutes: 60 - name: Run Unit Tests env: TEST_PYTHON: ${{ steps.sp.outputs.python-path }} run: | just test-all -p "$env:TEST_PYTHON" --group "$env:TEST_DJANGO_VERSION" shell: pwsh - name: Store coverage files uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: name: ${{ env.COVERAGE_FILE }} path: ${{ env.COVERAGE_FILE }} macos: runs-on: macos-latest permissions: contents: read env: RDBMS: sqlite COVERAGE_FILE: macos-py${{ matrix.python-version }}-${{ matrix.django-version }}-sqlite.coverage TEST_PYTHON_VERSION: ${{ matrix.python-version }} TEST_DJANGO_VERSION: ${{ matrix.django-version }} TEST_DATABASE_VERSION: "sqlite" strategy: fail-fast: false matrix: python-version: ["3.10", "3.12", "3.14"] django-version: - "dj42" # LTS April 2024 - "dj52" # LTS April 2028 - "dj61" # exclude: - python-version: "3.10" django-version: "dj52" - python-version: "3.10" django-version: "dj61" - python-version: "3.12" django-version: "dj42" - python-version: "3.12" django-version: "dj61" - python-version: "3.14" django-version: "dj42" - python-version: "3.14" django-version: "dj52" steps: - name: Clear Tool cache if: ${{ github.event.inputs.clear_cache == 'true' }} run: sudo rm -rf /opt/hostedtoolcache - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 id: sp with: python-version: ${{ matrix.python-version }} allow-prereleases: true - name: Install uv uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 with: enable-cache: false - name: Setup Just uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 - name: install-emacs-macos if: ${{ github.event.inputs.debug == 'true' }} run: | brew install emacs - name: Setup tmate session if: ${{ github.event.inputs.debug == 'true' }} uses: mxschmitt/action-tmate@35b54afac29c97fb54faba5b513f8fbd1882f113 timeout-minutes: 60 - name: Run Unit Tests env: TEST_PYTHON: ${{ steps.sp.outputs.python-path }} run: | just test-all -p "$TEST_PYTHON" --group "$TEST_DJANGO_VERSION" - name: Store coverage files uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: name: ${{ env.COVERAGE_FILE }} path: ${{ env.COVERAGE_FILE }} coverage-combine: needs: [postgres, sqlite, mysql, mariadb, oracle, windows, macos] runs-on: ubuntu-latest permissions: contents: read id-token: write # for codecov oidc authentication steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 id: sp with: python-version: "3.12" - name: Install uv uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 with: enable-cache: false - name: Setup Just uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 - name: Get coverage files uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c with: pattern: "*.coverage" merge-multiple: true - run: ls -la *.coverage - run: just coverage - name: Upload coverage to Codecov uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f with: use_oidc: true files: ./coverage.xml