| 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/ |
|---|
| 7 | SHELL := bash |
|---|
| 8 | .ONESHELL: |
|---|
| 9 | .SHELLFLAGS := -xeu -o pipefail -c |
|---|
| 10 | .SILENT: |
|---|
| 11 | .DELETE_ON_ERROR: |
|---|
| 12 | MAKEFLAGS += --warn-undefined-variables |
|---|
| 13 | MAKEFLAGS += --no-builtin-rules |
|---|
| 14 | |
|---|
| 15 | # Local target variables |
|---|
| 16 | PYTHON=python |
|---|
| 17 | export PYTHON |
|---|
| 18 | PYFLAKES=flake8 |
|---|
| 19 | export PYFLAKES |
|---|
| 20 | VIRTUAL_ENV=./.tox/py37 |
|---|
| 21 | SOURCES=src/allmydata static misc setup.py |
|---|
| 22 | APPNAME=tahoe-lafs |
|---|
| 23 | TEST_SUITE=allmydata |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | # Top-level, phony targets |
|---|
| 27 | |
|---|
| 28 | .PHONY: default |
|---|
| 29 | default: |
|---|
| 30 | @echo "no default target" |
|---|
| 31 | |
|---|
| 32 | .PHONY: test |
|---|
| 33 | ## Run all tests and code reports |
|---|
| 34 | test: .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 'py37' |
|---|
| 39 | .PHONY: test-venv-coverage |
|---|
| 40 | ## Run all tests with coverage collection and reporting. |
|---|
| 41 | test-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 |
|---|
| 53 | test-py3-all: .tox/create-venvs.log |
|---|
| 54 | tox --develop -e py37 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 |
|---|
| 59 | make-version: |
|---|
| 60 | $(PYTHON) ./setup.py update_version |
|---|
| 61 | |
|---|
| 62 | # Build OS X pkg packages. |
|---|
| 63 | .PHONY: build-osx-pkg |
|---|
| 64 | build-osx-pkg: |
|---|
| 65 | misc/build_helpers/build-osx-pkg.sh $(APPNAME) |
|---|
| 66 | |
|---|
| 67 | .PHONY: test-osx-pkg |
|---|
| 68 | test-osx-pkg: |
|---|
| 69 | $(PYTHON) misc/build_helpers/test-osx-pkg.py |
|---|
| 70 | |
|---|
| 71 | .PHONY: upload-osx-pkg |
|---|
| 72 | upload-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 |
|---|
| 84 | code-checks: check-interfaces check-debugging check-miscaptures -find-trailing-spaces -check-umids pyflakes |
|---|
| 85 | |
|---|
| 86 | .PHONY: check-interfaces |
|---|
| 87 | check-interfaces: |
|---|
| 88 | $(PYTHON) misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt |
|---|
| 89 | @echo |
|---|
| 90 | |
|---|
| 91 | .PHONY: check-debugging |
|---|
| 92 | check-debugging: |
|---|
| 93 | $(PYTHON) misc/coding_tools/check-debugging.py |
|---|
| 94 | @echo |
|---|
| 95 | |
|---|
| 96 | .PHONY: check-miscaptures |
|---|
| 97 | check-miscaptures: |
|---|
| 98 | $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt |
|---|
| 99 | @echo |
|---|
| 100 | |
|---|
| 101 | .PHONY: pyflakes |
|---|
| 102 | pyflakes: |
|---|
| 103 | $(PYFLAKES) $(SOURCES) |sort |uniq |
|---|
| 104 | @echo |
|---|
| 105 | |
|---|
| 106 | .PHONY: check-umids |
|---|
| 107 | check-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 |
|---|
| 117 | doc-checks: check-rst |
|---|
| 118 | |
|---|
| 119 | .PHONY: check-rst |
|---|
| 120 | check-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 |
|---|
| 125 | count-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/py37/bin/python will |
|---|
| 140 | # probably work. |
|---|
| 141 | |
|---|
| 142 | # src/allmydata/test/bench_dirnode.py |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | # The check-grid target also uses a pre-established client node, along with a |
|---|
| 146 | # long-term directory that contains some well-known files. See the docstring |
|---|
| 147 | # in src/allmydata/test/check_grid.py to see how to set this up. |
|---|
| 148 | ##.PHONY: check-grid |
|---|
| 149 | ##check-grid: .built |
|---|
| 150 | ## if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi |
|---|
| 151 | ## $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe |
|---|
| 152 | |
|---|
| 153 | .PHONY: test-get-ignore |
|---|
| 154 | test-git-ignore: |
|---|
| 155 | $(MAKE) |
|---|
| 156 | $(PYTHON) misc/build_helpers/test-git-ignore.py |
|---|
| 157 | |
|---|
| 158 | .PHONY: test-clean |
|---|
| 159 | test-clean: |
|---|
| 160 | find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old |
|---|
| 161 | $(MAKE) |
|---|
| 162 | $(MAKE) distclean |
|---|
| 163 | find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new |
|---|
| 164 | diff allfiles.tmp.old allfiles.tmp.new |
|---|
| 165 | |
|---|
| 166 | # It would be nice if 'make clean' deleted any automatically-generated |
|---|
| 167 | # _version.py too, so that 'make clean; make all' could be useable as a |
|---|
| 168 | # "what the heck is going on, get me back to a clean state', but we need |
|---|
| 169 | # 'make clean' to work on non-checkout trees without destroying useful information. |
|---|
| 170 | # Use 'make distclean' instead to delete all generated files. |
|---|
| 171 | .PHONY: clean |
|---|
| 172 | clean: |
|---|
| 173 | rm -rf build _trial_temp .built |
|---|
| 174 | rm -f `find src *.egg -name '*.so' -or -name '*.pyc'` |
|---|
| 175 | rm -rf support dist |
|---|
| 176 | rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"` |
|---|
| 177 | rm -rf *.pyc |
|---|
| 178 | rm -f *.pkg |
|---|
| 179 | |
|---|
| 180 | .PHONY: distclean |
|---|
| 181 | distclean: clean |
|---|
| 182 | rm -rf src/*.egg-info |
|---|
| 183 | rm -f src/allmydata/_version.py |
|---|
| 184 | rm -f src/allmydata/_appname.py |
|---|
| 185 | rm -rf ./.tox/ |
|---|
| 186 | |
|---|
| 187 | |
|---|
| 188 | .PHONY: find-trailing-spaces |
|---|
| 189 | find-trailing-spaces: |
|---|
| 190 | $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES) |
|---|
| 191 | @echo |
|---|
| 192 | |
|---|
| 193 | .PHONY: -find-trailing-spaces |
|---|
| 194 | -find-trailing-spaces: |
|---|
| 195 | -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES) |
|---|
| 196 | @echo |
|---|
| 197 | |
|---|
| 198 | .PHONY: fetch-and-unpack-deps |
|---|
| 199 | fetch-and-unpack-deps: |
|---|
| 200 | @echo "test-and-unpack-deps is obsolete" |
|---|
| 201 | |
|---|
| 202 | .PHONY: test-desert-island |
|---|
| 203 | test-desert-island: |
|---|
| 204 | @echo "test-desert-island is obsolete" |
|---|
| 205 | |
|---|
| 206 | .PHONY: test-pip-install |
|---|
| 207 | test-pip-install: |
|---|
| 208 | @echo "test-pip-install is obsolete" |
|---|
| 209 | |
|---|
| 210 | # TARBALL GENERATION |
|---|
| 211 | .PHONY: tarballs |
|---|
| 212 | tarballs: # delegated to tox, so setup.py can update setuptools if needed |
|---|
| 213 | tox -e tarballs |
|---|
| 214 | |
|---|
| 215 | .PHONY: upload-tarballs |
|---|
| 216 | upload-tarballs: |
|---|
| 217 | @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 |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | # Real targets |
|---|
| 221 | |
|---|
| 222 | src/allmydata/_version.py: |
|---|
| 223 | $(MAKE) make-version |
|---|
| 224 | |
|---|
| 225 | .tox/create-venvs.log: tox.ini setup.py |
|---|
| 226 | tox --notest -p all | tee -a "$(@)" |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | # to make a new release: |
|---|
| 230 | # - create a ticket for the release in Trac |
|---|
| 231 | # - ensure local copy is up-to-date |
|---|
| 232 | # - create a branch like "XXXX.release" from up-to-date master |
|---|
| 233 | # - in the branch, run "make release" |
|---|
| 234 | # - run "make release-test" |
|---|
| 235 | # - perform any other sanity-checks on the release |
|---|
| 236 | # - run "make release-upload" |
|---|
| 237 | # Note that several commands below hard-code "meejah"; if you are |
|---|
| 238 | # someone else please adjust them. |
|---|
| 239 | release: |
|---|
| 240 | @echo "Is checkout clean?" |
|---|
| 241 | git diff-files --quiet |
|---|
| 242 | git diff-index --quiet --cached HEAD -- |
|---|
| 243 | |
|---|
| 244 | @echo "Clean docs build area" |
|---|
| 245 | rm -rf docs/_build/ |
|---|
| 246 | |
|---|
| 247 | @echo "Install required build software" |
|---|
| 248 | python3 -m pip install --editable .[build] |
|---|
| 249 | |
|---|
| 250 | @echo "Test README" |
|---|
| 251 | python3 setup.py check -r -s |
|---|
| 252 | |
|---|
| 253 | @echo "Update NEWS" |
|---|
| 254 | python3 -m towncrier build --yes --version `python3 misc/build_helpers/update-version.py --no-tag` |
|---|
| 255 | git add -u |
|---|
| 256 | git commit -m "update NEWS for release" |
|---|
| 257 | |
|---|
| 258 | # note that this always bumps the "middle" number, e.g. from 1.17.1 -> 1.18.0 |
|---|
| 259 | # and produces a tag into the Git repository |
|---|
| 260 | @echo "Bump version and create tag" |
|---|
| 261 | python3 misc/build_helpers/update-version.py |
|---|
| 262 | |
|---|
| 263 | @echo "Build and sign wheel" |
|---|
| 264 | python3 setup.py bdist_wheel |
|---|
| 265 | gpg --pinentry=loopback -u meejah@meejah.ca --armor --detach-sign dist/tahoe_lafs-`git describe | cut -b 12-`-py3-none-any.whl |
|---|
| 266 | ls dist/*`git describe | cut -b 12-`* |
|---|
| 267 | |
|---|
| 268 | @echo "Build and sign source-dist" |
|---|
| 269 | python3 setup.py sdist |
|---|
| 270 | gpg --pinentry=loopback -u meejah@meejah.ca --armor --detach-sign dist/tahoe-lafs-`git describe | cut -b 12-`.tar.gz |
|---|
| 271 | ls dist/*`git describe | cut -b 12-`* |
|---|
| 272 | |
|---|
| 273 | # basically just a bare-minimum smoke-test that it installs and runs |
|---|
| 274 | release-test: |
|---|
| 275 | gpg --verify dist/tahoe-lafs-`git describe | cut -b 12-`.tar.gz.asc |
|---|
| 276 | gpg --verify dist/tahoe_lafs-`git describe | cut -b 12-`-py3-none-any.whl.asc |
|---|
| 277 | virtualenv testmf_venv |
|---|
| 278 | testmf_venv/bin/pip install dist/tahoe_lafs-`git describe | cut -b 12-`-py3-none-any.whl |
|---|
| 279 | testmf_venv/bin/tahoe --version |
|---|
| 280 | rm -rf testmf_venv |
|---|
| 281 | |
|---|
| 282 | release-upload: |
|---|
| 283 | scp dist/*`git describe | cut -b 12-`* meejah@tahoe-lafs.org:/home/source/downloads |
|---|
| 284 | git push origin_push tahoe-lafs-`git describe | cut -b 12-` |
|---|
| 285 | twine upload dist/tahoe_lafs-`git describe | cut -b 12-`-py3-none-any.whl dist/tahoe_lafs-`git describe | cut -b 12-`-py3-none-any.whl.asc dist/tahoe-lafs-`git describe | cut -b 12-`.tar.gz dist/tahoe-lafs-`git describe | cut -b 12-`.tar.gz.asc |
|---|