Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 3 | # Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 4 | # |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 5 | # Licensed under the Apache License, Version 2.0 (the "License") |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 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 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 18 | $(if $(DEBUG),$(warning ENTER)) |
| 19 | |
| 20 | ##-------------------## |
| 21 | ##---] GLOBALS [---## |
| 22 | ##-------------------## |
| 23 | .PHONY: lint-robot lint-robot-all lint-robot-modified |
| 24 | |
| 25 | have-robot-files := $(if $(ROBOT_FILES),true) |
| 26 | ROBOT_FILES ?= $(error ROBOT_FILES= required) |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 27 | |
| 28 | LINT_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 Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 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 | ## ----------------------------------------------------------------------- |
| 42 | ifndef NO-LINT-ROBOT |
| 43 | lint-robot-mode := $(if $(have-robot-files),modified,all) |
| 44 | lint : lint-robot-$(lint-robot-mode) |
| 45 | endif# NO-LINT-ROBOT |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 46 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 47 | ## ----------------------------------------------------------------------- |
| 48 | ## Intent: exhaustive robot syntax checking |
| 49 | ## ----------------------------------------------------------------------- |
| 50 | lint-robot-all: |
| 51 | $(HIDE)$(MAKE) --no-print-directory rflint-install |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 52 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 53 | $(activate)\ |
| 54 | && find . \( -iname '*.robot' \) -print0 \ |
| 55 | | $(xargs-n1) rflint $(LINT_ARGS) |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 56 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 57 | ## ----------------------------------------------------------------------- |
| 58 | ## Intent: check deps for format and python3 cleanliness |
| 59 | ## Note: |
| 60 | ## robot --py3k option no longer supported |
| 61 | ## ----------------------------------------------------------------------- |
| 62 | lint-robot-modified: $(venv-activate-script) |
| 63 | $(HIDE)$(MAKE) --no-print-directory rflint-install |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 64 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 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 | ## ----------------------------------------------------------------------- |
| 72 | rflint-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 Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 85 | help:: |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 86 | @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 Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 93 | |
| 94 | # [EOF] |