-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMakefile
121 lines (104 loc) · 3.52 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
# Copyright (C) 2019 Red Hat, Inc. All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
#
PKGNAME = dasbus
VERSION = $(shell awk '/Version:/ { print $$2 }' python-$(PKGNAME).spec)
TAG = v$(VERSION)
PYTHON ?= python3
COVERAGE ?= coverage3
# Container-related
CI_NAME = $(PKGNAME)-ci
CI_IMAGE ?= fedora
CI_TAG ?= latest
CI_CMD ?= make ci
# Arguments used by pylint for checking the code.
CHECK_ARGS ?=
.PHONY: clean
clean:
git clean -idx
.PHONY: container-ci
container-ci:
podman build \
--file ".travis/Dockerfile.$(CI_IMAGE)" \
--build-arg TAG=$(CI_TAG) \
--tag $(CI_NAME) \
--pull-always
podman run \
--volume .:/dasbus:Z \
--workdir /dasbus \
$(CI_NAME) $(CI_CMD)
.PHONY: ci
ci:
@echo "*** Running CI with $(PYTHON) ***"
$(PYTHON) --version
$(MAKE) check
$(MAKE) test
$(MAKE) docs
.PHONY: check
check:
@echo "*** Running pylint ***"
$(PYTHON) -m pylint --version
$(PYTHON) -m pylint $(CHECK_ARGS) src/ tests/
.PHONY: test
test:
@echo "*** Running pytest with $(COVERAGE) ***"
PYTHONPATH=src $(COVERAGE) run -m pytest
$(COVERAGE) combine
$(COVERAGE) report -m --include="src/*" | tee coverage-report.log
.PHONY: test-install
test-install:
@echo "*** Running tests for the installed package ***"
$(PYTHON) -c "import dasbus"
$(PYTHON) -m pytest
.PHONY: docs
docs:
$(MAKE) -C docs html text
.PHONY: changelog
changelog:
@git log --no-merges --pretty="format:- %s (%ae)" $(TAG).. | sed -e 's/@.*)/)/'
.PHONY: commit
commit:
@NEWSUBVER=$$((`echo $(VERSION) | cut -d . -f 2` + 1)) ; \
NEWVERSION=`echo $(VERSION).$$NEWSUBVER | cut -d . -f 1,3` ; \
DATELINE="* `LC_ALL=C.UTF-8 date "+%a %b %d %Y"` `git config user.name` <`git config user.email`> - $$NEWVERSION-1" ; \
cl=`grep -n %changelog python-${PKGNAME}.spec | cut -d : -f 1` ; \
tail --lines=+$$(($$cl + 1)) python-${PKGNAME}.spec > speclog ; \
(head -n $$cl python-${PKGNAME}.spec ; echo "$$DATELINE" ; make --quiet changelog 2>/dev/null ; echo ""; cat speclog) > python-${PKGNAME}.spec.new ; \
mv python-${PKGNAME}.spec.new python-${PKGNAME}.spec ; rm -f speclog ; \
sed -i "s/Version:\( *\)$(VERSION)/Version:\1$$NEWVERSION/" python-${PKGNAME}.spec ; \
sed -i "s/version = \"$(VERSION)\"/version = \"$$NEWVERSION\"/" pyproject.toml ; \
git add python-${PKGNAME}.spec setup.py ; \
git commit -m "New release: $$NEWVERSION"
.PHONY: tag
tag:
git tag -a -m "Tag as $(VERSION)" -f $(TAG)
@echo "Tagged as $(TAG)"
.PHONY: push
push:
@echo "Run the command 'git push --follow-tags' with '--dry-run' first."
.PHONY: archive
archive:
@echo "*** Building the distribution archive ***"
$(PYTHON) -m build
@echo "The archive is in dist/$(PKGNAME)-$(VERSION).tar.gz"
.PHONY: install
install: archive
@echo "*** Installing the $(PKGNAME)-$(VERSION) package ***"
$(PYTHON) -m pip install dist/$(PKGNAME)-$(VERSION)-py3-none-any.whl
.PHONY: upload
upload:
$(PYTHON) -m twine upload dist/*