spatial-d4science/.github/workflows/test.yml

103 lines
3.9 KiB
YAML
Raw Normal View History

2021-05-28 11:28:21 +02:00
name: Tests
2021-01-06 06:37:38 +01:00
on: [push, pull_request]
jobs:
2021-01-15 06:01:12 +01:00
lint:
2021-01-06 06:37:38 +01:00
runs-on: ubuntu-latest
2021-01-15 06:01:12 +01:00
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.6'
- name: Install requirements
run: pip install flake8 pycodestyle
- name: Check syntax
run: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics --exclude ckan
test:
needs: lint
strategy:
matrix:
2022-03-31 14:55:43 +02:00
ckan-version: [master, 2.9, 2.9-py2, 2.8, 2.7]
2021-01-15 06:01:12 +01:00
fail-fast: false
name: CKAN ${{ matrix.ckan-version }}
runs-on: ubuntu-latest
container:
image: openknowledge/ckan-dev:${{ matrix.ckan-version }}
2021-01-06 06:37:38 +01:00
services:
2021-01-15 06:01:12 +01:00
solr:
image: ckan/ckan-solr-dev:${{ matrix.ckan-version }}
postgres:
2021-01-18 16:47:18 +01:00
image: postgis/postgis:10-3.1
2021-01-06 06:37:38 +01:00
env:
2021-01-15 06:01:12 +01:00
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
2021-01-06 06:37:38 +01:00
image: redis:3
2021-01-15 06:01:12 +01:00
env:
CKAN_SQLALCHEMY_URL: postgresql://ckan_default:pass@postgres/ckan_test
CKAN_DATASTORE_WRITE_URL: postgresql://datastore_write:pass@postgres/datastore_test
CKAN_DATASTORE_READ_URL: postgresql://datastore_read:pass@postgres/datastore_test
CKAN_SOLR_URL: http://solr:8983/solr/ckan
CKAN_REDIS_URL: redis://redis:6379/1
PGPASSWORD: postgres
2021-01-06 06:37:38 +01:00
steps:
2021-01-15 06:01:12 +01:00
- uses: actions/checkout@v2
- name: Create Database
run: |
2021-01-15 07:48:48 +01:00
psql --host=postgres --username=postgres --command="CREATE USER ckan_default WITH PASSWORD 'pass' NOSUPERUSER NOCREATEDB NOCREATEROLE;"
createdb --encoding=utf-8 --host=postgres --username=postgres --owner=ckan_default ckan_test
2021-01-15 06:20:08 +01:00
psql --host=postgres --username=postgres --command="CREATE USER datastore_write WITH PASSWORD 'pass' NOSUPERUSER NOCREATEDB NOCREATEROLE;"
psql --host=postgres --username=postgres --command="CREATE USER datastore_read WITH PASSWORD 'pass' NOSUPERUSER NOCREATEDB NOCREATEROLE;"
createdb --encoding=utf-8 --host=postgres --username=postgres --owner=datastore_write datastore_test
2021-01-15 06:01:12 +01:00
- name: Install harvester
run: |
git clone https://github.com/ckan/ckanext-harvest
cd ckanext-harvest
pip install -r pip-requirements.txt
2021-01-15 06:33:28 +01:00
pip install -r dev-requirements.txt
pip install -e .
2021-01-15 07:21:55 +01:00
- name: Install dependency (common)
2021-01-15 06:44:45 +01:00
run: |
2021-01-15 07:09:23 +01:00
apk add --no-cache \
geos \
2021-01-15 07:42:29 +01:00
geos-dev \
2021-01-15 07:09:23 +01:00
proj-util \
2021-01-15 07:42:29 +01:00
proj-dev \
2021-01-15 07:09:23 +01:00
libxml2 \
2021-01-15 07:38:13 +01:00
libxslt \
2021-01-15 07:09:23 +01:00
gcc \
libxml2-dev \
libxslt-dev
2021-01-15 07:21:55 +01:00
- name: Install dependency (python2)
2022-04-22 14:07:32 +02:00
if: ${{ matrix.ckan-version == '2.9-py2' || matrix.ckan-version == '2.8' || matrix.ckan-version == '2.7' }}
2021-01-15 07:21:55 +01:00
run: |
2021-01-15 07:38:13 +01:00
apk add --no-cache \
2021-01-15 07:31:53 +01:00
python2-dev
pip install -r requirements-py2.txt
2021-01-15 07:21:55 +01:00
- name: Install dependency (python3)
2022-04-22 14:07:32 +02:00
if: ${{ matrix.ckan-version != '2.9-py2' && matrix.ckan-version != '2.8' && matrix.ckan-version != '2.7' }}
2021-01-15 07:21:55 +01:00
run: |
2021-01-15 07:38:13 +01:00
apk add --no-cache \
2021-01-15 07:21:55 +01:00
python3-dev
pip install -r requirements.txt
- name: Install requirements
run: |
2021-01-15 06:01:12 +01:00
pip install -e .
# Replace default path to CKAN core config file with the one on the container
sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini
2021-01-15 08:11:28 +01:00
- name: setup postgis
run: |
psql --host=postgres --username=postgres -d ckan_test --command="ALTER ROLE ckan_default WITH superuser;"
psql --host=postgres --username=postgres -d ckan_test --command="CREATE EXTENSION postgis;"
2021-01-15 06:01:12 +01:00
- name: Run tests
2021-05-28 11:28:21 +02:00
run: pytest --ckan-ini=test.ini --cov=ckanext.spatial --cov-report=xml --cov-append --disable-warnings ckanext/spatial/tests
- name: Upload coverage report to codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml