-
Notifications
You must be signed in to change notification settings - Fork 0
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
Replace vagrant-based testing with docker-based testing #7
Merged
Merged
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
74f4db6
enh: implement docker based testing
RaghavaAlajangi a116f01
fix: update upload-artifact version
RaghavaAlajangi bcf7e32
fix: install docker-compose
RaghavaAlajangi 68c6741
fix: install docker-compose from binary
RaghavaAlajangi 74a9c11
ref: move docker-compose.ci.yml to src dir
RaghavaAlajangi c4b54d5
fix: change build context to image
RaghavaAlajangi 378a9d5
fix: cleaning
RaghavaAlajangi bf70787
fix: configure Ci piepline properly
RaghavaAlajangi 4c60ea6
fix: replace /bin/bash with bash
RaghavaAlajangi 3287812
fix: remove interactive mode
RaghavaAlajangi 763f576
fix: change extension path
RaghavaAlajangi fa9de43
fix: run tests as ckan user in docker container
RaghavaAlajangi 16708a7
fix: set user to root in docker-compose configuration
RaghavaAlajangi 3f1d2e3
fix: run tests as root user in docker container
RaghavaAlajangi 27893c1
fix: update docker configuration to avoid permission errors and run t…
RaghavaAlajangi 50ca854
fix: update test script to set ownership for venv and coverage data
RaghavaAlajangi 30b4c9d
fix: update test script to run tests on GitHub runner and remove owne…
RaghavaAlajangi 8e5c896
ref: replace .env.example with docker-env.ci for environment configur…
RaghavaAlajangi cb37f48
fix: replace docker-env.ci with docker-ci.env
RaghavaAlajangi 155d93b
fix: replace docker-env.ci with docker-ci.env
RaghavaAlajangi 0d6b162
Merge branch 'run_tests_with_docker' of https://github.com/DCOR-dev/c…
RaghavaAlajangi 4ecb3a8
fix: use docker-ci.env for Docker Compose environment variables
RaghavaAlajangi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Host Ports | ||
CKAN_PORT_HOST=5000 | ||
NGINX_PORT_HOST=81 | ||
NGINX_SSLPORT_HOST=8443 | ||
|
||
# CKAN databases | ||
POSTGRES_USER=postgres | ||
POSTGRES_PASSWORD=postgres | ||
POSTGRES_DB=postgres | ||
POSTGRES_HOST=db | ||
CKAN_DB_USER=ckandbuser | ||
CKAN_DB_PASSWORD=ckandbpassword | ||
CKAN_DB=ckandb | ||
DATASTORE_READONLY_USER=datastore_ro | ||
DATASTORE_READONLY_PASSWORD=datastore | ||
DATASTORE_DB=datastore | ||
CKAN_SQLALCHEMY_URL=postgresql://ckandbuser:ckandbpassword@db/ckandb | ||
CKAN_DATASTORE_WRITE_URL=postgresql://ckandbuser:ckandbpassword@db/datastore | ||
CKAN_DATASTORE_READ_URL=postgresql://datastore_ro:datastore@db/datastore | ||
|
||
# Test database connections | ||
TEST_CKAN_SQLALCHEMY_URL=postgres://ckan:ckan@db/ckan_test | ||
TEST_CKAN_DATASTORE_WRITE_URL=postgresql://ckan:ckan@db/datastore_test | ||
TEST_CKAN_DATASTORE_READ_URL=postgresql://datastore_ro:datastore@db/datastore_test | ||
|
||
# Dev settings | ||
USE_HTTPS_FOR_DEV=false | ||
|
||
# CKAN core | ||
CKAN_VERSION=2.10.0 | ||
CKAN_SITE_ID=default | ||
CKAN_SITE_URL=https://localhost:8443 | ||
CKAN___BEAKER__SESSION__SECRET=CHANGE_ME | ||
# See https://docs.ckan.org/en/latest/maintaining/configuration.html#api-token-settings | ||
CKAN___API_TOKEN__JWT__ENCODE__SECRET=string:CHANGE_ME | ||
CKAN___API_TOKEN__JWT__DECODE__SECRET=string:CHANGE_ME | ||
CKAN_SYSADMIN_NAME=ckan_admin | ||
CKAN_SYSADMIN_PASSWORD=test1234 | ||
[email protected] | ||
CKAN_STORAGE_PATH=/var/lib/ckan | ||
CKAN_SMTP_SERVER=smtp.corporateict.domain:25 | ||
CKAN_SMTP_STARTTLS=True | ||
CKAN_SMTP_USER=user | ||
CKAN_SMTP_PASSWORD=pass | ||
CKAN_SMTP_MAIL_FROM=ckan@localhost | ||
CKAN_MAX_UPLOAD_SIZE_MB=100 | ||
TZ=UTC | ||
|
||
# Solr | ||
SOLR_IMAGE_VERSION=2.10-solr9 | ||
CKAN_SOLR_URL=http://solr:8983/solr/ckan | ||
TEST_CKAN_SOLR_URL=http://solr:8983/solr/ckan | ||
|
||
# Redis | ||
REDIS_VERSION=6 | ||
CKAN_REDIS_URL=redis://redis:6379/1 | ||
TEST_CKAN_REDIS_URL=redis://redis:6379/1 | ||
|
||
# Datapusher | ||
DATAPUSHER_VERSION=0.0.20 | ||
CKAN_DATAPUSHER_URL=http://datapusher:8800 | ||
CKAN__DATAPUSHER__CALLBACK_URL_BASE=http://ckan:5000 | ||
|
||
# NGINX | ||
NGINX_PORT=80 | ||
NGINX_SSLPORT=443 | ||
|
||
# Extensions | ||
CKAN__PLUGINS="image_view text_view datatables_view datastore datapusher envvars" | ||
CKAN__HARVEST__MQ__TYPE=redis | ||
CKAN__HARVEST__MQ__HOSTNAME=redis | ||
CKAN__HARVEST__MQ__PORT=6379 | ||
CKAN__HARVEST__MQ__REDIS_DB=1 | ||
|
||
CKAN___LICENSES_GROUP_URL=file:///srv/app/.local/lib/python3.10/site-packages/ckanext/dcor_schemas/licenses.json |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
0.8.3 | ||
- enh: implement docker based testing | ||
0.8.2 | ||
- setup: fix ckanext namespace | ||
0.8.1 | ||
|
This file was deleted.
Oops, something went wrong.
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,101 @@ | ||
volumes: | ||
ckan_storage: | ||
pg_data: | ||
solr_data: | ||
pip_cache: | ||
site_packages: | ||
vscode_server: | ||
minio_data: | ||
|
||
services: | ||
dcor-test: | ||
# Use image from Raghava's dockerHub | ||
image: raghavaalajangi95/dcor-ckan-docker-ckan:latest | ||
env_file: | ||
- .env | ||
links: | ||
- db | ||
- solr | ||
- redis | ||
- minio | ||
# hostname is defined as a docker resource in `dcor_control` | ||
hostname: dcor-dev-docker | ||
ports: | ||
- "0.0.0.0:${CKAN_PORT_HOST}:5000" | ||
user: root # This will avoid permission errors | ||
volumes: | ||
- ckan_storage:/var/lib/ckan | ||
# Map current GitHub runner working dir as src_extensions dir within | ||
# the container (this will allow us to access the ckanext-dcor_theme | ||
# directly inside src_extensions) | ||
- ./:/srv/app/src_extensions | ||
- pip_cache:/root/.cache/pip | ||
- site_packages:/usr/lib/python3.10/site-packages | ||
- vscode_server:/root/.vscode-server | ||
restart: unless-stopped | ||
healthcheck: | ||
test: ["CMD", "wget", "-qO", "/dev/null", "http://localhost:5000"] | ||
|
||
datapusher: | ||
image: ckan/ckan-base-datapusher:${DATAPUSHER_VERSION} | ||
restart: unless-stopped | ||
healthcheck: | ||
test: ["CMD", "wget", "-qO", "/dev/null", "http://localhost:8800"] | ||
|
||
db: | ||
# Use image from Raghava's dockerHub | ||
image: raghavaalajangi95/dcor-ckan-docker-postgresql:latest | ||
environment: | ||
- POSTGRES_USER | ||
- POSTGRES_PASSWORD | ||
- POSTGRES_DB | ||
- CKAN_DB_USER | ||
- CKAN_DB_PASSWORD | ||
- CKAN_DB | ||
- DATASTORE_READONLY_USER | ||
- DATASTORE_READONLY_PASSWORD | ||
- DATASTORE_DB | ||
volumes: | ||
- pg_data:/var/lib/postgresql/data | ||
restart: unless-stopped | ||
healthcheck: | ||
test: ["CMD", "pg_isready", "-U", "${POSTGRES_USER}", "-d", "${POSTGRES_DB}"] | ||
|
||
solr: | ||
image: ckan/ckan-solr:${SOLR_IMAGE_VERSION} | ||
volumes: | ||
- solr_data:/var/solr | ||
restart: unless-stopped | ||
healthcheck: | ||
test: ["CMD", "wget", "-qO", "/dev/null", "http://localhost:8983/solr/"] | ||
|
||
redis: | ||
image: redis:${REDIS_VERSION} | ||
restart: unless-stopped | ||
healthcheck: | ||
test: ["CMD", "redis-cli", "-e", "QUIT"] | ||
|
||
minio: | ||
image: minio/minio:latest | ||
restart: unless-stopped | ||
environment: | ||
- MINIO_ROOT_USER | ||
- MINIO_ROOT_PASSWORD | ||
command: minio server --console-address ":9001" /data | ||
ports: | ||
- "9000:9000" | ||
- "9001:9001" | ||
volumes: | ||
- minio_data:/data | ||
|
||
mc: | ||
image: minio/mc:RELEASE.2020-08-08T02-33-58Z | ||
depends_on: | ||
- minio | ||
entrypoint: > | ||
/bin/sh -c " | ||
/usr/bin/mc config host rm local; | ||
/usr/bin/mc config host add --api s3v4 local http://minio:9000 minioadmin minioadmin; | ||
/usr/bin/mc mb local/ckan/; | ||
/usr/bin/mc policy set download local/ckan/storage; | ||
" |
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,43 @@ | ||
#!/bin/bash | ||
|
||
# Fail immediately if any command fails | ||
set -e | ||
|
||
EXTENSION_NAME="ckanext-dcor_theme" # Change this to your extension's name | ||
CKAN_CONTAINER="${EXTENSION_NAME}-dcor-test-1" # CKAN container name | ||
EXTENSION_PATH="/srv/app/src_extensions/" | ||
|
||
# Create venv and install dependencies as a root user inside the container | ||
docker exec -u root ${CKAN_CONTAINER} bash -c " | ||
cd ${EXTENSION_PATH}; | ||
|
||
# Create a venv with systme site packages | ||
python3 -m venv --system-site-packages venv; | ||
source venv/bin/activate; | ||
pip install --upgrade pip wheel; | ||
|
||
# Update dcor libraries | ||
dcor update --yes; | ||
|
||
# Install ckanext-dcor_theme and its test requirements | ||
pip install .; | ||
pip install -r ./ckanext/dcor_theme/tests/requirements.txt; | ||
|
||
# Change ownership so that 'ckan' user can use the virtual environment | ||
chown -R ckan:ckan-sys ${EXTENSION_PATH}/venv | ||
" | ||
|
||
# Run tests on GitHub runner where container gets permissions from. | ||
echo "Running tests in the virtual environment..." | ||
docker exec ${CKAN_CONTAINER} bash -c " | ||
cd ${EXTENSION_PATH}; | ||
source venv/bin/activate; | ||
|
||
# Run coverage | ||
coverage run --source=ckanext.dcor_theme --omit=*tests* -m pytest -p no:warnings ckanext; | ||
|
||
# Generate the XML report | ||
coverage xml | ||
" | ||
|
||
echo "Tests completed!" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would propose to name this file to
docker-env.ci
and consequently use it in the entire workflow, i.e.check.yml
docker-compose.ci.yml
'senv_file
key.The reason is that
.env
is too generic which might lead to ambiguities.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will change it.