Skip to content

Refactor: Share spatial bind conversion helpers across dialects #948

Refactor: Share spatial bind conversion helpers across dialects

Refactor: Share spatial bind conversion helpers across dialects #948

name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch.
on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
workflow_dispatch:
schedule:
- cron: 0 5 1 * *
env:
PGPASSWORD: gis
jobs:
# This workflow runs the tests
tests:
# Set shell to work properly with Mamba
defaults:
run:
shell: bash -l {0}
# Setup test matrix
strategy:
fail-fast: false
matrix:
# Update the carryforward value in "Coveralls Finished" when updating
# this table.
python-version: [
{"pkg_name": "python==3.10.*", "flag": "3.10"},
{"pkg_name": "python==3.11.*", "flag": "3.11"},
{"pkg_name": "python==3.12.*", "flag": "3.12"},
{"pkg_name": "python==3.13.*", "flag": "3.13"},
{"pkg_name": "pypy3.11", "flag": "pypy3.11"},
]
# The type of runner that the job will run on
runs-on: ubuntu-24.04
services:
postgres:
image: postgis/postgis:18-3.6
env:
POSTGRES_DB: gis
POSTGRES_PASSWORD: gis
POSTGRES_USER: gis
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd "pg_isready -U gis -d gis"
--health-interval 5s
--health-timeout 5s
--health-retries 20
--health-start-period 5s
mysql:
image: mysql:9.6.0
ports:
- 3307:3306
env:
MYSQL_ROOT_PASSWORD: gis
# Set health checks to wait until MySQL has started
options: >-
--health-cmd "mysqladmin ping -h localhost -uroot -pgis --silent"
--health-interval 5s
--health-timeout 5s
--health-retries 20
--health-start-period 10s
mariadb:
image: mariadb:12.2.2
ports:
- 3308:3306
env:
MARIADB_ROOT_PASSWORD: gis
# Set health checks to wait until MariaDB has started
options: >-
--health-cmd "mariadb-admin ping -h localhost -uroot -pgis --silent"
--health-interval 5s
--health-timeout 5s
--health-retries 20
--health-start-period 10s
mssql:
image: mcr.microsoft.com/mssql/server:2022-CU24-ubuntu-22.04
ports:
- 1433:1433
env:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: "GeoAlchemy2!Sql2025"
# Set health checks to wait until MSSQL has started.
options: >-
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'GeoAlchemy2!Sql2025' -C -b -Q 'SELECT 1'"
--health-interval 5s
--health-timeout 5s
--health-retries 30
--health-start-period 10s
cockroachdb:
image: cockroachdb/cockroach:latest-v25.3
command: start-single-node --insecure --http-addr=0.0.0.0:8080
ports:
- 26257:26257
- 8080:8080
# Set health checks to wait until CockroachDB has started
options: >-
--health-cmd "cockroach sql --insecure --host=localhost:26257 --execute='SELECT 1'"
--health-interval 5s
--health-timeout 5s
--health-retries 30
--health-start-period 10s
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v6
# Setup Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version.flag }}
# Install SpatiaLite
- name: Install SpatiaLite
run: |
sudo apt-get update
sudo apt-get install -y libsqlite3-mod-spatialite libgdal-dev gdal-bin rasterio
# Install MSSQL tools and drivers
- name: Install MSSQL tools and drivers
run: |
curl -sSL -O https://packages.microsoft.com/config/ubuntu/$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2)/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update
sudo env ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev
echo "/opt/mssql-tools18/bin" >> "$GITHUB_PATH"
# Config PostgreSQL
- name: Configure PostgreSQL
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_USER: gis
POSTGRES_PASSWORD: gis
POSTGRES_DB: gis
run: |
./test_container/helpers/configure_postgres.sh
psql -h localhost -p 5432 -U gis -d gis -c 'SELECT postgis_version();'
# Configure MySQL
- name: Configure MySQL
env:
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3307
MYSQL_ROOT_PASSWORD: gis
run: |
./test_container/helpers/configure_mysql.sh
mysql --user=gis --password=gis --host=127.0.0.1 -P 3307 -e "SELECT VERSION();"
# Configure MariaDB
- name: Configure MariaDB
env:
MARIADB_HOST: 127.0.0.1
MARIADB_PORT: 3308
MARIADB_ROOT_PASSWORD: gis
run: |
./test_container/helpers/configure_mariadb.sh
mysql --user=gis --password=gis --host=127.0.0.1 -P 3308 -e "SELECT VERSION();"
# Configure MSSQL
- name: Configure MSSQL
env:
MSSQL_HOST: localhost,1433
MSSQL_SA_PASSWORD: "GeoAlchemy2!Sql2025"
MSSQL_TEST_DB: gis
MSSQL_TEST_LOGIN: gis
MSSQL_TEST_PASSWORD: gis
run: |
./test_container/helpers/init_mssql.sh
# Configure CockroachDB
- name: Configure CockroachDB
env:
COCKROACH_HOST: 127.0.0.1
COCKROACH_PORT: 26257
COCKROACH_DATABASE: gis
COCKROACH_USER: gis
run: |
./test_container/helpers/configure_cockroach.sh
psql "postgresql://gis@127.0.0.1:26257/gis?sslmode=disable" -v ON_ERROR_STOP=1 -c "SELECT version();"
# Check python version
- name: Display Python version
run: |
/home/runner/micromamba-bin/micromamba info
/home/runner/micromamba-bin/micromamba list
python -c "import sys; print(sys.version)"
# Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install tox-gh-actions
# Run the test suite
- name: Run the tests
env:
SPATIALITE_LIBRARY_PATH: /usr/lib/x86_64-linux-gnu/mod_spatialite.so
COVERAGE_FILE: .coverage
PYTEST_MYSQL_DB_URL: mysql://gis:gis@127.0.0.1:3307/gis
PYTEST_MARIADB_DB_URL: mariadb://gis:gis@127.0.0.1:3308/gis
PYTEST_MSSQL_DB_URL: mssql+pyodbc://gis:gis@localhost:1433/gis?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes
PYTEST_COCKROACHDB_DB_URL: cockroachdb://gis@127.0.0.1:26257/gis?sslmode=disable
run: |
if [[ ${{ matrix.python-version.flag }} == 'pypy3.11' ]]; then
export PYTEST_SPATIALITE3_DB_URL="FAILING URL"
export PYTEST_SPATIALITE4_DB_URL="FAILING URL"
export PYTEST_GEOPACKAGE_DB_URL="FAILING URL"
else
export PYTEST_ADDOPTS='--require-all-dialects'
fi;
# Run the unit test suite with SQLAlchemy=1.4.* and then with the latest version of SQLAlchemy
tox -vv
# Export coverage to Coveralls
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
format: cobertura
files: reports/coverage-*.xml
parallel: true
fail-on-error: false
flag-name: run-${{ matrix.python-version.flag }}
# This workflow aggregates coverages from all jobs and export it to Coveralls
coveralls:
needs: tests
if: ${{ always() }}
runs-on: ubuntu-22.04
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
fail-on-error: false
parallel-finished: true
carryforward: "run-3.10,run-3.11,run-3.12,run-3.13,run-pypy3.11"
# This workflow deploys the package
deploy:
needs: tests
runs-on: ubuntu-22.04
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.10
uses: actions/setup-python@v6
with:
python-version: "3.10"
# Build distribution and deploy to Pypi
- name: Build and deploy package
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
pip install --upgrade pip setuptools build twine
python -m build -o dist
twine upload dist/*