forked from StackStorm/st2docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
254 lines (213 loc) · 8.02 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
SHELL := /bin/bash
TOX_DIR := .tox
VIRTUALENV_DIR ?= virtualenv
ST2_VIRTUALENV_DIR ?= st2/virtualenv
# Sphinx docs options
SPHINXBUILD := sphinx-build
DOC_SOURCE_DIR := docs/source
DOC_BUILD_DIR := docs/build
COMMUNITY_TAG := community
ENTERPRISE_TAG := enterprise
BINARIES := bin
# All components are prefixed by st2
COMPONENTS := $(wildcard st2*)
COMPONENTS_RUNNERS := $(wildcard st2/contrib/runners/*)
# Components that implement a component-controlled test-runner. These components provide an
# in-component Makefile. (Temporary fix until I can generalize the pecan unittest setup. -mar)
# Note: We also want to ignore egg-info dir created during build
COMPONENT_SPECIFIC_TESTS := st2tests st2client.egg-info
# nasty hack to get a space into a variable
space_char :=
space_char +=
comma := ,
COMPONENT_PYTHONPATH = $(subst $(space_char),:,$(realpath $(COMPONENTS)))
PYTHON_TARGET := 2.7
REQUIREMENTS := requirements.txt st2/requirements.txt
PIP_OPTIONS := $(ST2_PIP_OPTIONS)
ifndef PIP_OPTIONS
PIP_OPTIONS := -U -q
endif
.PHONY: all
all: requirements check tests docs
.PHONY: docs
docs: .clone-st2 .clone-orquesta requirements .requirements-st2 .install-runners .docs
PHONY: .docs
.docs: .community-docs
PHONY: .clean-bwc-solutions-folders
.clean-bwc-solutions-folders:
@echo
@echo "==================== Remove solution specific folders ===================="
@echo
rm -Rf docs/source/_static/images/solutions/*
rm -Rf docs/source/_includes/bwc_toc.rst
rm -Rf docs/source/solutions/*
@echo
@echo
.PHONY: .community-docs
.community-docs: .clean-bwc-solutions-folders
@echo
@echo "==================== COMMUNITY DOCS ===================="
@echo
. $(ST2_VIRTUALENV_DIR)/bin/activate; ./scripts/generate-runner-parameters-documentation.py
. $(ST2_VIRTUALENV_DIR)/bin/activate; ./scripts/generate-internal-triggers-table.py
. $(ST2_VIRTUALENV_DIR)/bin/activate; ./scripts/generate-available-permission-types-table.py
@echo
. $(VIRTUALENV_DIR)/bin/activate; $(SPHINXBUILD) -t $(COMMUNITY_TAG) -W -b html $(DOC_SOURCE_DIR) $(DOC_BUILD_DIR)/html
@echo
@echo "Build finished. The HTML pages are in $(DOC_BUILD_DIR)/html."
.PHONY: .enterprise-docs
.enterprise-docs:
@echo
@echo "==================== ENTERPRISE DOCS ===================="
@echo
. $(ST2_VIRTUALENV_DIR)/bin/activate; ./scripts/generate-runner-parameters-documentation.py
. $(ST2_VIRTUALENV_DIR)/bin/activate; ./scripts/generate-internal-triggers-table.py
. $(ST2_VIRTUALENV_DIR)/bin/activate; ./scripts/generate-available-permission-types-table.py
@echo
. $(VIRTUALENV_DIR)/bin/activate; $(SPHINXBUILD) -t $(ENTERPRISE_TAG) -W -b html $(DOC_SOURCE_DIR) $(DOC_BUILD_DIR)/html
@echo
@echo "Build finished. The HTML pages are in $(DOC_BUILD_DIR)/html."
.PHONY: livedocs
livedocs: docs .livedocs
.PHONY: .livedocs
.livedocs:
@echo
@echo "==========================================================="
@echo " RUNNING DOCS"
@echo "==========================================================="
@echo
. $(VIRTUALENV_DIR)/bin/activate; sphinx-autobuild -H 0.0.0.0 -b html $(DOC_SOURCE_DIR) $(DOC_BUILD_DIR)/html
@echo
.PHONY: ewcdocs
ewcdocs: .clone-st2 .clone-orquesta .clone-ipfabric requirements .requirements-st2 .install-runners .ewcdocs
.PHONY: .ewcdocs
.ewcdocs: .patch-solutions .enterprise-docs .git-checkout-local-changes
.PHONY: .patch-solutions
.patch-solutions:
@echo
@echo "=========================================================="
@echo " PATCHING BWC DOCS"
@echo "=========================================================="
@echo
cp -R ipfabric/docs/source/* docs/source/
.PHONY: .git-checkout-local-changes
.git-checkout-local-changes:
@echo
@echo "=========================================================="
@echo " UNPATCHING BWC DOCS"
@echo "=========================================================="
@echo
git checkout docs/source/info.py
git checkout docs/source/_includes/solutions.rst
.PHONY: bwclivedocs
bwclivedocs: ewcdocs .livedocs
.PHONY: bwclocaldocs
bwclocaldocs: .clone-st2 .clone-orquesta requirements .requirements-st2 .ewcdocs .clean-bwc-solutions-folders
.PHONY: bwclocallivedocs
bwclocallivedocs: bwclocaldocs .livedocs
.PHONY: .cleandocs
.cleandocs:
@echo "Removing generated documentation"
rm -rf $(DOC_BUILD_DIR)
.PHONY: distclean
distclean:
@echo
@echo "==================== distclean ===================="
@echo
rm -rf $(VIRTUALENV_DIR)
.PHONY: requirements
requirements: virtualenv
@echo
@echo "==================== st2docs requirements ===================="
@echo
# Make sure we use latest version of pip
$(VIRTUALENV_DIR)/bin/pip install --upgrade "pip>=9.0,<9.1"
# Install requirements
#
for req in $(REQUIREMENTS); do \
echo "Installing $$req..." ; \
$(VIRTUALENV_DIR)/bin/pip install $(PIP_OPTIONS) -r $$req ; \
done
.PHONY: virtualenv
virtualenv: $(VIRTUALENV_DIR)/bin/activate
$(VIRTUALENV_DIR)/bin/activate:
@echo
@echo "==================== st2docs virtualenv ===================="
@echo
test -d $(VIRTUALENV_DIR) || virtualenv --no-site-packages --python=python2.7 $(VIRTUALENV_DIR)
# Setup PYTHONPATH in bash activate script...
echo '' >> $(VIRTUALENV_DIR)/bin/activate
echo '_OLD_PYTHONPATH=$$PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate
echo 'PYTHONPATH=$$_OLD_PYTHONPATH:$(COMPONENT_PYTHONPATH)' >> $(VIRTUALENV_DIR)/bin/activate
echo 'export PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate
touch $(VIRTUALENV_DIR)/bin/activate
# Setup PYTHONPATH in fish activate script...
echo '' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo 'set -gx _OLD_PYTHONPATH $$PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo 'set -gx PYTHONPATH $$_OLD_PYTHONPATH $(COMPONENT_PYTHONPATH)' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo 'functions -c deactivate old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo 'function deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' if test -n $$_OLD_PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' set -gx PYTHONPATH $$_OLD_PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' set -e _OLD_PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' end' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' functions -e old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo 'end' >> $(VIRTUALENV_DIR)/bin/activate.fish
touch $(VIRTUALENV_DIR)/bin/activate.fish
.PHONY: .install-runners
.install-runners:
@echo ""
@echo "================== install runners ===================="
@echo ""
@for component in $(COMPONENTS_RUNNERS); do \
echo "==========================================================="; \
echo "Installing runner:" $$component; \
echo "==========================================================="; \
(. $(ST2_VIRTUALENV_DIR)/bin/activate; cd $$component; python setup.py develop); \
done
.PHONY: .clone-st2
.clone-st2:
@echo
@echo "==================== cloning st2 ===================="
@echo
./scripts/clone-st2.sh
.PHONY: .clone-orquesta
.clone-orquesta:
@echo
@echo "==================== cloning orquesta ===================="
@echo
./scripts/clone-orquesta.sh
.PHONY: .clone-ipfabric
.clone-ipfabric:
@echo
@echo "==================== cloning ipfabric docs ===================="
@echo
./scripts/clone-ipfabric.sh
PHONY: .virtualenv-st2
.virtualenv-st2: .clone-st2
@echo
@echo "==================== st2 virtualenv ===================="
@echo
cd st2; make virtualenv
PHONY: .requirements-st2
.requirements-st2: .clone-st2
@echo
@echo "==================== st2 requirements ===================="
@echo
cd st2; make requirements
.PHONY: docker
docker: docker-build docker-run
PHONY: docker-build
docker-build:
@echo
@echo "==================== Building st2docs Docker ===================="
@echo
docker build -t st2/st2docs -f Dockerfile .
PHONY: docker-run
docker-run:
@echo
@echo "==================== Running st2docs in Docker ===================="
@echo
docker run --rm -it -v ${PWD}/docs/source:/st2docs/docs/source -p 127.0.0.1:8000:8000 st2/st2docs