Skip to content

Commit

Permalink
Merge pull request #643 from geopython/tox_modernisation
Browse files Browse the repository at this point in the history
Modernize CI using Tox, add a "[dev]" recipe, re-enable coveralls
  • Loading branch information
Zeitsperre authored Dec 22, 2021
2 parents f7f00ec + 8f2fcca commit 7f228ff
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 95 deletions.
62 changes: 38 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
name: build ⚙️

on: [ push, pull_request ]
on:
push:
branches:
- main
pull_request:

jobs:
main:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: github
include:
- tox-env: py37-extra
python-version: 3.7
- tox-env: py38-extra
python-version: 3.8
- tox-env: py39-extra
python-version: 3.9
steps:
- uses: actions/checkout@v2
- name: Install packages
- name: Install packages 📦
run: |
sudo apt-get update && sudo apt-get -y install libnetcdf-dev libhdf5-dev
sudo apt-get update
sudo apt-get -y install libnetcdf-dev libhdf5-dev
- uses: actions/setup-python@v2
name: Setup Python ${{ matrix.python-version }}
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements 📦
- name: Run flake8 ⚙️
run: |
pip3 install pip --upgrade
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt
pip3 install -r requirements-extra.txt
- name: run tests ⚙️
run: pytest -v tests
- name: run coveralls ⚙️
run: coveralls
pip install flake8
flake8 pywps
if: matrix.python-version == 3.7
- name: build docs 🏗️
run: |
pip3 install -e .
cd docs && make html
if: matrix.python-version == 3.7
- name: run flake8 ⚙️
run: flake8 pywps
- name: Install tox 📦
run: pip install tox
- name: Run tests with tox ⚙️
run: tox -e ${{ matrix.tox-env }}
- name: Run coveralls ⚙️
if: matrix.python-version == 3.7
uses: AndreMiras/coveralls-python-action@develop

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Setup Python 3.7
with:
python-version: 3.7
- name: Build docs 🏗️
run: |
pip install -e .[dev]
cd docs && make html
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2014-2016 PyWPS Development Team, represented by Jachym Cepicky
Copyright (C) 2014-2021 PyWPS Development Team, represented by Jachym Cepicky

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
coverage
coveralls
pytest
pytest-cov
flake8
pylint
Sphinx
Expand Down
16 changes: 11 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ parse = (?P<major>\d+)\.(?P<minor>\d+).(?P<patch>\d+)
serialize =
{major}.{minor}.{patch}

[flake8]
ignore = F401,E402,W606
max-line-length = 120
exclude = tests

[bumpversion:file:pywps/__init__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

[bumpversion:file:VERSION.txt]
search = {current_version}
replace = {new_version}

[coverage:run]
relative_files = True

[flake8]
ignore =
F401
E402
W606
max-line-length = 120
exclude = tests
91 changes: 51 additions & 40 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,68 @@

from setuptools import find_packages

with open('VERSION.txt') as ff:
with open("VERSION.txt") as ff:
VERSION = ff.read().strip()

DESCRIPTION = ('PyWPS is an implementation of the Web Processing Service '
'standard from the Open Geospatial Consortium. PyWPS is '
'written in Python.')
DESCRIPTION = (
"PyWPS is an implementation of the Web Processing Service "
"standard from the Open Geospatial Consortium. PyWPS is "
"written in Python."
)

with open('README.md') as ff:
with open("README.md") as ff:
LONG_DESCRIPTION = ff.read()

KEYWORDS = 'PyWPS WPS OGC processing'
KEYWORDS = "PyWPS WPS OGC processing"

with open('requirements.txt') as f:
INSTALL_REQUIRES = f.read().splitlines()
with open("requirements.txt") as fr:
INSTALL_REQUIRES = fr.read().splitlines()

with open("requirements-dev.txt") as frd:
DEV_REQUIRES = frd.read().splitlines()

CONFIG = {
'name': 'pywps',
'version': VERSION,
'description': DESCRIPTION,
'long_description': LONG_DESCRIPTION,
'long_description_content_type': 'text/markdown',
'keywords': KEYWORDS,
'license': 'MIT',
'platforms': 'all',
'author': 'Jachym Cepicky',
'author_email': 'jachym.cepicky@gmail.com',
'maintainer': 'Jachym Cepicky',
'maintainer_email': 'jachym.cepicky@gmail.com',
'url': 'https://pywps.org',
'download_url': 'https://github.com/geopython/pywps',
'classifiers': [
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
"name": "pywps",
"version": VERSION,
"description": DESCRIPTION,
"long_description": LONG_DESCRIPTION,
"long_description_content_type": "text/markdown",
"keywords": KEYWORDS,
"license": "MIT",
"platforms": "all",
"author": "Jachym Cepicky",
"author_email": "jachym.cepicky@gmail.com",
"maintainer": "Jachym Cepicky",
"maintainer_email": "jachym.cepicky@gmail.com",
"url": "https://pywps.org",
"download_url": "https://github.com/geopython/pywps",
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
'Topic :: Scientific/Engineering :: GIS'
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Scientific/Engineering :: GIS",
],
'install_requires': INSTALL_REQUIRES,
'python_requires': '>=3.6, <4',
'packages': find_packages(exclude=["docs", "tests.*", "tests"]),
'include_package_data': True,
'scripts': [],
'entry_points': {
'console_scripts': [
'joblauncher=pywps.processing.job:launcher', ]},
"install_requires": INSTALL_REQUIRES,
"extras_require": dict(
dev=DEV_REQUIRES,
),
"python_requires": ">=3.7,<4",
"packages": find_packages(exclude=["docs", "tests.*", "tests"]),
"include_package_data": True,
"scripts": [],
"entry_points": {
"console_scripts": [
"joblauncher=pywps.processing.job:launcher",
]
},
}

setup(**CONFIG)
12 changes: 7 additions & 5 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

import re

VERSION="1.0.0"
VERSION = "1.0.0"
WPS, OWS = get_ElementMakerForVersion(VERSION)
xpath_ns = get_xpath_ns(VERSION)


class ExceptionsTest(unittest.TestCase):

def setUp(self):
Expand All @@ -24,28 +25,29 @@ def test_invalid_parameter_value(self):
exception_el = resp.xpath('/ows:ExceptionReport/ows:Exception')[0]
assert exception_el.attrib['exceptionCode'] == 'InvalidParameterValue'
assert resp.status_code == 400
assert re.match('text/xml(;\s*charset=.*)?', resp.headers['Content-Type'])
assert re.match(r'text/xml(;\s*charset=.*)?', resp.headers['Content-Type'])
assert_pywps_version(resp)

def test_missing_parameter_value(self):
resp = self.client.get()
exception_el = resp.xpath('/ows:ExceptionReport/ows:Exception')[0]
assert exception_el.attrib['exceptionCode'] == 'MissingParameterValue'
assert resp.status_code == 400
assert re.match('text/xml(;\s*charset=.*)?', resp.headers['Content-Type'])
assert re.match(r'text/xml(;\s*charset=.*)?', resp.headers['Content-Type'])

def test_missing_request(self):
resp = self.client.get("?service=wps")
exception_el = resp.xpath('/ows:ExceptionReport/ows:Exception/ows:ExceptionText')[0]
# should mention something about a request
assert 'request' in exception_el.text
assert re.match('text/xml(;\s*charset=.*)?', resp.headers['Content-Type'])
assert re.match(r'text/xml(;\s*charset=.*)?', resp.headers['Content-Type'])

def test_bad_request(self):
resp = self.client.get("?service=wps&request=xyz")
exception_el = resp.xpath('/ows:ExceptionReport/ows:Exception')[0]
assert exception_el.attrib['exceptionCode'] == 'OperationNotSupported'
assert re.match('text/xml(;\s*charset=.*)?', resp.headers['Content-Type'])
assert re.match(r'text/xml(;\s*charset=.*)?', resp.headers['Content-Type'])


def load_tests(loader=None, tests=None, pattern=None):
if not loader:
Expand Down
38 changes: 18 additions & 20 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
[tox]
envlist=py36
envlist = py{37,38,39}{-extra,}
requires = pip >= 20.0
opts = --verbose

[testenv]

pip_pre=True
deps=
lxml
flask
owslib
simplejson
jsonschema
geojson
shapely
unipath
werkzeug
SQLAlchemy
jinja2

commands=
# check first which version is installed "gdal-config --version"
pip install GDAL==2.1.0 --global-option=build_ext --global-option="-I/usr/include/gdal"
python -m unittest tests
setenv =
PYTEST_ADDOPTS = "--color=yes"
PYTHONPATH = {toxinidir}
COV_CORE_SOURCE =
passenv = CI GITHUB_* LD_LIBRARY_PATH
download = True
install_command =
python -m pip install --no-user {opts} {packages}
extras = dev
deps =
extra: -rrequirements-extra.txt
commands =
; # magic for gathering the GDAL version within tox
; sh -c 'pip install GDAL=="$(gdal-config --version)" --global-option=build_ext --global-option="-I/usr/include/gdal"'
pytest --cov

0 comments on commit 7f228ff

Please sign in to comment.