-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-run-tests.sh
43 lines (32 loc) · 1.23 KB
/
docker-run-tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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!"