Skip to content

Commit

Permalink
Merge pull request #39 from GSA/ckan-210
Browse files Browse the repository at this point in the history
CKAN 2.10
  • Loading branch information
nickumia-reisys authored Jul 12, 2023
2 parents 332b06d + d8c5d91 commit 5dfabe0
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 100 deletions.
68 changes: 0 additions & 68 deletions .env

This file was deleted.

7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
ARG CKAN_VERSION=2.9
ARG CKAN_VERSION=2.10
FROM openknowledge/ckan-dev:${CKAN_VERSION}
ARG CKAN_VERSION

RUN pip install --upgrade pip

COPY . /app
WORKDIR /app
COPY . $APP_DIR/

# python cryptography takes a while to build
RUN pip install -r requirements.txt -r dev-requirements.txt -e .

WORKDIR ${APP_DIR}
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
CKAN_VERSION ?= 2.9
CKAN_VERSION ?= 2.10
COMPOSE_FILE ?= docker-compose.yml

build: ## Build the docker containers
CKAN_VERSION=$(CKAN_VERSION) docker-compose -f $(COMPOSE_FILE) build

lint: ## Lint the code
CKAN_VERSION=2.9 docker-compose -f docker-compose.yml run --rm app flake8 /app --count --show-source --statistics --exclude ckan --max-line-length=127
CKAN_VERSION=$(CKAN_VERSION) docker-compose -f docker-compose.yml run --rm app flake8 /app --count --show-source --statistics --exclude ckan --max-line-length=127

clean: ## Clean workspace and containers
find . -name *.pyc -delete
CKAN_VERSION=$(CKAN_VERSION) docker-compose -f $(COMPOSE_FILE) down -v --remove-orphan
CKAN_VERSION=$(CKAN_VERSION) SERVICES_VERSION=$(CKAN_VERSION) docker-compose -f $(COMPOSE_FILE) down -v --remove-orphan

test: ## Run tests in a new container
CKAN_VERSION=$(CKAN_VERSION) docker-compose -f $(COMPOSE_FILE) run --rm app /app/test.sh
CKAN_VERSION=$(CKAN_VERSION) SERVICES_VERSION=$(CKAN_VERSION) docker-compose -f $(COMPOSE_FILE) run --rm app /srv/app/test.sh

up: ## Start the containers
CKAN_VERSION=$(CKAN_VERSION) docker-compose -f $(COMPOSE_FILE) up
CKAN_VERSION=$(CKAN_VERSION) SERVICES_VERSION=$(CKAN_VERSION) docker-compose -f $(COMPOSE_FILE) up


.DEFAULT_GOAL := help
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Package | Notes
CKAN version | Compatibility
------------ | -------------
<=2.8 | no
2.9 | yes
2.9 | 0.0.5 (last supported)
2.10 | >=0.1.0

To install ckanext-datagovcatalog:

Expand Down Expand Up @@ -123,7 +124,7 @@ In order to support multiple versions of CKAN, or even upgrade to new versions
of CKAN, we support development and testing through the `CKAN_VERSION`
environment variable.

$ make CKAN_VERSION=2.9 test
$ make CKAN_VERSION=2.10 test

# Registering ckanext-datagovcatalog on PyPI

Expand Down
10 changes: 7 additions & 3 deletions ckanext/datagovcatalog/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_actions(self):

# IPackageController

def before_view(self, pkg_dict):
def before_dataset_view(self, pkg_dict):

# Add tracking information just for datasets
if pkg_dict.get("type", "dataset") == "dataset":
Expand All @@ -64,13 +64,13 @@ def before_view(self, pkg_dict):
def create_package_schema(self):
# let's grab the default schema from CKAN
schema = logic.schema.default_create_package_schema()
schema["tags"].update({"name": [not_empty, str]})
schema["tags"].update({"name": [not_empty, string]})
return schema

def update_package_schema(self):
# let's grab the default schema from CKAN
schema = logic.schema.default_update_package_schema()
schema["tags"].update({"name": [not_empty, str]})
schema["tags"].update({"name": [not_empty, string]})
log.error("Trying to update package schema %s" % schema["tags"])
return schema

Expand All @@ -81,3 +81,7 @@ def package_types(self):
# This plugin doesn't handle any special package types, it just
# customizes tag validation (see above)
return []


def string(value):
return str(value)
2 changes: 1 addition & 1 deletion ckanext/datagovcatalog/tests/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_create_harvest_source_with_no_org(self):
new_rec_action = toolkit.get_action("harvest_get_notifications_recipients")
new_recipients = new_rec_action(context, {'source_id': source_id})

assert {'name': u'default', 'email': None} in new_recipients
assert new_recipients == []

def _create_harvest_source_with_no_org(self):
site_user = toolkit.get_action('get_site_user')(
Expand Down
29 changes: 19 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,40 @@ services:
context: .
args:
CKAN_VERSION: ${CKAN_VERSION}
env_file:
- .env
environment:
CKAN__PLUGINS: envvars harvest ckan_harvester datagovcatalog
CKAN_SQLALCHEMY_URL: postgresql://ckan_default:pass@db/ckan_test
CKAN_DATASTORE_WRITE_URL: postgresql://datastore_write:pass@db/datastore_test
CKAN_DATASTORE_READ_URL: postgresql://datastore_read:pass@db/datastore_test
CKAN_SOLR_URL: http://solr:8983/solr/ckan
CKAN_REDIS_URL: redis://redis:6379/
CKAN_DATAPUSHER_URL: http://localhost:8080/ # datapusher is not really enabled
CKAN_SITE_ID: default
CKAN_SITE_URL: http://ckan:5000
CKAN_SYSADMIN_NAME: admin
CKAN_SYSADMIN_PASSWORD: password
CKAN_SYSADMIN_EMAIL: your_email@example.com
CKAN__STORAGE_PATH: /var/lib/ckan
PYTHONDONTWRITEBYTECODE: 1
ports:
- "5000:5000"
depends_on:
- db
- redis
- solr
volumes:
- ckan_storage:/var/lib/ckan
- ./config:/etc/ckan
- .:/app
- ./ckanext:/srv/app/ckanext
- ./test.sh:/srv/app/test.sh
- ./test.ini:/srv/app/test.ini

- ./setup.py:/srv/app/setup.py
- /etc/timezone:/etc/timezone:ro
- ./docker-entrypoint.d/:/docker-entrypoint.d/
db:
image: ckan/ckan-postgres-dev:${SERVICES_VERSION}
image: ckan/ckan-postgres-dev:2.9
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
env_file:
- .env
healthcheck:
test: ["CMD", "pg_isready -u postgres"]
interval: 10s
Expand All @@ -48,6 +58,5 @@ services:
- "8983:8983"

volumes:
ckan_storage:
pg_data:
solr_data:
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-e git+https://github.com/GSA/ckanext-harvest.git@9d1f647d247c16b6c3acba26e321e9500cafb18c#egg=ckanext-harvest
-e git+https://github.com/GSA/ckanext-harvest.git@eb73bed1739ac8656d892a609b5ee303e34251ca#egg=ckanext-harvest

ckantoolkit==0.0.3
ckantoolkit>=0.0.7
pika
pyOpenSSL
pyopenssl==22.1.0
ckanext-envvars==0.0.3
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# http://packaging.python.org/en/latest/tutorial.html#version
version='0.0.5',
version='0.1.0',

description='''Catalog customizations''',
long_description=long_description,
Expand Down
4 changes: 2 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
set -o errexit
set -o pipefail

TEST_CONFIG=/app/test.ini
TEST_CONFIG=/srv/app/test.ini

# Database is listening, but still unavailable. Just keep trying...
while ! ckan -c $TEST_CONFIG db init; do
Expand All @@ -19,4 +19,4 @@ done
ckan -c $TEST_CONFIG harvester initdb

# start_ckan_development.sh &
pytest --ckan-ini=$TEST_CONFIG --cov=ckanext.datagovcatalog --disable-warnings /app/ckanext/datagovcatalog/tests/
pytest --ckan-ini=$TEST_CONFIG --cov=ckanext.datagovcatalog --disable-warnings /srv/app/ckanext/datagovcatalog/tests/

0 comments on commit 5dfabe0

Please sign in to comment.