[Biopython-dev] Status & scope of the git pre-commit hook?

Adam Kurkiewicz popantrop at gmail.com
Mon Dec 12 12:46:16 UTC 2016


What is the status and the scope of the git pre-commit hook in biopython?

I found an issue raised here, but I can't tell if this is work in
progress or something accomplished:
https://github.com/biopython/biopython/issues/883. I couldn't find the
hook in the project files.

Ideally, what I'm looking for is a code snippet, which will:

- run test cases for the files I changed since the last commit (not
all the files -- too slow).
- run pep8 on the files I changed since the last commit (not all the
files -- too slow).
- run itself automatically before committing, but also allow me to run
it manually.

The motivation is to cut down on the time spent waiting for test cases
to pass every time I do some work on the codebase, and to prevent me
from committing invalid code.

I've eventually (poorly) written one myself (based on a snippet passed
by Peter), which is suitable for what I'm doing with biopython just
now:

    #!/bin/sh
    set -xe
    unset PYTHONPATH

    # these are hard coded, which isn't nice:
    python2 Tests/run_tests.py test_Affy test_CelFile Bio.Affy Bio.Affy.CelFile
    python3 Tests/run_tests.py test_Affy test_CelFile Bio.Affy Bio.Affy.CelFile
    pypy Tests/run_tests.py test_Affy test_CelFile Bio.Affy Bio.Affy.CelFile

    # these should not be so generic (just check the files I changed,
not all the files!)
    # Checking all the files is very slow (20+ seconds on my system)
    pep8 --max-line-length 92 BioSQL/
    pep8 --ignore E402 --max-line-length 90 Scripts/
    pep8 --max-line-length 90 Doc/examples/
    pep8 --ignore E122,E123,E126,E127,E128,E129,E501,E731 Bio/
    pep8 --ignore E122,E123,E126,E127,E128,E241,E402,E501,E731 Tests/

Before writing this script I've tried installing tox locally, but that
didn't go very well and I gave up. Also, it doesn't seem that running
tox would achieve what I want -- a lightweight way to run relevant
testcases and lint relevant files.

I've also tried running a full test suite, but it takes too much time
to be run regularly.

Adam


More information about the Biopython-dev mailing list