forked from CiscoTestAutomation/genieparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
249 lines (219 loc) · 7.85 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
################################################################################
# #
# Cisco Systems Proprietary Software #
# Not to be distributed without consent from Test Technology #
# Cisco Systems, Inc. #
# #
################################################################################
# genie.libs.parser Internal Makefile
#
# Author:
#
# Support:
#
# Version:
# v21.8
#
# Date:
# August 2021
#
# About This File:
# This script will build the genie.libs.parser package for
# distribution in PyPI server
#
# Requirements:
# 1. Module name is the same as package name.
# 2. setup.py file is stored within the module folder
################################################################################
# Variables
PKG_NAME = genie.libs.parser
BUILD_DIR = $(shell pwd)/__build__
DIST_DIR = $(BUILD_DIR)/dist
PYTHON = python3
TESTCMD = runAll --path=$(shell pwd)/tests
TESTFLD = pyats run job folder_parsing_job.py --no-mail
TESTDEVAT = pyats run job folder_parsing_job.py -e ${BINOS_ROOT}/atests/cisco/pyats/libs/genie/external_parser --no-mail
BUILD_CMD = $(PYTHON) setup.py bdist_wheel --dist-dir=$(DIST_DIR)
PYPIREPO = pypitest
PYLINT_CMD = pylintAll
CYTHON_CMD = compileAll
INDEX_URL = https://pyats-pypi.cisco.com/simple
TRUSTED_HOST = pyats-pypi.cisco.com
# Development pkg requirements
RELATED_PKGS = genie.libs.parser
# aiohttp requires charset-normalizer<3.0.0
DEPENDENCIES = xmltodict requests charset-normalizer==2.1.1
ifeq ($(MAKECMDGOALS), devnet)
BUILD_CMD += --devnet
endif
.PHONY: clean package distribute develop undevelop help devnet\
docs test install_build_deps uninstall_build_deps distribute_staging\
distribute_staging_external
help:
@echo "Please use 'make <target>' where <target> is one of"
@echo ""
@echo "package Build the package"
@echo "test Test the package"
@echo "distribute Distribute the package to internal Cisco PyPi server"
@echo "distribute_staging Distribute build pkgs to staging area"
@echo "distribute_staging_external Distribute build pkgs to external staging area"
@echo "clean Remove build artifacts"
@echo "develop Build and install development package"
@echo "undevelop Uninstall development package"
@echo "docs Build Sphinx documentation for this package"
@echo "devnet Build DevNet package."
@echo "install_build_deps install pyats-distutils"
@echo "uninstall_build_deps Remove pyats-distutils"
@echo "compile Compile all python modules to c"
@echo "coverage_all Run code coverage on all test files"
@echo "pylint_all Run python linter on all python modules"
@echo "json Build json files"
@echo "changelogs Build compiled changelog file"
@echo ""
@echo " --- build arguments ---"
@echo " DEVNET=true build for devnet style (cythonized, no ut)"
compile:
@echo ""
@echo "Compiling to C code"
@echo --------------------------
@pip install --index-url=$(INDEX_URL) --trusted-host $(TRUSTED_HOST) cisco-distutils --upgrade || true
$(CYTHON_CMD)
@echo "Done Compiling"
@echo ""
@echo "Done."
@echo ""
coverage_all:
@echo ""
@echo "Running Code coverage on all unittests"
@echo ---------------------------------------
@$(TESTCMD) --path tests/ --coverage --no-refresh
@echo ""
@echo "Done."
@echo ""
pylint_all:
@echo ""
@echo "Running Pylint on all modules"
@echo "-----------------------------"
@$(PYLINT_CMD)
@echo "Done linting"
@echo ""
@echo "Done."
@echo ""
devnet: package
@echo "Completed building DevNet packages"
@echo ""
install_build_deps:
@pip install --upgrade pip setuptools wheel
uninstall_build_deps:
@echo "Nothing to do"
docs:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "No documentation for $(PKG_NAME)"
@echo ""
test:
@pip install --index-url=$(INDEX_URL) --trusted-host $(TRUSTED_HOST) cisco-distutils --upgrade || true
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Unittests runs"
@if [ -d "${BINOS_ROOT}/atests/cisco/pyats/libs/genie/external_parser" ]; then \
$(TESTCMD) && cd tests && $(TESTFLD) && cd ${BINOS_ROOT}/atests/cisco/pyats/libs/genie/external_parser/tests && $(TESTDEVAT); \
else \
$(TESTCMD) && cd tests && $(TESTFLD); \
fi
package:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Building $(PKG_NAME) distributable: $@"
@echo ""
$(BUILD_CMD)
@echo ""
@echo "Completed building: $@"
@echo ""
@echo "Done."
@echo ""
develop:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Building and installing $(PKG_NAME) development distributable: $@"
@echo ""
@pip uninstall -y $(RELATED_PKGS) || true
@pip install $(DEPENDENCIES)
@$(PYTHON) setup.py develop --no-deps
@echo ""
@echo "Completed building and installing: $@"
@echo ""
@echo "Done."
@echo ""
undevelop:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Uninstalling $(PKG_NAME) development distributable: $@"
@echo ""
@$(PYTHON) setup.py develop --no-deps -q --uninstall
@echo ""
@echo "Completed uninstalling: $@"
@echo ""
@echo "Done."
@echo ""
clean:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Removing make directory: $(BUILD_DIR)"
@rm -rf $(BUILD_DIR) $(DIST_DIR)
@echo ""
@echo "Removing build artifacts ..."
@$(PYTHON) setup.py clean
@echo ""
@echo "Done."
@echo ""
distribute:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(PROD_PKGS)"
@test -d $(DIST_DIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@ssh -q $(PROD_USER) 'test -e $(PROD_PKGS)/$(PKG_NAME) || mkdir $(PROD_PKGS)/$(PKG_NAME)'
@scp $(DIST_DIR)/* $(PROD_USER):$(PROD_PKGS)/$(PKG_NAME)/
@echo ""
@echo "Done."
@echo ""
distribute_staging:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(STAGING_PKGS)"
@test -d $(DIST_DIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@ssh -q $(PROD_USER) 'test -e $(STAGING_PKGS)/$(PKG_NAME) || mkdir $(STAGING_PKGS)/$(PKG_NAME)'
@scp $(DIST_DIR)/* $(PROD_USER):$(STAGING_PKGS)/$(PKG_NAME)/
@echo ""
@echo "Done."
@echo ""
distribute_staging_external:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(STAGING_EXT_PKGS)"
@test -d $(DIST_DIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@ssh -q $(PROD_USER) 'test -e $(STAGING_EXT_PKGS)/$(PKG_NAME) || mkdir $(STAGING_EXT_PKGS)/$(PKG_NAME)'
@scp $(DIST_DIR)/* $(PROD_USER):$(STAGING_EXT_PKGS)/$(PKG_NAME)/
@echo ""
@echo "Done."
@echo ""
json:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Generating Parser json file"
@echo ""
@$(PYTHON) -c "from genie.json.make_json import make_genieparser; make_genieparser()"
@echo ""
@echo "Done."
@echo ""
changelogs:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Generating changelog file"
@echo ""
@$(PYTHON) -c "from ciscodistutils.make_changelog import main; main('./changelog/undistributed', './changelog/undistributed.rst')"
@echo ""
@echo "Done."
@echo ""