-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMakefile
73 lines (56 loc) · 2.01 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
short_ver = 2.0.3
long_ver = $(shell git describe --long 2>/dev/null || echo $(short_ver)-0-unknown-g`git describe --always`)
generated = pglookout/version.py
PYTHON ?= python3
PYTHON_SOURCE_DIRS = pglookout/ test/
all: $(generated)
: 'try "make rpm" or "make deb" or "make test"'
pglookout/version.py: version.py
$(PYTHON) $^ $@
test: mypy flake8 pylint unittest
unittest: $(generated)
$(PYTHON) -m pytest
mypy: $(generated)
$(PYTHON) -m mypy
flake8: $(generated)
$(PYTHON) -m flake8 $(PYTHON_SOURCE_DIRS)
pylint: $(generated)
$(PYTHON) -m pylint $(PYTHON_SOURCE_DIRS)
fmt: $(generated)
isort $(PYTHON_SOURCE_DIRS)
black $(PYTHON_SOURCE_DIRS)
fmt-check: $(generated)
isort --check $(PYTHON_SOURCE_DIRS)
black --check $(PYTHON_SOURCE_DIRS)
coverage:
$(PYTHON) -m pytest $(PYTEST_ARG) --cov-report term-missing --cov-branch \
--cov-report xml:coverage.xml --cov pglookout test/
clean:
$(RM) -r *.egg-info/ build/ dist/
$(RM) ../pglookout_* test-*.xml $(generated)
deb: $(generated)
cp debian/changelog.in debian/changelog
dch -v $(long_ver) "Automatically built package"
dpkg-buildpackage -A -uc -us
rpm: $(generated)
git archive --output=pglookout-rpm-src.tar --prefix=pglookout/ HEAD
# add generated files to the tar, they're not in git repository
tar -r -f pglookout-rpm-src.tar --transform=s,pglookout/,pglookout/pglookout/, $(generated)
rpmbuild -bb pglookout.spec \
--define '_topdir $(PWD)/rpm' \
--define '_sourcedir $(shell pwd)' \
--define 'major_version $(short_ver)' \
--define 'minor_version $(subst -,.,$(subst $(short_ver)-,,$(long_ver)))'
$(RM) pglookout-rpm-src.tar
build-dep-fed:
sudo dnf -y install --best --allowerasing \
python3-devel python3-pytest python3-pylint \
python3-mock python3-psycopg2 \
python3-requests rpm-build systemd-python3 \
python3-flake8 python3-pytest-cov python3-packaging
build-dep-deb:
sudo apt-get install \
build-essential devscripts dh-systemd \
python3-all python3-setuptools python3-psycopg2 python3-requests \
python3-packaging
.PHONY: rpm