-
Notifications
You must be signed in to change notification settings - Fork 335
Expand file tree
/
Copy pathMakefile
More file actions
245 lines (199 loc) · 6.2 KB
/
Makefile
File metadata and controls
245 lines (199 loc) · 6.2 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
MAKEFLAGS += -j2
OS := $(shell uname;)
SELINUXOPT ?= $(shell test -x /usr/sbin/selinuxenabled && selinuxenabled && echo -Z)
PREFIX ?= /usr/local
BINDIR ?= ${PREFIX}/bin
SHAREDIR ?= ${PREFIX}/share
PYTHON ?= $(shell command -v python3 python|head -n1)
DESTDIR ?= /
PATH := $(PATH):$(HOME)/.local/bin
MYPIP ?= pip
IMAGE ?= ramalama
PROJECT_DIR ?= $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
EXCLUDE_DIRS ?= .venv venv .tox build
EXCLUDE_OPTS ?= $(addprefix --exclude-dir=,$(EXCLUDE_DIRS))
PYTHON_SCRIPTS ?= $(shell grep -lEr "^\#\!\s*/usr/bin/(env +)?python(3)?(\s|$$)" $(EXCLUDE_OPTS) $(PROJECT_DIR) || true)
RUFF_TARGETS ?= ramalama scripts test bin/ramalama
E2E_IMAGE ?= localhost/e2e:latest
default: help
help:
@echo "Build Container Image"
@echo
@echo " - make build"
@echo " - make build IMAGE=ramalama"
@echo " - make multi-arch"
@echo " - make multi-arch IMAGE=ramalama"
@echo " Build using build cache, for development only"
@echo " - make build IMAGE=ramalama CACHE=-C"
@echo
@echo "Build docs"
@echo
@echo " - make docs"
@echo
@echo "Install ramalama"
@echo
@echo " - make install"
@echo
@echo "Test ramalama"
@echo
@echo " - make test"
@echo
@echo "Clean the repository"
@echo
@echo " - make clean"
@echo
.PHONY: install-uv
install-uv:
./install-uv.sh
.PHONY: install-requirements
install-requirements:
${MYPIP} install ".[dev]"
.PHONY: install-completions
install-completions: completions
install ${SELINUXOPT} -d -m 755 $(DESTDIR)${SHAREDIR}/bash-completion/completions
install ${SELINUXOPT} -m 644 completions/bash-completion/completions/ramalama \
$(DESTDIR)${SHAREDIR}/bash-completion/completions/ramalama
install ${SELINUXOPT} -d -m 755 $(DESTDIR)${SHAREDIR}/fish/vendor_completions.d
install ${SELINUXOPT} -m 644 completions/fish/vendor_completions.d/ramalama.fish \
$(DESTDIR)${SHAREDIR}/fish/vendor_completions.d/ramalama.fish
install ${SELINUXOPT} -d -m 755 $(DESTDIR)${SHAREDIR}/zsh/site-functions
install ${SELINUXOPT} -m 644 completions/zsh/site-functions/_ramalama \
$(DESTDIR)${SHAREDIR}/zsh/site-functions/_ramalama
.PHONY: install-shortnames
install-shortnames:
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(SHAREDIR)/ramalama
install ${SELINUXOPT} -m 644 shortnames/shortnames.conf \
$(DESTDIR)$(SHAREDIR)/ramalama
.PHONY: completions
completions:
mkdir -p completions/bash-completion/completions
register-python-argcomplete --shell bash ramalama > completions/bash-completion/completions/ramalama
mkdir -p completions/fish/vendor_completions.d
register-python-argcomplete --shell fish ramalama > completions/fish/vendor_completions.d/ramalama.fish
mkdir -p completions/zsh/site-functions
-register-python-argcomplete --shell zsh ramalama > completions/zsh/site-functions/_ramalama
.PHONY: install
install: docs completions
RAMALAMA_VERSION=$(RAMALAMA_VERSION) \
${MYPIP} install . --no-deps --root $(DESTDIR) --prefix ${PREFIX}
.PHONY: build
build:
./container_build.sh ${CACHE} build $(IMAGE) -v "$(VERSION)"
.PHONY: build-rm
build-rm:
./container_build.sh ${CACHE} -r build $(IMAGE) -v "$(VERSION)"
.PHONY: build_multi_arch
build_multi_arch:
./container_build.sh ${CACHE} multi-arch $(IMAGE) -v "$(VERSION)"
.PHONY: install-docs
install-docs: docs
make -C docs install
.PHONY: docs docs-manpages docsite-docs
docs: docs-manpages docsite-docs
docs-manpages:
$(MAKE) -C docs
# Preprocess *.md.in into *.md only (no go-md2man). Used by man-check in CI.
.PHONY: docs-manpages-md
docs-manpages-md:
$(MAKE) -C docs manpages-md
docsite-docs:
$(MAKE) -C docsite convert
.PHONY: lint
lint:
! git grep -n -- '#!/usr/bin/python3' -- ':!Makefile'
ruff check $(RUFF_TARGETS)
shellcheck *.sh */*.sh */*/*.sh
.PHONY: check-format
check-format:
ruff check --select I $(RUFF_TARGETS)
ruff format --check $(RUFF_TARGETS)
.PHONY: format
format:
ruff check --select I --fix $(RUFF_TARGETS)
ruff format $(RUFF_TARGETS)
.PHONY: codespell
codespell:
codespell $(PROJECT_DIR) $(PYTHON_SCRIPTS)
.PHONY: man-check
man-check: docs-manpages-md
ifeq ($(OS),Linux)
hack/man-page-checker
hack/xref-helpmsgs-manpages
endif
.PHONY: type-check
type-check:
mypy --check-untyped-defs $(addprefix --exclude=,$(EXCLUDE_DIRS)) --exclude test $(PROJECT_DIR)
.PHONY: validate
validate: codespell lint check-format man-check type-check
.PHONY: pypi-build
pypi-build: clean
make docs
python3 -m build --sdist
python3 -m build --wheel
.PHONY: pypi
pypi: pypi-build
python3 -m twine upload dist/*
.PHONY: e2e-image
e2e-image:
podman inspect $(E2E_IMAGE) &> /dev/null || \
podman build -t $(E2E_IMAGE) -f container-images/e2e/Containerfile .
e2e-tests-in-container slow-tests-in-container: extra-opts = --security-opt unmask=/proc/* --device /dev/net/tun
%-in-container: e2e-image
podman run --rm \
--userns=keep-id:size=200000 \
--security-opt label=disable \
--security-opt=mask=/sys/bus/pci/drivers/i915 \
$(extra-opts) \
-v /tmp \
-v $(CURDIR):/src \
$(E2E_IMAGE) make $*
.PHONY: ci
ci:
test/ci.sh
.PHONY: requires-tox
requires-tox:
@command -v tox >/dev/null 2>&1 || ${MYPIP} install tox
.PHONY: unit-tests
unit-tests: requires-tox
tox
.PHONY: unit-tests-verbose
unit-tests-verbose: requires-tox
tox -- --full-trace --capture=tee-sys
.PHONY: cov-tests
cov-tests: requires-tox
tox -- --cov
.PHONY: detailed-cov-tests
detailed-cov-tests: requires-tox
tox -e coverage
.PHONY: e2e-tests
e2e-tests: requires-tox
tox -q -e e2e
.PHONY: e2e-tests-nocontainer
e2e-tests-nocontainer: requires-tox
tox -q -e e2e -- --no-container
.PHONY: e2e-tests-docker
e2e-tests-docker: requires-tox
tox -q -e e2e -- --container-engine=docker
.PHONY: slow-tests
slow-tests: requires-tox
tox -q -e slow
.PHONY: slow-tests-docker
slow-tests-docker: requires-tox
tox -q -e slow -- --container-engine=docker
.PHONY: end-to-end-tests
end-to-end-tests: validate e2e-tests e2e-tests-nocontainer slow-tests ci
make clean
hack/tree_status.sh
.PHONY: test
test: tests
.PHONY: tests
tests: unit-tests end-to-end-tests
.PHONY: rag-requirements
rag-requirements:
touch container-images/common/*.in
make -C container-images/common tools-requirements requirements-rag.txt
.PHONY: clean
clean:
make -C docs clean
make -C docsite clean clean-generated
find . -depth -print0 | git check-ignore --stdin -z | xargs -0 rm -rf