branches:
- "master"
- "sqlalchemy_pipeline"
+ - "django_pipeline"
paths-ignore:
- "docs/*"
- "tools/*"
URL: postgresql+psycopg://postgres:password@127.0.0.1/test
working-directory: sa_home/sa
run: pytest -n 2 -q --dburi $URL --backend-only --dropfirst --color=yes
+
+ django:
+ # linux should be enough to test if everything works.
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ django_label:
+ # what version of django to download is defined in the "include" section below,
+ # in the variable pip_django
+ - git_main
+ - lts
+ impl:
+ - c
+ - python
+ include:
+ - django_label: git_main
+ pip_django: git+https://github.com/django/django.git#egg=Django
+ python-version: "3.11"
+ # TODO: Needs updating with new LTS releases, is this something we want?
+ # Also needs consideration against which python we wanna test.
+ # Current logic is test oldest in lts and newest in main
+ - django_label: lts
+ pip_django: "'Django>=4.2,<4.3'"
+ python-version: "3.8"
+
+ env:
+ DEPS: ./psycopg
+
+ services:
+ postgresql:
+ image: postgres:15
+ env:
+ POSTGRES_PASSWORD: password
+ POSTGRES_DB: postgres
+ ports:
+ - 5432:5432
+ # Wait until postgres has started
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: actions/setup-python@v4
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ - name: Setup PG
+ env:
+ PGPASSWORD: password
+ run: |
+ psql -AXqte "host=127.0.0.1 dbname=postgres user=postgres" << HERE
+ SELECT version();
+ HERE
+
+ - name: Include psycopg-c to the packages to install
+ if: ${{ matrix.impl == 'c' }}
+ run: |
+ echo "DEPS=$DEPS ./psycopg_c" >> $GITHUB_ENV
+
+ - name: Install pycopg packages
+ run: pip install $DEPS
+
+ - name: Download and configure Django
+ run: |
+ pip download --no-deps --no-binary :all: ${{ matrix.pip_django }}
+ mkdir django_home
+ case $(file --brief --mime-type Django*) in
+ application/gzip)
+ tar -C django_home -xzf Django*
+ ;;
+ application/zip)
+ unzip -d django_home -q Django*
+ ;;
+ *)
+ echo "Unexpected format for $(file --mime-type Django*)" >&2
+ exit 1
+ ;;
+ esac
+ mv django_home/$( ls django_home ) django_home/django
+ cat << HERE > django_home/django/tests/test_postgresql.py
+ DATABASES = {
+ "default": {
+ "ENGINE": "django.db.backends.postgresql",
+ "HOST": "127.0.0.1",
+ "USER": "postgres",
+ "PASSWORD": "password",
+ },
+ "other": {
+ "ENGINE": "django.db.backends.postgresql",
+ "HOST": "127.0.0.1",
+ "USER": "postgres",
+ "PASSWORD": "password",
+ },
+ }
+
+ SECRET_KEY = "django_tests_secret_key"
+
+ # Use a fast hasher to speed up tests.
+ PASSWORD_HASHERS = [
+ "django.contrib.auth.hashers.MD5PasswordHasher",
+ ]
+
+ DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
+
+ USE_TZ = False
+ HERE
+
+ - uses: actions/cache@v3
+ with:
+ path: ~/.cache/pip
+ key: ${{ matrix.python-version }}-pip-${{ hashFiles('django_home/django/tests/requirements/py3.txt', 'django_home/django/setup.cfg') }}
+ restore-keys: |
+ ${{ matrix.python-version }}-pip-
+
+ - name: Install Django and dependencies
+ working-directory: django_home/django
+ run: |
+ pip install .
+ pip install -r tests/requirements/py3.txt
+
+ - name: Run Django tests
+ working-directory: django_home/django/tests
+ run: ./runtests.py --settings=test_postgresql postgres_tests backends queries