Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CKAN 2.11 support #331

Merged
merged 18 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 17 additions & 46 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install requirements
Expand All @@ -20,18 +20,24 @@ jobs:
strategy:
matrix:
include:
- ckan-version: "2.11"
ckan-image: "ckan/ckan-dev:2.11-py3.10"
solr-image: "2.10-solr9-spatial"
harvester-version: 'master'
- ckan-version: "2.10"
ckan-image: "ckan/ckan-dev:2.10-py3.10"
solr-image: "2.10-solr9-spatial"
harvester-version: 'master'
- ckan-version: 2.9
ckan-image: "amercader/ckan-dev:2.9-py3.9"
solr-image: 2.9-solr9-spatial
harvester-version: 'master'
fail-fast: false

name: CKAN ${{ matrix.ckan-version }}, Solr ${{ matrix.solr-image }}
runs-on: ubuntu-latest
container:
image: openknowledge/ckan-dev:${{ matrix.ckan-version }}
image: ${{ matrix.ckan-image }}
services:
solr:
image: ckan/ckan-solr:${{ matrix.solr-image }}
Expand All @@ -53,51 +59,22 @@ jobs:
PGPASSWORD: postgres

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install dependencies (common)
run: |
apk add --no-cache \
geos \
geos-dev \
proj-util \
proj-dev \
libxml2 \
libxslt \
gcc \
DEBIAN_FRONTEND=noninteractive apt-get --assume-yes --quiet install \
python3-dev \
libxml2-dev \
libxslt-dev

- name: Enable pip cache
run: |
echo "PIP version: $(pip --version)"
mkdir -p ~/.cache/pip
pip install -U pip --cache-dir ~/.cache/pip
chown -R $(whoami) ~/.cache/pip

- uses: actions/cache@v3
id: cache
with:
path: |
~/.cache/pip
/usr/lib/python*/site-packages
key: ${{ runner.os }}-spatial-ckan-${{ matrix.ckan-version }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-spatial-ckan-${{ matrix.ckan-version }}-${{ hashFiles('requirements.txt') }}

- name: Patch to test pyproj
if: ${{ matrix.ckan-version == '2.9' }}
run: |
pip install cython==0.29.36
pip install --no-use-pep517 pyproj==2.6.1
libxslt1-dev \
libgeos-c1v5

- name: Install dependencies from requirements.txt
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install -r requirements.txt
pip install pytest-ckan

- name: Install harvester
if: steps.cache.outputs.cache-hit != 'true'
run: |
echo "Installing harvester"
git clone --depth 1 --branch ${{ matrix.harvester-version }} https://github.com/ckan/ckanext-harvest
Expand All @@ -112,7 +89,6 @@ jobs:
pip install -e .

- name: Install requirements
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -e .

- name: Replace default path to CKAN
Expand All @@ -121,9 +97,4 @@ jobs:
sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini

- name: Run tests
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@v3
with:
file: ./coverage.xml
run: pytest --ckan-ini=test.ini --cov=ckanext.spatial --cov-report term-missing --cov-append --disable-warnings ckanext/spatial/tests
4 changes: 2 additions & 2 deletions ckanext/spatial/harvested_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ def get_value(self, element):
for child in self.elements:
value[child.name] = child.read_value(element)
return value
elif type(element) == etree._ElementStringResult:
elif hasattr(etree, "_ElementStringResult") and type(element) is etree._ElementStringResult:
value = str(element)
elif type(element) == etree._ElementUnicodeResult:
elif type(element) is etree._ElementUnicodeResult:
value = str(element)
else:
value = self.element_tostring(element)
Expand Down
12 changes: 11 additions & 1 deletion ckanext/spatial/plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,17 @@ def _get_search_backend(self):

def update_config(self, config):

self._get_search_backend()
search_backend = self._get_search_backend()

qp = None
if search_backend == "solr-bbox":
qp = "frange"
elif search_backend == "solr-spatial-field":
qp = "field"
if qp:
if not config.get("ckan.search.solr_allowed_query_parsers"):
config["ckan.search.solr_allowed_query_parsers"] = []
config["ckan.search.solr_allowed_query_parsers"].append(qp)

# IPackageController

Expand Down
10 changes: 0 additions & 10 deletions ckanext/spatial/tests/conftest.py

This file was deleted.

152 changes: 0 additions & 152 deletions ckanext/spatial/tests/fixtures.py

This file was deleted.

Loading