-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
96 lines (77 loc) · 2.92 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Copyright (c) 2019-2021 Sine Nomine Associates
.PHONY: help init lint test doc docs preview build install clean distclean \
pylint test-plugins test-roles test-playbooks reset
PYTHON ?= /usr/bin/python3.12
VERSION := $(shell $(PYTHON) version.py)
UPDATE := --force --pre
PYFILES := plugins/*/*.py tests/*/*.py tests/*/*/*.py
ACPATH := $(realpath $(CURDIR)/../../..)
EXTRACT := ANSIBLE_COLLECTIONS_PATHS=$(ACPATH) ansible-doc-extractor
ifdef VIRTUAL_ENV
VENV =
else
VENV = . .venv/bin/activate;
endif
help:
@echo "usage: make <target>"
@echo "targets:"
@echo " init install virtualenv"
@echo " lint run lint checks"
@echo " test run unit and molecule tests"
@echo " doc generate documentation"
@echo " build build openafs collection"
@echo " install install openafs collection"
@echo " reset reset molecule temporary directories"
@echo " clean remove generated files"
@echo " distclean remove generated files and virtualenv"
.venv/bin/activate: requirements.txt
test -d .venv || $(PYTHON) -m venv .venv
.venv/bin/pip install -U pip wheel
.venv/bin/pip install -U -r requirements.txt
touch .venv/bin/activate
init: .venv/bin/activate
doc docs:
mkdir -p docs/source/modules docs/source/plugins/lookup
$(VENV) $(EXTRACT) docs/source/modules plugins/modules/[!_]*.py
$(VENV) $(EXTRACT) docs/source/plugins/lookup plugins/lookup/[!_]*.py
$(VENV) $(MAKE) -C docs html
preview: docs
xdg-open docs/build/html/index.html
builds/openafs_contrib-openafs-$(VERSION).tar.gz:
sed -i -e 's/^version: .*/version: $(VERSION)/' galaxy.yml
mkdir -p builds
$(VENV) ansible-galaxy collection build --output-path builds .
sed -e "s|@BUILD@|$(CURDIR)/$@|" collections.yml.in > builds/collections.yml
build: builds/openafs_contrib-openafs-$(VERSION).tar.gz
install: build
$(VENV) ansible-galaxy collection install $(UPDATE) builds/openafs_contrib-openafs-$(VERSION).tar.gz
pylint:
$(VENV) pyflakes $(PYFILES)
$(VENV) flake8 $(PYFILES)
lint: pylint
$(VENV) $(MAKE) -C roles/openafs_krbserver lint
$(VENV) $(MAKE) -C roles/openafs_krbclient lint
$(VENV) $(MAKE) -C roles/openafs_common lint
$(VENV) $(MAKE) -C roles/openafs_devel lint
$(VENV) $(MAKE) -C roles/openafs_server lint
$(VENV) $(MAKE) -C roles/openafs_client lint
test: test-plugins test-roles test-playbooks
test-plugins:
$(VENV) $(MAKE) -C tests test
test-roles:
$(VENV) $(MAKE) -C roles/openafs_krbserver test
$(VENV) $(MAKE) -C roles/openafs_krbclient test
$(VENV) $(MAKE) -C roles/openafs_common test
$(VENV) $(MAKE) -C roles/openafs_devel test
$(VENV) $(MAKE) -C roles/openafs_server test
$(VENV) $(MAKE) -C roles/openafs_client test
test-playbooks:
$(VENV) $(MAKE) -C tests/playbooks test
reset:
for r in roles/*; do $(VENV) $(MAKE) -C $$r reset; done
$(VENV) $(MAKE) -C tests/playbooks reset
clean:
rm -rf builds docs/build
rm -rf */*/__pycache__ */*/.pytest_cache */*/.cache
distclean: clean
rm -rf .venv