blob: 9ba28b0e14e5a6e1da6aa20a63b16a12425c21d0 [file] [log] [blame]
Joey Armstrong6b58fd42023-04-12 17:45:53 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
3# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
4#
5# Licensed under the Apache License, Version 2.0 (the "License")
6# 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
18$(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)
27
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
36## -----------------------------------------------------------------------
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
46
47## -----------------------------------------------------------------------
48## Intent: exhaustive robot syntax checking
49## -----------------------------------------------------------------------
50lint-robot-all:
51 $(HIDE)$(MAKE) --no-print-directory rflint-install
52
53 $(activate)\
54 && find . \( -iname '*.robot' \) -print0 \
55 | $(xargs-n1) rflint $(LINT_ARGS)
56
57## -----------------------------------------------------------------------
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
64
65 $(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## -----------------------------------------------------------------------
85help::
86 @echo ' lint-robot Syntax check python using the robot command'
87
88help-verbose += help-lint-robot-verbose
89help-lint-robot-verbose:
90 @echo ' $(MAKE) lint-robot ROBOT_FILES=...'
91 @echo ' lint-robot-all robot checking: exhaustive'
92 @echo ' lint-robot-modified robot checking: only modified'
93
94$(if $(DEBUG),$(warning LEAVE))
95
96# [EOF]