Skip to content

CI: Fix Pypy job

CI: Fix Pypy job #696

name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch.
on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
workflow_dispatch:
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:
python-version: [
{"pkg_name": "python==3.7.*", "flag": "3.7"},
{"pkg_name": "python==3.8.*", "flag": "3.8"},
{"pkg_name": "python==3.9.*", "flag": "3.9"},
{"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": "pypy3.10", "flag": "pypy3.10"},
]
# The type of runner that the job will run on
runs-on: ubuntu-22.04
services:
postgres:
image: postgis/postgis:16-3.4
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
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:latest
ports:
- 3307:3306
env:
MYSQL_USER: gis
MYSQL_PASSWORD: gis
MYSQL_DATABASE: gis
MYSQL_ROOT_PASSWORD: gis
# Set health checks to wait until MySQL has started
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
mariadb:
image: mariadb:latest
ports:
- 3308:3306
env:
MARIADB_USER: gis
MARIADB_PASSWORD: gis
MARIADB_DATABASE: gis
MARIADB_ROOT_PASSWORD: gis
# Set health checks to wait until MariaDB has started
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Setup Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version.flag }}
# Install MariaDB
- name: Install MariaDB and SpatiaLite
run: |
sudo apt-get install -y mariadb-server mariadb-client libsqlite3-mod-spatialite libgdal-dev gdal-bin rasterio
# Config PostgreSQL
- name: Configure PostgreSQL
run: |
# Create schema "gis" into database "gis"
psql -h localhost -p 5432 -U gis -d gis -c 'CREATE SCHEMA gis;'
# Add PostGIS extension to "gis" database
psql -h localhost -p 5432 -U gis -d gis -c 'CREATE EXTENSION IF NOT EXISTS postgis SCHEMA public;'
# Drop PostGIS Tiger Geocoder extension to "gis" database
psql -h localhost -p 5432 -U gis -d gis -c 'DROP EXTENSION IF EXISTS postgis_tiger_geocoder CASCADE;'
# Add PostGISRaster extension to "gis" database
psql -h localhost -p 5432 -U gis -d gis -c 'CREATE EXTENSION IF NOT EXISTS postgis_raster SCHEMA public;'
# Drop PostGIS Topology extension to "gis" database
psql -h localhost -p 5432 -U gis -d gis -c 'DROP EXTENSION IF EXISTS postgis_topology;'
# Check MySQL
- name: Check MySQL
run: |
mysql --user=gis --password=gis --host=127.0.0.1 -P 3307 -e "SELECT VERSION();"
mysql --user=root --password=gis --host=127.0.0.1 -P 3307 -e "GRANT ALL PRIVILEGES ON *.* TO 'gis'@'%' WITH GRANT OPTION;"
# Check MariaDB
- name: Check MariaDB
run: |
mysql --user=gis --password=gis --host=127.0.0.1 -P 3308 -e "SELECT VERSION();"
mysql --user=root --password=gis --host=127.0.0.1 -P 3308 -e "GRANT ALL PRIVILEGES ON *.* TO 'gis'@'%' WITH GRANT OPTION;"
# 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:[email protected]:3307/gis
PYTEST_MARIADB_DB_URL: mariadb://gis:[email protected]:3308/gis
run: |
export PYTEST_ADDOPTS='--require-all-dialects'
if [[ ${{ matrix.python-version.flag }} == 'pypy3.8' ]]; then
export PYTEST_ADDOPTS=${PYTEST_ADDOPTS}' --ignore=tests/gallery/test_insert_raster.py'
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
uses: AndreMiras/coveralls-python-action@v20201129
with:
parallel: true
flag-name: run-${{ matrix.python-version.flag }}
# This workflow aggregates coverages from all jobs and export it to Coveralls
coveralls:
needs: tests
runs-on: ubuntu-22.04
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@v20201129
with:
parallel-finished: true
github-token: ${{ secrets.github_token }}
# 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@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
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/*