-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (61 loc) · 1.96 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
MAXFAIL ?= 100
PYPI_URL ?= https://upload.pypi.org/legacy/
PYPI_USER ?= $(USER)
RRSYNC_URL = https://www.samba.org/ftp/unpacked/rsync/support/rrsync
VERSION ?= $(shell grep -o '[0-9.]*' secondshot/_version.py)
VENV=python_env
VDIR=$(PWD)/$(VENV)
include Makefile.docker
analysis: flake8
test: pytest
package: bin/rrsync dist/secondshot-$(VERSION).tar.gz
publish: test_requirements package
@echo Publishing python package
(. $(VDIR)/bin/activate && \
twine upload --repository-url $(PYPI_URL) \
-u $(PYPI_USER) -p $(PYPI_PASSWORD) dist/*)
test_functional:
@echo "Run Functional Tests - not yet implemented"
flake8: test_requirements
@echo "Running flake8 code analysis"
. $(VDIR)/bin/activate ; flake8 --exclude=python_env,check_rsnap.py \
secondshot tests \
--per-file-ignores='secondshot/alembic/versions/*:E501,E122,E128'
python_env: $(VDIR)/bin/python3
test_requirements: python_env
@echo "Installing test requirements"
(. $(VDIR)/bin/activate && \
pip install -r tests/requirements.txt)
$(VDIR)/bin/python3:
@echo "Creating virtual environment"
python3 -m venv --system-site-packages $(VENV)
pytest: test_requirements
@echo "Running pytest unit tests"
(. $(VDIR)/bin/activate && \
PYTHONPATH=. python3 -m pytest $(XARGS) ./tests/ \
--durations=10 \
--junitxml=./tests/results.xml \
--maxfail=$(MAXFAIL) \
--cov-report html \
--cov-report xml \
--cov-report term-missing \
--cov secondshot)
dist/secondshot-$(VERSION).tar.gz:
@echo "Building package"
pip show wheel >/dev/null; \
if [ $$? -ne 0 ]; then \
(. $(VDIR)/bin/activate ; python setup.py sdist bdist_wheel); \
else \
python setup.py sdist bdist_wheel ; \
fi
bin/rrsync:
@echo "Downloading rrsync"
wget -q -O $@ $(RRSYNC_URL)
chmod +x $@
clean:
rm -rf build dist bin/rrsync secondshot/htmlcov *.egg-info \
.cache .pytest_cache tests/__pycache__
find . -regextype egrep -regex '.*(coverage.xml|results.xml|\.pyc|~)' \
-exec rm -rf {} \;
wipe_clean: clean
rm -rf python_env