forked from OpenDataGIS/ckanext-facet_scheming
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from mjanez/feature/docker-tests
Add docker-compose tests
- Loading branch information
Showing
7 changed files
with
161 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
omit = | ||
*/site-packages/* | ||
*/python?.?/* | ||
ckan/* | ||
ckan/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
build | ||
dist | ||
*.egg-info/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
services: | ||
ckan: | ||
build: | ||
context: . | ||
dockerfile: docker/Dockerfile | ||
environment: | ||
TZ: UTC | ||
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 | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: postgres | ||
depends_on: | ||
- postgres | ||
- solr | ||
- redis | ||
volumes: | ||
- ./ckanext:/srv/app/src/ckanext-schemingdcat/ckanext | ||
|
||
solr: | ||
image: ckan/ckan-solr:2.9-solr9-spatial | ||
logging: | ||
driver: none | ||
healthcheck: | ||
test: ["CMD", "wget", "-qO", "/dev/null", "http://localhost:8983/solr/"] | ||
|
||
postgres: | ||
image: ckan/ckan-postgres-dev:2.9 | ||
logging: | ||
driver: none | ||
healthcheck: | ||
test: ["CMD", "pg_isready", "-U", "ckan_default", "-d", "ckan_test"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
redis: | ||
image: redis:latest | ||
logging: | ||
driver: none | ||
healthcheck: | ||
test: ["CMD", "redis-cli", "-e", "QUIT"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
FROM ghcr.io/mjanez/ckan-spatial-test:2.10.5 | ||
|
||
ENV CKAN_VERSION_MAYOR=ckan-2.9 | ||
ENV APP_DIR=/srv/app | ||
ENV CKAN_DIR=${APP_DIR}/src/ckan | ||
ENV TZ=UTC | ||
|
||
WORKDIR ${APP_DIR}/src/ckanext-schemingdcat | ||
|
||
# Conditionally install pytest-rerunfailures if CKAN version is 2.9 | ||
RUN if [ "$CKAN_VERSION_MAYOR" = "2.9" ]; then \ | ||
pip3 install -U pytest-rerunfailures; \ | ||
fi | ||
|
||
# Copy extension files to the container | ||
COPY . . | ||
|
||
# ## Override test_ckan.sh | ||
# - Make sure to put the docker/setup/test_ckan.sh.override path because of the COPY context | ||
# COPY docker/setup/test_ckan.sh.override ${APP_DIR}/test_ckan.sh | ||
# RUN chmod +x ${APP_DIR}/test_ckan.sh | ||
|
||
# Install the base + test dependencies | ||
RUN pip3 install --no-cache-dir -r ${APP_DIR}/src/ckanext-schemingdcat/requirements.txt && \ | ||
# ignore installed packaging required version (fixed pyshacl issues) | ||
pip3 install --no-cache-dir -r ${APP_DIR}/src/ckanext-schemingdcat/dev-requirements.txt && \ | ||
pip3 install -e ${APP_DIR}/src/ckanext-schemingdcat && \ | ||
# 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 | ||
|
||
WORKDIR ${APP_DIR} | ||
|
||
# Setup other extensions | ||
RUN echo "mjanez/ckanext-dcat" && \ | ||
pip3 install --no-cache-dir -e git+https://github.com/mjanez/ckanext-dcat.git#egg=ckanext-dcat && \ | ||
pip3 install --no-cache-dir -r ${APP_DIR}/src/ckanext-dcat/requirements.txt && \ | ||
echo "ckan/ckanext-harvest" && \ | ||
pip3 install --no-cache-dir -e git+https://github.com/ckan/ckanext-harvest.git#egg=ckanext-harvest && \ | ||
pip3 install --no-cache-dir -r ${APP_DIR}/src/ckanext-harvest/requirements.txt && \ | ||
echo "ckan/ckanext-scheming" && \ | ||
pip3 install --no-cache-dir -e git+https://github.com/ckan/ckanext-scheming.git#egg=ckanext-scheming && \ | ||
echo "mjanez/ckanext-fluent" && \ | ||
pip3 install --no-cache-dir -e git+https://github.com/mjanez/ckanext-fluent.git#egg=ckanext-fluent | ||
|
||
WORKDIR ${APP_DIR}/src/ckanext-schemingdcat | ||
|
||
# Running the tests with coverage output | ||
CMD ["/bin/sh", "-c", "$APP_DIR/test_ckan.sh -d ckanext/schemingdcat/tests ckanext.schemingdcat"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Setup extension | ||
echo "[ckan-test.run-tests] Database init" | ||
ckan -c test.ini db init | ||
|
||
echo "[ckan-test.run-tests] Database pending migrations" | ||
ckan -c test.ini db pending-migrations --apply | ||
|
||
# Default test directory and output file | ||
TEST_DIR="tests" | ||
|
||
# Parse options | ||
while getopts 'cd:o:' OPTION; do | ||
case "$OPTION" in | ||
c) | ||
RUN_COVERALLS=1;; | ||
d) | ||
TEST_DIR="$OPTARG";; | ||
?) | ||
RUN_COVERALLS=0; | ||
exit 1;; | ||
esac | ||
done | ||
shift "$(($OPTIND -1))" | ||
|
||
if [ -n "$1" ]; then | ||
echo "[ckan-test.run-tests] pytest --ckan-ini=test.ini --cov=\"$1\" --cov-report=term-missing --cov-append --disable-warnings $TEST_DIR" | ||
pytest --ckan-ini=test.ini --cov="$1" --cov-report=term-missing --cov-append --disable-warnings "$TEST_DIR" | ||
test_exit_code=$? | ||
else | ||
echo "[ckan-test.run-tests] pytest --ckan-ini=test.ini --cov-report=term-missing --cov-append --disable-warnings $TEST_DIR" | ||
pytest --ckan-ini=test.ini --cov-report=term-missing --cov-append --disable-warnings "$TEST_DIR" | ||
test_exit_code=$? | ||
fi | ||
|
||
if [ "$RUN_COVERALLS" = 1 ]; then | ||
coveralls; | ||
fi | ||
|
||
exit $test_exit_code |