blob: fa8175c840e07143919e1988b86cf224a7bb48b0 [file] [log] [blame]
Joey Armstrong36592e32022-11-28 09:00:28 -05001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrong4de98b72023-02-09 14:51:38 -05003# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstrong36592e32022-11-28 09:00:28 -05004#
Joey Armstrong4de98b72023-02-09 14:51:38 -05005# Licensed under the Apache License, Version 2.0 (the "License")
Joey Armstrong36592e32022-11-28 09:00:28 -05006# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# -----------------------------------------------------------------------
17
Joey Armstrong4de98b72023-02-09 14:51:38 -050018$(if $(DEBUG),$(warning ENTER))
19
20##-------------------##
21##---] GLOBALS [---##
22##-------------------##
23.PHONY: lint-robot lint-robot-all lint-robot-modified
24
25have-robot-files := $(if $(ROBOT_FILES),true)
26ROBOT_FILES ?= $(error ROBOT_FILES= required)
Joey Armstrong36592e32022-11-28 09:00:28 -050027
28LINT_ARGS ?= --verbose --configure LineTooLong:130 -e LineTooLong \
29 --configure TooManyTestSteps:65 -e TooManyTestSteps \
30 --configure TooManyTestCases:50 -e TooManyTestCases \
31 --configure TooFewTestSteps:1 \
32 --configure TooFewKeywordSteps:1 \
33 --configure FileTooLong:2000 -e FileTooLong \
34 -e TrailingWhitespace
35
Joey Armstrong4de98b72023-02-09 14:51:38 -050036## -----------------------------------------------------------------------
37## Intent: Use the robot command to perform syntax checking.
38## % make lint
39## % make lint-robot-all
40## % make lint-robot-modified
41## -----------------------------------------------------------------------
42ifndef NO-LINT-ROBOT
43 lint-robot-mode := $(if $(have-robot-files),modified,all)
44 lint : lint-robot-$(lint-robot-mode)
45endif# NO-LINT-ROBOT
Joey Armstrong36592e32022-11-28 09:00:28 -050046
Joey Armstrong4de98b72023-02-09 14:51:38 -050047## -----------------------------------------------------------------------
48## Intent: exhaustive robot syntax checking
49## -----------------------------------------------------------------------
50lint-robot-all:
51 $(HIDE)$(MAKE) --no-print-directory rflint-install
Joey Armstrong36592e32022-11-28 09:00:28 -050052
Joey Armstrong4de98b72023-02-09 14:51:38 -050053 $(activate)\
54 && find . \( -iname '*.robot' \) -print0 \
55 | $(xargs-n1) rflint $(LINT_ARGS)
Joey Armstrong36592e32022-11-28 09:00:28 -050056
Joey Armstrong4de98b72023-02-09 14:51:38 -050057## -----------------------------------------------------------------------
58## Intent: check deps for format and python3 cleanliness
59## Note:
60## robot --py3k option no longer supported
61## -----------------------------------------------------------------------
62lint-robot-modified: $(venv-activate-script)
63 $(HIDE)$(MAKE) --no-print-directory rflint-install
Joey Armstrong36592e32022-11-28 09:00:28 -050064
Joey Armstrong4de98b72023-02-09 14:51:38 -050065 $(activate) && rflint $(LINT_ARGS) $(ROBOT_FILES)
66
67## -----------------------------------------------------------------------
68## Intent: Install the rflint command for syntax checking.
69## Note: requirements.txt pip install not used here ATM due to implicit
70## per-repository dependency config to enable checking.
71## -----------------------------------------------------------------------
72rflint-install: $(venv-activate-script)
73 @echo
74 @echo "** -----------------------------------------------------------------------"
75 @echo "** robot syntax checking"
76 @echo "** -----------------------------------------------------------------------"
77 $(activate)\
78 && pip install --upgrade robotframework-lint
79 $(activate) && rflint --version
80 @echo
81
82## -----------------------------------------------------------------------
83## Intent: Display command usage
84## -----------------------------------------------------------------------
Joey Armstrong36592e32022-11-28 09:00:28 -050085help::
Joey Armstrong4de98b72023-02-09 14:51:38 -050086 @echo ' lint-robot Syntax check python using the robot command'
87 ifdef VERBOSE
88 @echo ' lint-robot-all robot checking: exhaustive'
89 @echo ' lint-robot-modified robot checking: only modified'
90 endif
91
92$(if $(DEBUG),$(warning LEAVE))
Joey Armstrong36592e32022-11-28 09:00:28 -050093
94# [EOF]