mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-18 10:46:24 +00:00
test(vcs): Add a VCS push hook to run tests
Personally, I can't stand working without a VCS hook anymore. It saves me so much time in context switches from revisiting and revising PRs when I see that the CI run is red. Much better to fail before I push so I can revise while the relevant changes are fresh in my head. In order to start using this, one has to run `$ make build` first. Should I add that and make other documentation changes in the wiki related to my changes in this PR?
This commit is contained in:
parent
ce20ac6a74
commit
2ef422e064
8
.pre-commit-config.yaml
Normal file
8
.pre-commit-config.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
repos:
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: test
|
||||
name: test
|
||||
entry: "make test"
|
||||
language: system
|
||||
pass_filenames: false
|
20
Makefile
20
Makefile
@ -13,6 +13,8 @@ MAKEFLAGS += --warn-undefined-variables
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
|
||||
# Local target variables
|
||||
VCS_HOOK_SAMPLES=$(wildcard .git/hooks/*.sample)
|
||||
VCS_HOOKS=$(VCS_HOOK_SAMPLES:%.sample=%)
|
||||
PYTHON=python
|
||||
export PYTHON
|
||||
PYFLAKES=flake8
|
||||
@ -27,13 +29,22 @@ APPNAME=tahoe-lafs
|
||||
default:
|
||||
@echo "no default target"
|
||||
|
||||
.PHONY: build
|
||||
## Set up and build for local development
|
||||
# To also run checks on every commit:
|
||||
# $ make .git/hooks/pre-commit
|
||||
build: .tox .git/hooks/pre-push
|
||||
|
||||
.PHONY: test
|
||||
## Run all tests and code reports
|
||||
test: .tox
|
||||
tox --develop -p auto
|
||||
test: build
|
||||
# Run codechecks first since it takes the least time to report issues early.
|
||||
tox --develop -e codechecks
|
||||
# Run all the test environments in parallel to reduce run-time
|
||||
tox --develop -p auto -e 'py27,py36,pypy27'
|
||||
.PHONY: test-py3-all
|
||||
## Run all tests under Python 3
|
||||
test-py3-all: .tox
|
||||
test-py3-all: build
|
||||
tox --develop -e py36 allmydata
|
||||
|
||||
# This is necessary only if you want to automatically produce a new
|
||||
@ -233,3 +244,6 @@ src/allmydata/_version.py:
|
||||
|
||||
.tox: tox.ini setup.py
|
||||
tox --notest -p all
|
||||
|
||||
$(VCS_HOOKS): .tox .pre-commit-config.yaml
|
||||
"./$(<)/py36/bin/pre-commit" install --hook-type $(@:.git/hooks/%=%)
|
||||
|
9
tox.ini
9
tox.ini
@ -37,6 +37,8 @@ deps =
|
||||
# regressions in new releases of this package that cause us the kind of
|
||||
# suffering we're trying to avoid with the above pins.
|
||||
certifi
|
||||
# VCS hooks support
|
||||
py36,!coverage: pre-commit
|
||||
|
||||
# We add usedevelop=False because testing against a true installation gives
|
||||
# more useful results.
|
||||
@ -86,6 +88,13 @@ basepython = python2.7
|
||||
passenv = HOME
|
||||
whitelist_externals =
|
||||
/bin/mv
|
||||
setenv =
|
||||
# Workaround an error when towncrier is run under the VCS hook,
|
||||
# https://stackoverflow.com/a/4027726/624787:
|
||||
# File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/codechecks/lib/python2.7/site-packages/towncrier/check.py", line 44, in __main
|
||||
# .decode(getattr(sys.stdout, "encoding", "utf8"))
|
||||
# `TypeError: decode() argument 1 must be string, not None`
|
||||
PYTHONIOENCODING=utf_8
|
||||
commands =
|
||||
flake8 src static misc setup.py
|
||||
python misc/coding_tools/check-umids.py src
|
||||
|
Loading…
Reference in New Issue
Block a user