-
Notifications
You must be signed in to change notification settings - Fork 114
/
Makefile
174 lines (133 loc) · 3.67 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
SHELL = /bin/bash -o pipefail
USER := $(shell whoami)
check-root:
ifeq ($(USER), root)
@echo "WARNING: Installing as root should be avoided at all costs. Use a virtualenv."
endif
### REQUIREMENTS
install-python-requirements: setup.py check-root
@echo "--> Installing Python development dependencies."
pip install setuptools
pip install -r requirements.txt
install-node-requirements:
@echo "--> Installing Node development dependencies."
cd stethoscope/ui && npm install
install-requirements: install-python-requirements install-node-requirements
### INSTALL/DEVELOP/BUILD
install-editable-package:
@echo "--> Installing editable package."
pip install --no-deps -e .[\
google,\
jamf,\
landesk,\
duo,\
bitfit,\
vpn_labeler,\
mac_manufacturer,\
re_filter,\
oidc,\
es_logger,\
es_notifications,\
restful_feedback,\
atlas,\
batch,\
batch_es,\
batch_restful_summary\
]
react-build:
cd stethoscope/ui && npm run build
develop: install-requirements install-editable-package react-build
build-ui: install-node-requirements react-build
develop-ui:
cd stethoscope/ui && npm start
install-develop-ui: install-node-requirements develop-ui
### DOCKER
docker-build-ui:
@echo "--> Building UI code in a Docker container."
docker-compose up node-builder
docker-build: Dockerfile Dockerfile-nginx docker-compose.yml docker-compose.base.yml
docker-compose build
### TOKENS
dev-token-docker:
@echo "--> Generating authentication token for local development using Docker."
echo REACT_APP_TOKEN=$(shell docker-compose run -e STETHOSCOPE_API_INSTANCE_PATH="/code/instance/" login stethoscope-token) > stethoscope/ui/.env
dev-token:
@echo "--> Generating authentication token for local development."
echo REACT_APP_TOKEN=$(shell stethoscope-token) > stethoscope/ui/.env
### LINT
lint-py:
@echo "--> Linting Python files."
tox -e lint
lint-js:
@echo "--> Linting JavaScript files."
cd stethoscope/ui && npm run lint
lint: lint-py lint-js
### TEST
test-py: clean-py
@echo "--> Running Python tests (see test.log for output)."
py.test | tee test.log # settings in pytest.ini
test-js-watch:
@echo "--> Running JavaScript tests."
cd stethoscope/ui && npm run test
test-js:
@echo "--> Running JavaScript tests."
cd stethoscope/ui && CI=true npm run test
test: test-py test-js
tox: clean-py
@echo "--> Running tox."
if which detox; then detox; else tox; fi
coverage-py: clean-py
@echo "--> Running Python tests with coverage (see test.log and htmlcov/ for output)."
py.test --cov-report html --cov=stethoscope | tee test.log # settings in pytest.ini
### CLEAN
clean-py:
@echo "--> Removing Python bytecode files."
find . -name '__pycache__' -delete # Python 3
find . -name '*.py[co]' -delete # Python 2
clean-js:
@echo "--> Removing JavaScript build output."
rm -rf stethoscope/ui/build
clean-static:
@echo "--> Removing generated static content."
rm -rf stethoscope/static && rm -f stethoscope/login/templates/layout.html
clean: clean-py clean-js clean-static
### DISTCLEAN
distclean-py: clean-py
@echo "--> Removing egg-info directory."
rm -rf Stethoscope.egg-info
distclean-js: clean-js
@echo "--> Removing node modules."
rm -rf stethoscope/ui/node_modules
distclean: distclean-py distclean-js clean-static
### PHONY
.PHONY: \
check-root \
install-python-requirements \
install-node-requirements \
install-requirements \
install-editable-package \
develop \
install-develop-ui \
build-ui \
docker-build-ui \
develop-ui \
docker-build \
react-build \
dev-token-docker \
dev-token \
lint \
lint-py \
lint-js \
test \
test-py \
test-js-watch \
test-js \
tox \
coverage-py \
clean-py \
clean-js \
clean-static \
clean \
distclean-py \
distclean-js \
distclean