-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
137 lines (112 loc) · 4.9 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
########################################################
# Makefile for re-worker-func
#
# useful targets (not all implemented yet!):
# make clean -- Clean up garbage
# make pyflakes, make pep8 -- source code checks
# make test ----------------- run all unit tests (export LOG=true for /tmp/ logging)
# make ci ------------------- Execute CI steps (for travis or jenkins)
########################################################
# > VARIABLE = value
#
# Normal setting of a variable - values within it are recursively
# expanded when the variable is USED, not when it's declared.
#
# > VARIABLE := value
#
# Setting of a variable with simple expansion of the values inside -
# values within it are expanded at DECLARATION time.
########################################################
NAME := re-worker-func
RPMSPECDIR := ./contrib/rpm/
RPMSPEC := $(RPMSPECDIR)/re-worker-func.spec
TESTPACKAGE := replugin
SHORTNAME := replugin
SRCDIR := replugin/funcworker
################
# For CI deps
TMPDIR = $(shell mktemp -d)
FUNCDIR := $(TMPDIR)
REWORKERDIR := $(TMPDIR)
CMDIR := $(TMPDIR)
sdist: clean
python setup.py sdist
rm -fR funcworker.egg-info
tests: unittests pep8 pyflakes
:
unittests:
@echo "#############################################"
@echo "# Running Unit Tests"
@echo "#############################################"
nosetests -v --with-cover --cover-min-percentage=80 --cover-package=replugin test/
clean:
@find . -type f -regex ".*\.py[co]$$" -delete
@find . -type f \( -name "*~" -or -name "#*" \) -delete
@rm -fR build dist rpm-build MANIFEST htmlcov .coverage reworkerfunc.egg-info re-worker-funcenv
pep8:
@echo "#############################################"
@echo "# Running PEP8 Compliance Tests"
@echo "#############################################"
pep8 --ignore=E501,E121,E124 $(SRCDIR)
pyflakes:
@echo "#############################################"
@echo "# Running Pyflakes Sanity Tests"
@echo "# Note: most import errors may be ignored"
@echo "#############################################"
-pyflakes $(SRCDIR)
rpmcommon: sdist
@mkdir -p rpm-build
@cp dist/*.gz rpm-build/
srpm: rpmcommon
@rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir $(RPMSPECDIR)" \
--define "_sourcedir %{_topdir}" \
-bs $(RPMSPEC)
@echo "#############################################"
@echo "$(NAME) SRPM is built:"
@find rpm-build -maxdepth 2 -name '$(NAME)*src.rpm' | awk '{print " " $$1}'
@echo "#############################################"
rpm: rpmcommon
@rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir $(RPMSPECDIR)" \
--define "_sourcedir %{_topdir}" \
-ba $(RPMSPEC)
@echo "#############################################"
@echo "$(NAME) RPMs are built:"
@find rpm-build -maxdepth 2 -name '$(NAME)*.rpm' | awk '{print " " $$1}'
@echo "#############################################"
virtualenv:
@echo "#############################################"
@echo "# Creating a virtualenv"
@echo "#############################################"
virtualenv $(NAME)env
. $(NAME)env/bin/activate && PYTHONUSERBASE=$(NAME)env pip install -r requirements.txt
. $(NAME)env/bin/activate && pip install pep8 nose coverage mock
# If there are any special things to install do it here
. $(NAME)env/bin/activate && cd $(REWORKERDIR) && wget https://github.com/RHInception/re-worker/archive/master.zip && unzip master && cd re-worker-master && pip install .
# Note how these next two lines end with '|| true', we do this because func and certmaster attempt to install files into /etc/, and that will fail
. $(NAME)env/bin/activate && cd $(FUNCDIR) && wget https://www.fedorahosted.org/releases/f/u/func/func-0.28.tar.gz && tar xvzf func-0.28.tar.gz && cd func-0.28 && pip install . || true
. $(NAME)env/bin/activate && cd $(CMDIR) && wget https://www.fedorahosted.org/releases/c/e/certmaster/certmaster-0.28.tar.gz && tar xvzf certmaster-0.28.tar.gz && cd certmaster-0.28 && pip install . || true
ci-unittests:
@echo "#############################################"
@echo "# Running Unit Tests in virtualenv"
@echo "#############################################"
. $(NAME)env/bin/activate && nosetests -v --with-cover --cover-min-percentage=80 --cover-package=$(TESTPACKAGE) test/
ci-list-deps:
@echo "#############################################"
@echo "# Listing all pip deps"
@echo "#############################################"
. $(NAME)env/bin/activate && pip freeze
ci-pep8:
@echo "#############################################"
@echo "# Running PEP8 Compliance Tests in virtualenv"
@echo "#############################################"
. $(NAME)env/bin/activate && pep8 --ignore=E501,E121,E124 $(SHORTNAME)/
ci: clean virtualenv ci-list-deps ci-pep8 ci-unittests
: