-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
105 lines (76 loc) · 3.72 KB
/
Makefile
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
.PHONY: test install lint generate-tests-from-features
include .env-dev
BUILD_PRINT = \e[1;34mSTEP: \e[0m
#-----------------------------------------------------------------------------
# Basic commands
#-----------------------------------------------------------------------------
install-all:
@ echo -e "$(BUILD_PRINT)Installing both user and dev requirements$(END_BUILD_PRINT)"
@ python -m pip install --upgrade pip
@ python -m pip install -r requirements.txt -r requirements-dev.txt
install-dev:
@ echo -e "$(BUILD_PRINT)Installing only dev requirements$(END_BUILD_PRINT)"
@ python -m pip install --upgrade pip
@ python -m pip install -r requirements-dev.txt
install:
@ echo "$(BUILD_PRINT)Installing user requirements"
@ python -m pip install --upgrade pip
@ python -m pip install -r requirements.txt
test: test-unit
test-unit:
@ echo -e "$(BUILD_PRINT)Unit Testing ...$(END_BUILD_PRINT)"
@ tox -e unit
test-features:
@ echo -e "$(BUILD_PRINT)Gherkin Features Testing ...$(END_BUILD_PRINT)"
@ tox -e features
test-all:
@ echo "$(BUILD_PRINT)Running all tests"
@ tox
#-----------------------------------------------------------------------------
# Gherkin feature and acceptance test generation commands
#-----------------------------------------------------------------------------
FEATURES_FOLDER = tests/features
STEPS_FOLDER = tests/steps
FEATURE_FILES := $(wildcard $(FEATURES_FOLDER)/*.feature)
EXISTENT_TEST_FILES = $(wildcard $(STEPS_FOLDER)/*.py)
HYPOTHETICAL_TEST_FILES := $(addprefix $(STEPS_FOLDER)/test_, $(notdir $(FEATURE_FILES:.feature=.py)))
TEST_FILES := $(filter-out $(EXISTENT_TEST_FILES),$(HYPOTHETICAL_TEST_FILES))
generate-tests-from-features: $(TEST_FILES)
@ echo "$(BUILD_PRINT)The following test files should be generated: $(TEST_FILES)"
@ echo "$(BUILD_PRINT)Done generating missing feature files"
@ echo "$(BUILD_PRINT)Verifying if there are any missing step implementations"
@ py.test --generate-missing --feature $(FEATURES_FOLDER)
$(addprefix $(STEPS_FOLDER)/test_, $(notdir $(STEPS_FOLDER)/%.py)): $(FEATURES_FOLDER)/%.feature
@ echo "$(BUILD_PRINT)Generating the testfile "$@" from "$<" feature file"
@ pytest-bdd generate $< > $@
@ sed -i 's|features|../features|' $@
#-----------------------------------------------------------------------------
# Fuseki related commands
#-----------------------------------------------------------------------------
start-fuseki:
@ echo "$(BUILD_PRINT)Starting Fuseki on port $(if $(FUSEKI_PORT),$(FUSEKI_PORT),'default port')"
@ docker-compose --file docker-compose.yml --env-file .env-dev up -d fuseki
stop-fuseki:
@ echo "$(BUILD_PRINT)Stopping Fuseki"
@ docker-compose --file docker-compose.yml --env-file .env-dev down
fuseki-create-test-dbs:
@ echo "$(BUILD_PRINT)Building dummy "subdiv" and "abc" datasets at http://localhost:$(if $(FUSEKI_PORT),$(FUSEKI_PORT),unknown port)/$$/datasets"
@ sleep 2
@ curl --anyauth --user 'admin:admin' -d 'dbType=mem&dbName=subdiv' 'http://localhost:$(FUSEKI_PORT)/$$/datasets'
@ curl --anyauth --user 'admin:admin' -d 'dbType=mem&dbName=abc' 'http://localhost:$(FUSEKI_PORT)/$$/datasets'
clean-data:
@ echo "$(BUILD_PRINT)Deleting the $(DATA_FOLDER)"
@ sudo rm -rf $(DATA_FOLDER)
start-service: start-fuseki fuseki-create-test-dbs
stop-service: stop-fuseki clean-data
publish-pipy:
@ echo "$(BUILD_PRINT)Creating the source distribution"
@ python3 setup.py sdist bdist_wheel
@ echo "$(BUILD_PRINT)Checking the distribution"
@ twine check dist/*
@ echo "$(BUILD_PRINT)Uploading the distribution"
@ twine upload --skip-existing dist/*
#-----------------------------------------------------------------------------
# Default
#-----------------------------------------------------------------------------
all: install test