-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.mk
50 lines (41 loc) · 1.61 KB
/
test.mk
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
SHELL := /bin/bash
TIMESTAMP := $(shell date +%Y-%m-%d_%H-%M-%S)
MYSQL_CREDS := $(if $(MYSQL_ALLOW_EMPTY_PASSWORD),-uroot,-uroot -p)
MYSQL_DATABASE ?= sdc
COVERAGE_THRESHOLD ?= 90
build:
make install-requirements;
make hard-refresh;
make test;
make lint;
hard-refresh:
make db-refresh;
make redis-flush;
test:
pip install pytest mock pytest-mock coverage;
coverage run -m pytest;
coverage report --fail-under=${COVERAGE_THRESHOLD}
test-no-cover:
pip install pytest mock pytest-mock pytest-console-scripts;
pytest;
db-refresh:
mysql -h127.0.0.1 ${MYSQL_CREDS} -e "DROP DATABASE IF EXISTS "${MYSQL_DATABASE}";";
mysql -h127.0.0.1 ${MYSQL_CREDS} -e "CREATE DATABASE "${MYSQL_DATABASE}";";
mysql -h127.0.0.1 ${MYSQL_CREDS} "${MYSQL_DATABASE}" < tests/db/schema.sql;
lint:
pip install pylint;
find . -type f -name "*.py" | xargs pylint --ignored-modules=pyspark,awsglue --extension-pkg-whitelist=pyspark,awsglue;
redis-flush:
sudo apt-get install redis-tools;
redis-cli FLUSHALL;
test-dependant:
$(eval VERSION := $(shell grep ${PACKAGE_NAME}== requirements.txt | grep -Eo '[0-9]+([.][0-9]+)([.][0-9]+)?'))
sed -i 's#${PACKAGE_NAME}==${VERSION}#git+https://lucidlogic:${GIT_ACCESS_TOKEN}@github.com/${REPO_NAME}/@${BRANCH_NAME}#g' requirements.txt
make install-requirements;
make hard-refresh;
make test;
test-dependant-no-db:
$(eval VERSION := $(shell grep ${PACKAGE_NAME}== requirements.txt | grep -Eo '[0-9]+([.][0-9]+)([.][0-9]+)?'))
sed -i 's#${PACKAGE_NAME}==${VERSION}#git+https://lucidlogic:${GIT_ACCESS_TOKEN}@github.com/${REPO_NAME}/@${BRANCH_NAME}#g' requirements.txt
make install-requirements;
make test;