-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
98 lines (83 loc) · 3.25 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
#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License 2.0;
# you may not use this file except in compliance with the Elastic License 2.0.
#
PYTHON ?= python3
PYTHON_EXE = python
PIP = pip3
VENV_DIRECTORY = venv
PROJECT_DIRECTORY = ees_network_drive
TEST_DIRECTORY = tests
COVERAGE_THRESHOLD = 50 # In percents, so 50 = 50%
EXEC_DIR = bin
CMD_UPDATE = touch
ES_VERSION_V8 ?= yes
.DEFAULT_GOAL = help
ifeq ($(OS),Windows_NT)
detected_OS := Windows
EXEC_DIR := Scripts
CMD_UPDATE := type nul >
endif
ifeq ($(ES_VERSION_V8), yes)
ES_LIB := elastic_enterprise_search==8.2.0
else
ES_LIB := elastic_enterprise_search==7.17.0
endif
help:
@echo "make install_locally - install the project into virtual environment for development purposes"
@echo "make install_package - install the project for the user"
@echo "make uninstall_package - uninstall the project for the user"
@echo "make test - run the tests for the project"
@echo "make cover - check test coverage for the project"
@echo "make lint - run linter against the project"
@echo "make clean - remove venv and other temporary files from the project"
@echo "make test_connectivity - test connectivity to Network Drives and Enterprise Search"
@echo "make update_package - update package with local changes"
.venv_init:
${PIP} install virtualenv
${PYTHON} -m venv ${VENV_DIRECTORY}
${CMD_UPDATE} .venv_init
.installed: .venv_init
${VENV_DIRECTORY}/${EXEC_DIR}/${PIP} install -U pip
${VENV_DIRECTORY}/${EXEC_DIR}/${PIP} install -r requirements.txt
${VENV_DIRECTORY}/${EXEC_DIR}/${PIP} install --force-reinstall ${ES_LIB}
${CMD_UPDATE} .installed
# install_locally can be used to test the implementation after the changes were made to the module
# #{VENV_DIRECTORY}/bin will contain a file with name ${PROJECT_DIRECTORY} that is the main
# executable.
install_locally: .installed .venv_init
${VENV_DIRECTORY}/${EXEC_DIR}/${PIP} install .
test: .installed .venv_init
${VENV_DIRECTORY}/${EXEC_DIR}/${PYTHON_EXE} -m pytest ${TEST_DIRECTORY}/ --suppress-no-test-exit-code
cover: .installed .venv_init
${VENV_DIRECTORY}/${EXEC_DIR}/${PYTHON_EXE} -m pytest --cov ${PROJECT_DIRECTORY} --cov-config=${TEST_DIRECTORY}/.coveragerc --cov-fail-under=${COVERAGE_THRESHOLD} ${TEST_DIRECTORY}/ --suppress-no-test-exit-code
lint: .installed .venv_init
${VENV_DIRECTORY}/${EXEC_DIR}/flake8 ${PROJECT_DIRECTORY}
test_connectivity: .installed .venv_init
${VENV_DIRECTORY}/${EXEC_DIR}/pytest ${PROJECT_DIRECTORY}/test_connectivity.py
install_package: .installed
${PIP} install --user .
${PIP} install --force-reinstall ${ES_LIB}
update_package:
${PIP} install --user .
uninstall_package:
${PIP} uninstall ${PROJECT_DIRECTORY} -y
clean:
ifeq ($(detected_OS),Windows)
if exist venv rd /s /Q venv 2>nul
if exist build rd /s /Q build 2>nul
if exist ${PROJECT_DIRECTORY}.egg-info rd /s /Q ${PROJECT_DIRECTORY}.egg-info 2>nul
if exist .pytest_cache rd /s /Q .pytest_cache 2>nul
if exist .coverage del /s /Q .coverage 2>nul
if exist .installed del /Q .installed 2>nul
if exist .venv_init del /Q .venv_init 2>nul
else
rm -rf venv
rm -rf build
rm -rf *.egg-info
rm -rf .pytest_cache
rm -f .coverage
rm -f .installed
rm -f .venv_init
endif