Skip to content

Commit

Permalink
Merge pull request #102 from opendatazurich/dockerizing
Browse files Browse the repository at this point in the history
Merge dockerizing into main branch
  • Loading branch information
bellisk committed Feb 8, 2024
2 parents bf2be0e + 2ac47fd commit f3860f8
Show file tree
Hide file tree
Showing 22 changed files with 2,660 additions and 1,473 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Tests
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Install requirements
run: pip install flake8 pycodestyle black isort
- name: Check syntax
run: flake8 . --count --select=C901,E901,E999,F401,F821,F822,F823 --show-source --statistics --extend-exclude ckan
- name: Check codestyle
run: |
isort --diff --check ckanext/
black --diff --check ckanext/
test:
needs: lint
strategy:
matrix:
ckan-version: ["2.10"]
fail-fast: false

name: CKAN ${{ matrix.ckan-version }}
runs-on: ubuntu-20.04
services:
postgres:
image: ckan/ckan-postgres-dev:${{ matrix.ckan-version }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:3
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
WORKDIR: /__w/ckanext-stadtzh-harvest/ckanext-stadtzh-harvest
SOLR_CONFIG_CKAN_DIR: /opt/solr/server/solr/configsets/ckan/conf

steps:
- uses: actions/checkout@v3
- name: Create solr container
run: |
/usr/bin/docker create --name test_solr --network ${{ job.container.network }} --network-alias solr \
--workdir $WORKDIR --publish 8983:8983 \
-e "SOLR_HEAP=1024m" -e "SOLR_SCHEMA_FILE=$SOLR_CONFIG_CKAN_DIR/managed-schema" \
-e GITHUB_ACTIONS=true -e CI=true -v "${{ github.workspace }}/solr/schema.xml":"$SOLR_CONFIG_CKAN_DIR/managed-schema" \
-v "${{ github.workspace }}/solr/german_dictionary.txt":"$SOLR_CONFIG_CKAN_DIR/german_dictionary.txt" \
-v "${{ github.workspace }}/solr/solrconfig.xml":"$SOLR_CONFIG_CKAN_DIR/solrconfig.xml" \
ckan/ckan-solr:${{ matrix.ckan-version }}
docker start test_solr
- name: Create ckan container
run: |
/usr/bin/docker create --name test_ckan --network ${{ job.container.network }} --network-alias ckan \
-e "HOME=/github/home" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" \
-v "/home/runner/work":"/__w" -v "/home/runner/work/_temp":"/__w/_temp" \
-v "/home/runner/work/_actions":"/__w/_actions" -v "/opt/hostedtoolcache":"/__t" \
-v "/home/runner/work/_temp/_github_home":"/github/home" \
-v "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
--entrypoint "tail" openknowledge/ckan-dev:${{ matrix.ckan-version }} "-f" "/dev/null"
docker start test_ckan
- name: Install requirements and set up ckanext
run: |
docker exec test_ckan $WORKDIR/bin/install_test_requirements.sh ${{ matrix.ckan-version }}
- name: Run tests
run: |
docker exec test_ckan pytest --ckan-ini=$WORKDIR/test.ini \
--cov=ckanext.stadtzhharvest --disable-warnings $WORKDIR/ckanext/stadtzhharvest/tests
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile = black
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)

ckanext-stadtzh-harvest
=======================

Expand Down
29 changes: 29 additions & 0 deletions bin/install_test_requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Install requirements and ckanext
pip install -r /__w/ckanext-stadtzh-harvest/ckanext-stadtzh-harvest/requirements.txt
pip install -r /__w/ckanext-stadtzh-harvest/ckanext-stadtzh-harvest/dev-requirements.txt
pip install -e /__w/ckanext-stadtzh-harvest/ckanext-stadtzh-harvest/
pip install -U requests[security]

# Install ckanext dependencies
pip install -e git+https://github.com/ckan/ckanext-xloader.git#egg=ckanext-xloader
pip install -r https://raw.githubusercontent.com/ckan/ckanext-xloader/master/requirements.txt
pip install -e git+https://github.com/opendatazurich/ckanext-stadtzh-theme.git@main#egg=ckanext-stadtzh-theme
pip install -r https://raw.githubusercontent.com/opendatazurich/ckanext-stadtzh-theme/main/pip-requirements.txt
pip install -e git+https://github.com/ckan/ckanext-dcat.git#egg=ckanext-dcat
pip install -r https://raw.githubusercontent.com/ckan/ckanext-dcat/master/requirements.txt
pip install -e git+https://github.com/ckan/ckanext-harvest.git#egg=ckanext-harvest
pip install -r https://raw.githubusercontent.com/ckan/ckanext-harvest/master/requirements.txt

# 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/' /__w/ckanext-stadtzh-harvest/ckanext-stadtzh-harvest/test.ini

# Init db and enable required plugins
echo "Removing all ckan plugins so we can initialize the database"
ckan config-tool /__w/ckanext-stadtzh-harvest/ckanext-stadtzh-harvest/test.ini "ckan.plugins = "
ckan -c /__w/ckanext-stadtzh-harvest/ckanext-stadtzh-harvest/test.ini db init
echo "Re-enabling ckan plugins now the database is initialized"
ckan config-tool /__w/ckanext-stadtzh-harvest/ckanext-stadtzh-harvest/test.ini "ckan.plugins = harvest stadtzh_harvester stadtzhtheme"
echo "Plugins enabled: harvest stadtzh_harvester stadtzhtheme"
ckan -c /__w/ckanext-stadtzh-harvest/ckanext-stadtzh-harvest/test.ini db upgrade -p harvest
98 changes: 0 additions & 98 deletions bin/travis-build.bash

This file was deleted.

15 changes: 0 additions & 15 deletions bin/travis-run.sh

This file was deleted.

2 changes: 2 additions & 0 deletions ckanext/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# this is a namespace package
try:
import pkg_resources

pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil

__path__ = pkgutil.extend_path(__path__, __name__)
Loading

0 comments on commit f3860f8

Please sign in to comment.