Joey Armstrong | 9956d97 | 2022-11-11 13:07:31 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 92ac4cf | 2022-12-27 07:39:37 -0500 | [diff] [blame^] | 3 | # Copyright 2023 Open Networking Foundation (ONF) and the ONF Contributors |
| 4 | # Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | # SPDX-FileCopyrightText: 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors |
| 19 | # SPDX-License-Identifier: Apache-2.0 |
| 20 | # ----------------------------------------------------------------------- |
| 21 | |
| 22 | # -*- makefile -*- |
| 23 | # ----------------------------------------------------------------------- |
Joey Armstrong | 9956d97 | 2022-11-11 13:07:31 -0500 | [diff] [blame] | 24 | # Copyright 2017-2022 Open Networking Foundation (ONF) and the ONF Contributors |
Matteo Scandolo | 2da7278 | 2022-06-13 11:30:07 -0700 | [diff] [blame] | 25 | # SPDX-FileCopyrightText: 2022-present Intel Corporation |
| 26 | # |
| 27 | # SPDX-License-Identifier: Apache-2.0 |
Joey Armstrong | 9956d97 | 2022-11-11 13:07:31 -0500 | [diff] [blame] | 28 | # ----------------------------------------------------------------------- |
Matteo Scandolo | 2da7278 | 2022-06-13 11:30:07 -0700 | [diff] [blame] | 29 | |
Joey Armstrong | 9956d97 | 2022-11-11 13:07:31 -0500 | [diff] [blame] | 30 | .DEFAULT_GOAL := test |
Matteo Scandolo | 2da7278 | 2022-06-13 11:30:07 -0700 | [diff] [blame] | 31 | |
Joey Armstrong | 9956d97 | 2022-11-11 13:07:31 -0500 | [diff] [blame] | 32 | dot ?= . |
| 33 | TOP ?= $(dot) |
| 34 | MAKEDIR ?= $(TOP)/makefiles |
| 35 | |
Joey Armstrong | 9956d97 | 2022-11-11 13:07:31 -0500 | [diff] [blame] | 36 | jq = $(env-clean) jq |
| 37 | jq-args += --exit-status |
| 38 | |
| 39 | YAMLLINT = $(shell which yamllint) |
| 40 | yamllint := $(env-clean) $(YAMLLINT) |
| 41 | yamllint-args := -c .yamllint |
| 42 | |
Joey Armstrong | 92ac4cf | 2022-12-27 07:39:37 -0500 | [diff] [blame^] | 43 | ##--------------------## |
| 44 | ##---] INCLUDES [---## |
| 45 | ##--------------------## |
| 46 | include $(MAKEDIR)/include.mk |
| 47 | |
Joey Armstrong | 9956d97 | 2022-11-11 13:07:31 -0500 | [diff] [blame] | 48 | ##-------------------## |
| 49 | ##---] TARGETS [---## |
| 50 | ##-------------------## |
| 51 | all: |
| 52 | |
| 53 | lint += lint-json |
| 54 | lint += lint-yaml |
| 55 | |
| 56 | lint : $(lint) |
| 57 | test : lint |
| 58 | |
| 59 | ## ----------------------------------------------------------------------- |
| 60 | ## ----------------------------------------------------------------------- |
| 61 | lint-yaml yaml-lint: |
| 62 | ifeq ($(null),$(shell which yamllint)) |
Matteo Scandolo | 2da7278 | 2022-06-13 11:30:07 -0700 | [diff] [blame] | 63 | $(error "Please install yamllint to run linting") |
| 64 | endif |
Joey Armstrong | 9956d97 | 2022-11-11 13:07:31 -0500 | [diff] [blame] | 65 | $(HIDE)$(env-clean) find . -name '*.yaml' -type f -print0 \ |
| 66 | | xargs -0 -t -n1 $(yamllint) $(yamllint-args) |
| 67 | |
| 68 | ## ----------------------------------------------------------------------- |
| 69 | ## ----------------------------------------------------------------------- |
| 70 | lint-json: |
| 71 | $(HIDE)$(env-clean) find . -name '*.json' -type f -print0 \ |
| 72 | | xargs -0 -t -n1 $(jq) $(jq-args) $(dot) >/dev/null |
| 73 | |
| 74 | ## ----------------------------------------------------------------------- |
| 75 | ## ----------------------------------------------------------------------- |
| 76 | pre-check: |
| 77 | @echo "[REQUIRED] Checking for linting tools" |
| 78 | $(HIDE)which jq |
| 79 | $(HIDE)which yamllint |
| 80 | @echo |
| 81 | |
| 82 | ## ----------------------------------------------------------------------- |
| 83 | ## ----------------------------------------------------------------------- |
Joey Armstrong | ffd93d2 | 2022-12-02 09:37:18 -0500 | [diff] [blame] | 84 | .PHONY: pre-commit |
| 85 | .PHONY: fixperms |
| 86 | pre-commit: lint fixperms |
| 87 | |
| 88 | ## ----------------------------------------------------------------------- |
| 89 | ## Scrub volume messages from jenksins logs and help secure nodes. |
| 90 | ## WARNING: Kubernetes configuration file is group-readable. This is insecure |
| 91 | ## ----------------------------------------------------------------------- |
| 92 | fixperms-args :=$(null) |
| 93 | fixperms-args += -name '*.conf' |
| 94 | fixperms-args += -o -name '*.json' |
| 95 | fixperms-args += -o -name '*.yaml' |
| 96 | fixperms: |
| 97 | $(HIDE)find . \( $(fixperms-args) \) -print0 \ |
| 98 | | xargs -0 chmod og-rwx |
| 99 | |
| 100 | ## ----------------------------------------------------------------------- |
| 101 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 9956d97 | 2022-11-11 13:07:31 -0500 | [diff] [blame] | 102 | clean: |
| 103 | |
| 104 | ## ----------------------------------------------------------------------- |
| 105 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 92ac4cf | 2022-12-27 07:39:37 -0500 | [diff] [blame^] | 106 | help:: |
Joey Armstrong | 9956d97 | 2022-11-11 13:07:31 -0500 | [diff] [blame] | 107 | @echo |
| 108 | @echo "USAGE: $(MAKE)" |
| 109 | @echo " lint perform syntax checks on source" |
| 110 | @echo " test perform syntax checks on source" |
| 111 | @echo " pre-check Verify tools and deps are available for testing" |
| 112 | @echo |
| 113 | @echo "[LINT]" |
| 114 | @echo " lint-json Syntax check .json sources" |
| 115 | @echo " lint-yaml Syntax check .yaml sources" |
| 116 | @echo |
Joey Armstrong | ffd93d2 | 2022-12-02 09:37:18 -0500 | [diff] [blame] | 117 | @echo "[PRE:check]" |
| 118 | @echo " pre-check Verify tools and deps are available for testing" |
| 119 | @echo |
| 120 | @echo "[PRE:commit]" |
| 121 | @echo " pre-commit Perform common repairs on source" |
| 122 | @echo " fixperms Remove group write permission on config files" |
| 123 | @echo |
Joey Armstrong | 92ac4cf | 2022-12-27 07:39:37 -0500 | [diff] [blame^] | 124 | |
Joey Armstrong | 9956d97 | 2022-11-11 13:07:31 -0500 | [diff] [blame] | 125 | # [EOF] |