-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
158 lines (117 loc) · 4.71 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
###
# Makefile configuration
###
.DEFAULT_GOAL := help
# We want our output silent by default, use VERBOSE=1 make <command> ...
# to get verbose output.
ifndef VERBOSE
.SILENT:
endif
###
# Define environment variables in the beginning of the file
###
VENV := venv
###
# Define local variables after environment variables
###
setup_deps = setup-dev-requirements
test_deps = setup-dev-requirements
update_test_images := ./tests/update_test_images.py
archlinux_template = tests/templates/Dockerfile.archlinux.jinja2
archlinux_images := tests/images/archlinux/Dockerfile
debian_template = tests/templates/Dockerfile.debian.jinja2
ubuntu_images = $(shell $(VENV)/bin/python $(update_test_images) --list-only --distrib=ubuntu $(TEST_IMAGE_OPTS))
debian_images = $(shell $(VENV)/bin/python $(update_test_images) --list-only --distrib=debian $(TEST_IMAGE_OPTS))
focal_images = $(shell $(VENV)/bin/python $(update_test_images) --list-only --release=focal $(TEST_IMAGE_OPTS))
jammy_images = $(shell $(VENV)/bin/python $(update_test_images) --list-only --release=jammy --no-homebrew $(TEST_IMAGE_OPTS))
bullseye_images = $(shell $(VENV)/bin/python $(update_test_images) --list-only --release=bullseye $(TEST_IMAGE_OPTS))
homebrew_images = $(shell $(VENV)/bin/python $(update_test_images) --list-only --no-git)
###
# This Makefile uses self-documenting help commands
###
.PHONY: help
help: ## print this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort -d | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: all
all: lint test ## run all linting and tests
.PHONY: clean
clean: clean-test-images ## clean generated files
.PHONY: test
test: update-test-images run-tests ## run all tests
.PHONY:
setup: $(setup_deps) ## install development dependencies
.PHONY: setup-dev-requirements
setup-dev-requirements: requirements.dev.txt | $(VENV)/bin/pip-sync
$(VENV)/bin/pip-sync requirements.dev.txt
$(VENV)/bin/python:
python -m venv $(VENV)
$(VENV)/bin/pip-sync $(VENV)/bin/pip-compile: | $(VENV)/bin/python
$(VENV)/bin/pip install pip-tools
$(VENV)/bin/pylint: setup-dev-requirements
$(VENV)/bin/pre-commit: setup-dev-requirements
requirements.dev.txt: requirements.dev.in | $(VENV)/bin/pip-compile
$(VENV)/bin/pip-compile requirements.dev.in --output-file requirements.dev.txt
$(archlinux_images): $(archlinux_template) $(update_test_images) | $(VENV)/bin/python
$(VENV)/bin/python $(update_test_images) --dockerfile=$@
tests/images/%/Dockerfile: $(debian_template) $(update_test_images) | $(VENV)/bin/python
$(VENV)/bin/python $(update_test_images) --dockerfile=$@
.PHONY: test-ubuntu
test-ubuntu: $(test_deps)
$(MAKE) $(ubuntu_images)
./tests/run-tests.sh $(ubuntu_images) $(TEST_RUN_OPTS)
.PHONY: test-focal
test-focal: $(test_deps)
$(MAKE) $(focal_images)
./tests/run-tests.sh $(focal_images) $(TEST_RUN_OPTS)
.PHONY: test-jammy
test-jammy: $(test_deps)
$(MAKE) $(jammy_images)
./tests/run-tests.sh $(jammy_images) $(TEST_RUN_OPTS)
.PHONY: test-debian
test-debian: $(test_deps)
$(MAKE) $(debian_images)
./tests/run-tests.sh $(debian_images) $(TEST_RUN_OPTS)
.PHONY: test-bullseye
test-bullseye: $(test_deps)
$(MAKE) $(bullseye_images)
./tests/run-tests.sh $(bullseye_images) $(TEST_RUN_OPTS)
.PHONY: test-archlinux
test-archlinux: $(test_deps)
$(MAKE) $(archlinux_images)
./tests/run-tests.sh $(archlinux_images) $(TEST_RUN_OPTS)
.PHONY: test-homebrew
test-homebrew: $(test_deps)
$(MAKE) $(homebrew_images)
./tests/run-tests.sh $(homebrew_images)
.PHONY: update-test-images
update-test-images: $(test_deps)
$(VENV)/bin/python ./tests/update_test_images.py $(TEST_IMAGE_OPTS)
.PHONY: run-tests
run-tests:
./tests/run-tests.sh $(TEST_RUN_OPTS)
.PHONY: clean-test-images
clean-test-images:
cd tests && find . -not -path "./templates/*" -name "Dockerfile" -exec rm -f {} \;
cd tests && find . -not -path "./templates/*" -name "install_homebrew.sh" -exec rm -f {} \;
.PHONY: update
update: ## update pyenv and Python versions
./scripts/update-release.sh pyenv
./scripts/update-release.sh pyenv-virtualenv
./scripts/update-python.sh python37
./scripts/update-python.sh python38
./scripts/update-python.sh python39
./scripts/update-python.sh python310
PRE_COMMIT_HOOKS = .git/hooks/pre-commit
PRE_PUSH_HOOKS = .git/hooks/pre-push
COMMIT_MSG_HOOKS = .git/hooks/commit-msg
.PHONY: lint
lint: install-git-hooks | $(VENV)/bin/pre-commit ## lint all files
$(VENV)/bin/pre-commit run -a
.PHONY: install-git-hooks
install-git-hooks: $(PRE_COMMIT_HOOKS) $(PRE_PUSH_HOOKS) $(COMMIT_MSG_HOOKS)
$(PRE_COMMIT_HOOKS):
$(VENV)/bin/pre-commit install --install-hooks
$(PRE_PUSH_HOOKS):
$(VENV)/bin/pre-commit install --install-hooks -t pre-push
$(COMMIT_MSG_HOOKS):
$(VENV)/bin/pre-commit install --install-hooks -t commit-msg