-
Notifications
You must be signed in to change notification settings - Fork 46
/
Makefile
145 lines (120 loc) · 3.73 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
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
default: help
help:
@echo "Build Container"
@echo
@echo " - make build"
@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-requirements
install-requirements:
pipx install tqdm black flake8 argcomplete wheel omlmd huggingface_hub codespell
.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
install ${SELINUXOPT} -m 644 completions/zsh/vendor-completions/_ramalama \
$(DESTDIR)${SHAREDIR}/zsh/vendor-completions/_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/vendor-completions
-register-python-argcomplete --shell zsh ramalama > completions/zsh/vendor-completions/_ramalama
.PHONY: install
install: docs completions
RAMALAMA_VERSION=$(RAMALAMA_VERSION) \
pip install . --no-deps --root $(DESTDIR) --prefix ${PREFIX}
.PHONY: build
build:
ifeq ($(OS),Linux)
./container_build.sh $(IMAGE)
endif
.PHONY: install-docs
install-docs: docs
make -C docs install
.PHONY: docs
docs:
make -C docs
.PHONY: lint
lint:
black --line-length 120 --exclude 'venv/*' *.py ramalama/*.py # Format the code
flake8 --max-line-length=120 --exclude=venv *.py ramalama/*.py # Check for any inconsistencies
.PHONY: codespell
codespell:
codespell --dictionary=- -w
.PHONY: test-run
test-run:
_RAMALAMA_TEST=local RAMALAMA=$(CURDIR)/bin/ramalama bats -T test/system/030-run.bats
_RAMALAMA_OPTIONS=--nocontainer _RAMALAMA_TEST=local bats -T test/system/030-run.bats
.PHONY: validate
validate: codespell lint
ifeq ($(OS),Linux)
hack/man-page-checker
hack/xref-helpmsgs-manpages
endif
.PHONY: pypi
pypi: clean
make docs
python3 -m build --sdist
python3 -m build --wheel
python3 -m twine upload dist/*
.PHONY: bats
bats:
RAMALAMA=$(CURDIR)/bin/ramalama bats -T test/system/
.PHONY: bats-nocontainer
bats-nocontainer:
_RAMALAMA_TEST_OPTS=--nocontainer RAMALAMA=$(CURDIR)/bin/ramalama bats -T test/system/
.PHONY: bats-docker
bats-docker:
_RAMALAMA_TEST_OPTS=--engine=docker RAMALAMA=$(CURDIR)/bin/ramalama bats -T test/system/
.PHONY: ci
ci:
test/ci.sh
.PHONY: test
test: validate bats bats-nocontainer ci
make clean
hack/tree_status.sh
.PHONY: clean
clean:
@find . -name \*~ -delete
@find . -name \*# -delete
@find . -name \*.rej -delete
@find . -name \*.orig -delete
rm -rf $$(<.gitignore)
make -C docs clean