-
Notifications
You must be signed in to change notification settings - Fork 112
206 lines (175 loc) · 6.33 KB
/
test_and_publish.yml
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
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.8", "flag": "pypy3.8"},
]
# 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/*