-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdocker-compose-test.yaml
59 lines (59 loc) · 2.26 KB
/
docker-compose-test.yaml
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# PY_VER=3.9 IMAGE=djtest DISTRO=alpine AS_SCRIPT=FALSE PHARUS_VERSION=$(cat pharus/version.py | grep -oP '\d+\.\d+\.\d+') HOST_UID=$(id -u) docker compose -f docker-compose-test.yaml up --exit-code-from pharus
#
# Intended for running test suite locally.
# Note: If requirements or Dockerfile change, will need to add --build flag.
version: "2.4"
x-net:
&net
networks:
- main
services:
db:
<<: *net
image: datajoint/mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=simple
pharus:
<<: *net
stdin_open: true # docker run -i
tty: true # docker run -t
extends:
file: ./docker-compose-build.yaml
service: pharus
environment:
- FLASK_ENV=development # enables logging to console from Flask
- TEST_DB_SERVER=${TEST_DB_SERVER:-db}
- TEST_DB_USER=${TEST_DB_USER:-root}
- TEST_DB_PASS=${TEST_DB_PASS:-simple}
- AS_SCRIPT
- PHARUS_SPEC_PATH=tests/init/test_dynamic_api_spec.yaml
volumes:
- ./requirements_test.txt:/tmp/pip_requirements.txt
- ./pharus:/opt/conda/lib/python${PY_VER}/site-packages/pharus
command:
- sh
- -c
- |
set -e
if echo "${AS_SCRIPT}" | grep -i true &>/dev/null; then
echo "------ SYNTAX TESTS ------"
PKG_DIR=/main/pharus
flake8 $${PKG_DIR} --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 /main/tests --count --select=E9,F63,F7,F82 --show-source --statistics
echo "------ UNIT TESTS ------"
pytest -sv --cov-report term-missing --cov=pharus /main/tests/
echo "------ STYLE TESTS ------"
black $${PKG_DIR} --required-version '24.8.0' --check -v --extend-exclude "^.*dynamic_api.py$$"
flake8 $${PKG_DIR} --count --max-complexity=20 --max-line-length=94 --statistics --exclude=*dynamic_api.py --ignore=W503,W605
black /main/tests --required-version '24.8.0' --check -v
flake8 /main/tests --count --max-complexity=20 --max-line-length=94 --statistics --ignore=F401,F811,W503,F403
else
echo "=== Running ==="
echo "Please see 'docker-compose-test.yaml' for detail on running tests."
tail -f /dev/null
fi
depends_on:
db:
condition: service_healthy
networks:
main: