blob: c4d8e942a79d58f6bf637761ebb8d5bb8917f083 [file] [log] [blame]
Zack Williamsad45bf02020-03-04 21:37:20 -07001# {{ cookiecutter.role_name }} Makefile
2#
Zack Williamse58b0eb2022-03-19 21:23:49 -07003# SPDX-FileCopyrightText: {{ cookiecutter.year }} {{ cookiecutter.author }} <{{ cookiecutter.email }}>
Zack Williamsad45bf02020-03-04 21:37:20 -07004# SPDX-License-Identifier: {{ cookiecutter.license }}
5
6SHELL = bash -eu -o pipefail
7
8.DEFAULT_GOAL := help
9.PHONY: test lint yamllint ansiblelint license help
10
11test: ## run tests on the playbook with molecule
12 molecule --version
13 molecule test
14
Zack Williamse58b0eb2022-03-19 21:23:49 -070015lint: license yamllint ansiblelint ## run all lint checks
Zack Williamsad45bf02020-03-04 21:37:20 -070016
17# all YAML files
18YAML_FILES ?= $(shell find . -type f \( -name '*.yaml' -o -name '*.yml' \) -print )
19
Zack Williamse58b0eb2022-03-19 21:23:49 -070020license: ## Check license with the reuse tool
21 reuse --version
22 reuse --root . lint
23
Zack Williamsad45bf02020-03-04 21:37:20 -070024yamllint: ## lint check with yamllint
25 yamllint --version
26 yamllint \
27 -d "{extends: default, rules: {line-length: {max: 99}}}" \
28 -s $(YAML_FILES)
29
Zack Williamse58b0eb2022-03-19 21:23:49 -070030# List of molecule files, not including base molecule.yml which isn't ansible format
31MOLECULE_FILES ?= $(shell find molecule -type f -name '*.yml' \! -name 'molecule.yml' -print )
32
Zack Williamsad45bf02020-03-04 21:37:20 -070033ansiblelint: ## lint check with ansible-lint
34 ansible-lint --version
35 ansible-lint -v .
Zack Williamse58b0eb2022-03-19 21:23:49 -070036 ansible-lint -v $(MOLECULE_FILES)
Zack Williamsad45bf02020-03-04 21:37:20 -070037
38help: ## Print help for each target
39 @echo {{ cookiecutter.role_name }} test targets
40 @echo
41 @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
42 | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'