-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
91 lines (61 loc) · 2.53 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
# Licensed under the MIT License
# https://github.com/craigahobbs/python-template/blob/main/LICENSE
MAKEJ ?= -j
.PHONY: help
help:
@echo 'usage: make [changelog|clean|commit|superclean|test]'
.PHONY: commit
commit: test
.PHONY: clean
clean:
rm -rf build/ test-actual/
.PHONY: gh-pages
gh-pages:
.PHONY: superclean
superclean: clean
# Helper to edit files with sed
SED_FILE = if [ -f $(strip $(2)) ]; then sed -E $(strip $(1)) $(strip $(2)) >> $(strip $(2)).tmp && mv $(strip $(2)).tmp $(strip $(2)); fi
# Test rule function - name, template args, *env
define TEST_RULE
test: test-$(strip $(1))
.PHONY: test-$(strip $(1))
test-$(strip $(1)): build/venv.build
@echo 'Testing "$(strip $(1))"...'
rm -rf test-actual/$(strip $(1))/
build/venv/$$(VENV_BIN)/template-specialize template/ test-actual/$(strip $(1))/ $(strip $(2))
$(call SED_FILE, 's/[0-9]{4}(,? John Doe)/YYYY\1/g', test-actual/$(strip $(1))/LICENSE)
$(call SED_FILE, 's/[0-9]{4}(,? John Doe)/YYYY\1/g', test-actual/$(strip $(1))/doc/conf.py)
diff -r test-actual/$(strip $(1))/ test-expected/$(strip $(1))/
PYTHON_BUILD_DIR=../../../python-build $(if $(3),$(strip $(3)) )$$(MAKE) $(MAKEJ) -C test-actual/$(strip $(1))/ commit
rm -rf test-actual/$(strip $(1))/
endef
# Test rules
.PHONY: test
test:
rm -rf test-actual/
@echo Tests completed - all passed
$(eval $(call TEST_RULE, required, \
-k package 'my-package' -k name 'John Doe' -k email 'johndoe@gmail.com' -k github 'johndoe'))
$(eval $(call TEST_RULE, noapi, \
-k package 'my-package' -k name 'John Doe' -k email 'johndoe@gmail.com' -k github 'johndoe' -k noapi 1))
$(eval $(call TEST_RULE, nomain, \
-k package 'my-package' -k name 'John Doe' -k email 'johndoe@gmail.com' -k github 'johndoe' -k nomain 1))
$(eval $(call TEST_RULE, noapi-nomain, \
-k package 'my-package' -k name 'John Doe' -k email 'johndoe@gmail.com' -k github 'johndoe' -k noapi 1 -k nomain 1))
$(eval $(call TEST_RULE, noapi-0-nomain-0, \
-k package 'my-package' -k name 'John Doe' -k email 'johndoe@gmail.com' -k github 'johndoe' -k noapi 0 -k nomain 0, \
UNITTEST_PARALLEL=1))
.PHONY: changelog
changelog: build/venv.build
build/venv/$(VENV_BIN)/simple-git-changelog
build/venv.build:
python3 -m venv --upgrade-deps build/venv
build/venv/$(VENV_BIN)/pip -q install --progress-bar off simple-git-changelog template-specialize
touch $@
# Windows support
VENV_BIN := bin
ifeq '$(OS)' 'Windows_NT'
ifeq ($(shell python3 -c "import sysconfig; print(sysconfig.get_preferred_scheme('user'))"),nt_user)
VENV_BIN := Scripts
endif
endif