summaryrefslogtreecommitdiff
path: root/.github/workflows/postgis.yml
blob: 3ef5c05bddeecee303896dee3da2351b8e23638b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: GeoDjango Tests

on:
  pull_request:
    types: [labeled, synchronize, opened, reopened]
    paths-ignore:
      - 'docs/**'

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
   contents: read

jobs:
  postgis:
    if: contains(github.event.pull_request.labels.*.name, 'geodjango')
    runs-on: ubuntu-latest
    defaults:
      run:
        # Use Conda shell in all steps. See https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell
        shell: bash -el {0}
    strategy:
      fail-fast: false
      matrix:
        include:
          - conda-environment-file: ".github/workflows/data/conda/geolibs-pg17-gil.yml"
            pg_major: "17"
            python: "3.14"
          - conda-environment-file: ".github/workflows/data/conda/geolibs-pg17-freethreading.yml"
            pg_major: "17"
            python: "3.14t"
          - conda-environment-file: ".github/workflows/data/conda/geolibs-pg18-gil.yml"
            pg_major: "18"
            python: "3.14"
          - conda-environment-file: ".github/workflows/data/conda/geolibs-pg18-freethreading.yml"
            pg_major: "18"
            python: "3.14t"
    name: PostgreSQL ${{ matrix.pg_major }}, Python ${{ matrix.python }}
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Install system packages
        run: |
          sudo apt update
          xargs -a .github/workflows/data/apt-packages.txt sudo apt install -y --no-install-recommends
      - name: Setup Miniforge
        # Pinned to v4.0.1
        uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5
        with:
          activate-environment: geodjango
          environment-file: ${{ matrix.conda-environment-file }}
          channel-priority: strict
      - name: Create PostgreSQL settings file
        run: mv ./.github/workflows/data/test_postgis.py.tpl ./tests/test_postgis.py
      - name: Initialize and start local PostgreSQL
        env:
          PGPASSWORD: postgres
        run: |
          initdb -D "$GITHUB_WORKSPACE/.tmp/pgdata" --username="user" --auth=scram-sha-256 --pwfile=<(echo "$PGPASSWORD")
          pg_ctl -D "$GITHUB_WORKSPACE/.tmp/pgdata" -w start
          psql -U user -d postgres -c "CREATE EXTENSION IF NOT EXISTS postgis;"
          psql -U user -d postgres -c "SELECT PostGIS_full_version();"
      - name: Show GIL status
        run: python -c "import sys; print('GIL enabled:', sys._is_gil_enabled())"
      - name: Print geospatial versions
        run: |
          python -c "from django.contrib.gis import gdal, geos; print(f'GDAL: {gdal.gdal_version()}'); print(f'GEOS: {geos.geos_version()}')"
      - name: Run PostGIS tests
        run: python -Wall tests/runtests.py -v2 --settings=test_postgis