name: Tests permissions: contents: read on: push: branches: - main pull_request: env: # Used in our tox configuration to determine which dependency groups to install DEPENDENCY_GROUP: ci jobs: pre-commit: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v7.0.1 - name: Install uv uses: astral-sh/setup-uv@v10.0.1 with: enable-cache: true - name: Install Python uses: actions/setup-python@v7.0.0 with: python-version: '3.13' - name: Install pre-commit run: uv tool install pre-commit - name: Run pre-commit hooks run: pre-commit run --all-files tests: runs-on: ubuntu-24.04 needs: pre-commit strategy: fail-fast: false matrix: python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] database-engine: [sqlite, mariadb, postgres] services: mariadb: image: mariadb:11.4.2 env: MYSQL_ROOT_PASSWORD: mariadb ports: - 3306:3306 postgres: image: postgres:16-alpine env: PGUSER: postgres POSTGRES_PASSWORD: postgres options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 env: DJANGO_SETTINGS_MODULE: tests.server.settings DATABASE_ENGINE: ${{ matrix.database-engine }} steps: - name: Checkout code uses: actions/checkout@v7.0.1 - name: Install uv uses: astral-sh/setup-uv@v10.0.1 with: enable-cache: true cache-dependency-glob: pyproject.toml - name: Install tox # See: https://github.com/tox-dev/tox-gh run: uv tool install --python-preference only-managed --python 3.13 tox --with . --with tox-uv --with tox-gh - name: Install Python # Skip if the python version is already installed to run tox if: matrix.python-version != '3.13' run: uv python install --python-preference only-managed ${{ matrix.python-version }} - name: Setup test suite run: tox run -vv --notest --skip-missing-interpreters false env: TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }} - name: Create databases run: | PGPASSWORD="postgres" psql -c 'create database django_guardian;' -h localhost -U postgres; PGPASSWORD="postgres" psql -c 'create database test_django_guardian;' -h localhost -U postgres; mysql --host=127.0.0.1 --user=root --password=mariadb -e 'CREATE DATABASE django_guardian;'; mysql --host=127.0.0.1 --user=root --password=mariadb -e 'CREATE DATABASE test_django_guardian;'; - name: Test with PostgreSQL if: matrix.database-engine == 'postgres' env: TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }} DATABASE_URL: postgres://postgres:postgres@localhost/django_guardian PYTEST_ADDOPTS: -vv --durations=20 DIFF_AGAINST: HEAD UV_PYTHON_PREFERENCE: only-managed run: tox run -vv --skip-pkg-install - name: Test with MariaDB if: matrix.database-engine == 'mariadb' env: TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }} DATABASE_URL: mysql://root:mariadb@127.0.0.1:3306/django_guardian PYTEST_ADDOPTS: -vv --durations=20 DIFF_AGAINST: HEAD UV_PYTHON_PREFERENCE: only-managed run: tox run -vv --skip-pkg-install - name: Test with SQLite if: matrix.database-engine == 'sqlite' env: TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }} DATABASE_URL: sqlite:// PYTEST_ADDOPTS: -vv --durations=20 DIFF_AGAINST: HEAD UV_PYTHON_PREFERENCE: only-managed run: tox run -vv --skip-pkg-install