source: trunk/Makefile

Last change on this file was 272d6d0, checked in by Jean-Paul Calderone <exarkun@…>, at 2020-12-01T14:55:17Z

Update developer docs wrt pre-commit

  • Property mode set to 100644
File size: 8.0 KB
Line 
1# Tahoe LFS Development and maintenance tasks
2#
3# NOTE: this Makefile requires GNU make
4
5### Defensive settings for make:
6#     https://tech.davis-hansson.com/p/make/
7SHELL := bash
8.ONESHELL:
9.SHELLFLAGS := -xeu -o pipefail -c
10.SILENT:
11.DELETE_ON_ERROR:
12MAKEFLAGS += --warn-undefined-variables
13MAKEFLAGS += --no-builtin-rules
14
15# Local target variables
16PYTHON=python
17export PYTHON
18PYFLAKES=flake8
19export PYFLAKES
20VIRTUAL_ENV=./.tox/py27
21SOURCES=src/allmydata static misc setup.py
22APPNAME=tahoe-lafs
23TEST_SUITE=allmydata
24
25
26# Top-level, phony targets
27
28.PHONY: default
29default:
30        @echo "no default target"
31
32.PHONY: test
33## Run all tests and code reports
34test: .tox/create-venvs.log
35# Run codechecks first since it takes the least time to report issues early.
36        tox --develop -e codechecks
37# Run all the test environments in parallel to reduce run-time
38        tox --develop -p auto -e 'py27,py36,pypy27'
39.PHONY: test-venv-coverage
40## Run all tests with coverage collection and reporting.
41test-venv-coverage:
42# Special handling for reporting coverage even when the test run fails
43        rm -f ./.coverage.*
44        test_exit=
45        $(VIRTUAL_ENV)/bin/coverage run -m twisted.trial --rterrors --reporter=timing \
46                $(TEST_SUITE) || test_exit="$$?"
47        $(VIRTUAL_ENV)/bin/coverage combine
48        $(VIRTUAL_ENV)/bin/coverage xml || true
49        $(VIRTUAL_ENV)/bin/coverage report
50        if [ ! -z "$$test_exit" ]; then exit "$$test_exit"; fi
51.PHONY: test-py3-all
52## Run all tests under Python 3
53test-py3-all: .tox/create-venvs.log
54        tox --develop -e py36 allmydata
55
56# This is necessary only if you want to automatically produce a new
57# _version.py file from the current git history (without doing a build).
58.PHONY: make-version
59make-version:
60        $(PYTHON) ./setup.py update_version
61
62# Build OS X pkg packages.
63.PHONY: build-osx-pkg
64build-osx-pkg:
65        misc/build_helpers/build-osx-pkg.sh $(APPNAME)
66
67.PHONY: test-osx-pkg
68test-osx-pkg:
69        $(PYTHON) misc/build_helpers/test-osx-pkg.py
70
71.PHONY: upload-osx-pkg
72upload-osx-pkg:
73        # [Failure instance: Traceback: <class 'OpenSSL.SSL.Error'>: [('SSL routines', 'ssl3_read_bytes', 'tlsv1 alert unknown ca'), ('SSL routines', 'ssl3_write_bytes', 'ssl handshake failure')]
74        #
75        # @echo "uploading to ~tahoe-tarballs/OS-X-packages/ via flappserver"
76        # @if [ "X${BB_BRANCH}" = "Xmaster" ] || [ "X${BB_BRANCH}" = "X" ]; then \
77        #   flappclient --furlfile ~/.tahoe-osx-pkg-upload.furl upload-file tahoe-lafs-*-osx.pkg; \
78        #  else \
79        #   echo not uploading tahoe-lafs-osx-pkg because this is not trunk but is branch \"${BB_BRANCH}\" ; \
80        # fi
81
82.PHONY: code-checks
83#code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
84code-checks: check-interfaces check-debugging check-miscaptures -find-trailing-spaces -check-umids pyflakes
85
86.PHONY: check-interfaces
87check-interfaces:
88        $(PYTHON) misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
89        @echo
90
91.PHONY: check-debugging
92check-debugging:
93        $(PYTHON) misc/coding_tools/check-debugging.py
94        @echo
95
96.PHONY: check-miscaptures
97check-miscaptures:
98        $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
99        @echo
100
101.PHONY: pyflakes
102pyflakes:
103        $(PYFLAKES) $(SOURCES) |sort |uniq
104        @echo
105
106.PHONY: check-umids
107check-umids:
108        $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
109        @echo
110
111.PHONY: -check-umids
112-check-umids:
113        -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
114        @echo
115
116.PHONY: doc-checks
117doc-checks: check-rst
118
119.PHONY: check-rst
120check-rst:
121        @for x in `find *.rst docs -name "*.rst"`; do rst2html -v $${x} >/dev/null; done 2>&1 |grep -v 'Duplicate implicit target name:'
122        @echo
123
124.PHONY: count-lines
125count-lines:
126        @echo -n "files: "
127        @find src -name '*.py' |grep -v /build/ |wc -l
128        @echo -n "lines: "
129        @cat `find src -name '*.py' |grep -v /build/` |wc -l
130        @echo -n "TODO: "
131        @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
132        @echo -n "XXX: "
133        @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
134
135
136# Here is a list of testing tools that can be run with 'python' from a
137# virtualenv in which Tahoe has been installed. There used to be Makefile
138# targets for each, but the exact path to a suitable python is now up to the
139# developer. But as a hint, after running 'tox', ./.tox/py27/bin/python will
140# probably work.
141
142# src/allmydata/test/bench_dirnode.py
143
144
145# The check-speed and check-grid targets are disabled, since they depend upon
146# the pre-located $(TAHOE) executable that was removed when we switched to
147# tox. They will eventually be resurrected as dedicated tox environments.
148
149# The check-speed target uses a pre-established client node to run a canned
150# set of performance tests against a test network that is also
151# pre-established (probably on a remote machine). Provide it with the path to
152# a local directory where this client node has been created (and populated
153# with the necessary FURLs of the test network). This target will start that
154# client with the current code and then run the tests. Afterwards it will
155# stop the client.
156#
157# The 'sleep 5' is in there to give the new client a chance to connect to its
158# storageservers, since check_speed.py has no good way of doing that itself.
159
160##.PHONY: check-speed
161##check-speed: .built
162##      if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
163##      @echo "stopping any leftover client code"
164##      -$(TAHOE) stop $(TESTCLIENTDIR)
165##      $(TAHOE) start $(TESTCLIENTDIR)
166##      sleep 5
167##      $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
168##      $(TAHOE) stop $(TESTCLIENTDIR)
169
170# The check-grid target also uses a pre-established client node, along with a
171# long-term directory that contains some well-known files. See the docstring
172# in src/allmydata/test/check_grid.py to see how to set this up.
173##.PHONY: check-grid
174##check-grid: .built
175##      if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
176##      $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
177
178.PHONY: test-get-ignore
179test-git-ignore:
180        $(MAKE)
181        $(PYTHON) misc/build_helpers/test-git-ignore.py
182
183.PHONY: test-clean
184test-clean:
185        find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
186        $(MAKE)
187        $(MAKE) distclean
188        find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
189        diff allfiles.tmp.old allfiles.tmp.new
190
191# It would be nice if 'make clean' deleted any automatically-generated
192# _version.py too, so that 'make clean; make all' could be useable as a
193# "what the heck is going on, get me back to a clean state', but we need
194# 'make clean' to work on non-checkout trees without destroying useful information.
195# Use 'make distclean' instead to delete all generated files.
196.PHONY: clean
197clean:
198        rm -rf build _trial_temp _test_memory .built
199        rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
200        rm -rf support dist
201        rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
202        rm -rf *.pyc
203        rm -f bin/tahoe bin/tahoe.pyscript
204        rm -f *.pkg
205
206.PHONY: distclean
207distclean: clean
208        rm -rf src/*.egg-info
209        rm -f src/allmydata/_version.py
210        rm -f src/allmydata/_appname.py
211        rm -rf ./.tox/
212
213
214.PHONY: find-trailing-spaces
215find-trailing-spaces:
216        $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
217        @echo
218
219.PHONY: -find-trailing-spaces
220-find-trailing-spaces:
221        -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
222        @echo
223
224.PHONY: fetch-and-unpack-deps
225fetch-and-unpack-deps:
226        @echo "test-and-unpack-deps is obsolete"
227
228.PHONY: test-desert-island
229test-desert-island:
230        @echo "test-desert-island is obsolete"
231
232.PHONY: test-pip-install
233test-pip-install:
234        @echo "test-pip-install is obsolete"
235
236# TARBALL GENERATION
237.PHONY: tarballs
238tarballs: # delegated to tox, so setup.py can update setuptools if needed
239        tox -e tarballs
240
241.PHONY: upload-tarballs
242upload-tarballs:
243        @if [ "X${BB_BRANCH}" = "Xmaster" ] || [ "X${BB_BRANCH}" = "X" ]; then for f in dist/*; do flappclient --furlfile ~/.tahoe-tarball-upload.furl upload-file $$f; done ; else echo not uploading tarballs because this is not trunk but is branch \"${BB_BRANCH}\" ; fi
244
245
246# Real targets
247
248src/allmydata/_version.py:
249        $(MAKE) make-version
250
251.tox/create-venvs.log: tox.ini setup.py
252        tox --notest -p all | tee -a "$(@)"
Note: See TracBrowser for help on using the repository browser.