Skip to content

Commit cc8abb6

Browse files
committed
Improvements to developer experience.
- Add more information to CONTRIBUTING.rst - including information on tox and running specific tests. - Add new quick-test make target for running the fatest tests quickly (and documentation). - Add new tox make target for running specific tests with tox (and documentation). - Add new _open-docs make target open pre-existing docs locally. - Modify lint make target to lint through tox to verify both Python 2 and Python 3 syntax. - Add new flake8 make target corresponding to the old lint target. - Add Makefile targets for installing pre-commit git hooks - one that lints and one that lints and runs the new quick-test target (and documentation). - Fix dev-requirements.txt which had a duplicated wheel entry. - General Makefile refactoring and documentation improvements. Closes #209.
1 parent cdbf55a commit cc8abb6

File tree

8 files changed

+157
-50
lines changed

8 files changed

+157
-50
lines changed

CONTRIBUTING.rst

Lines changed: 92 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ is open to whoever wants to implement it.
3636
Implement Features
3737
~~~~~~~~~~~~~~~~~~
3838

39-
Look through the GitHub issues for features. Anything tagged with "feature"
40-
is open to whoever wants to implement it.
39+
Look through the GitHub issues for features. Anything tagged with
40+
"enhancement" is open to whoever wants to implement it.
4141

4242
Write Documentation
4343
~~~~~~~~~~~~~~~~~~~
@@ -70,9 +70,7 @@ Ready to contribute? Here's how to set up `planemo` for local development.
7070

7171
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
7272

73-
$ mkvirtualenv planemo
74-
$ cd planemo/
75-
$ python setup.py develop
73+
$ make setup-venv
7674

7775
4. Create a branch for local development::
7876

@@ -81,18 +79,17 @@ Ready to contribute? Here's how to set up `planemo` for local development.
8179
Now you can make your changes locally.
8280

8381
5. When you're done making changes, check that your changes pass ``flake8``
84-
and the tests::
85-
86-
$ flake8 planemo tests
87-
$ python setup.py test
88-
89-
To get ``flake8``, just ``pip install`` them into your virtualenv.
90-
91-
.. including testing other Python versions with tox
92-
.. $ python setup.py test
93-
.. $ tox
94-
..
95-
.. To get flake8 and tox, just pip install them into your virtualenv.
82+
and the tests
83+
84+
::
85+
86+
$ make lint
87+
$ make test
88+
89+
If the modification doesn't affect code that configures and runs Galaxy -
90+
skipping a couple tests that will cause Galaxy and its dependencies to be
91+
downloaded results in a significant speed up. This subset of tests can be
92+
run with ``make quick-test``.
9693

9794
6. Commit your changes and push your branch to GitHub::
9895

@@ -113,7 +110,81 @@ Before you submit a pull request, check that it meets these guidelines:
113110
https://travis-ci.org/galaxyproject/planemo/pull_requests
114111
and make sure that the tests pass for all supported Python versions.
115112

116-
.. Tips
117-
.. ----
118-
.. To run a subset of tests::
119-
.. $ python -m unittest tests.test_planemo
113+
Tips
114+
----
115+
116+
To run a subset of tests::
117+
118+
% make tox ENV=py27 ARGS='--tests tests/test_shed_upload.py'
119+
120+
This will use Tox_ to run the specified tests using Python 2.7. ``ENV`` here
121+
can be used to specify different Python version (e.g. ``py26``, ``py27``,
122+
``py34``). Python 3.4 is a work in progress.
123+
124+
Even more granularity is also possible by specifying specific test methods.::
125+
126+
make tox ENV=py27 ARGS='--tests tests/test_shed_upload.py:ShedUploadTestCase.test_tar_from_git'
127+
128+
129+
``tox`` can be used to run tests directly also (use ``. .venv/bin/activate``
130+
to ensure it is on your ``PATH``).
131+
132+
::
133+
134+
tox -e py27 -- --tests tests/test_shed_upload.py
135+
136+
Tox_ itself is configured to wrap nose_. One can skip Tox_ and run
137+
``nosetests`` directly.
138+
139+
::
140+
141+
nosetests tests/test_shed_upload.py
142+
143+
Tox_
144+
~~~~~~~~~~~
145+
146+
Tox_ is a tool to automate testing across different Python versions. The
147+
``tox`` executable can be supplied with a ``-e`` argument to specify a
148+
testing environment. Planemo defines the following environments:
149+
150+
``py27-lint``
151+
Lint the planemo code using Python 2.7.
152+
153+
``py34-lint``
154+
Lint the planemo code using Python 3.4 (also ensures valid Python 3
155+
syntax).
156+
157+
``py27-lint-readme``
158+
Lint the README reStructuredText.
159+
160+
``py26``
161+
Run planemo tests in Python 2.6.
162+
163+
``py27``
164+
Run planemo tests in Python 2.7.
165+
166+
``py34``
167+
Run planemo tests in Python 3.4 (not currently working).
168+
169+
170+
Pre-commit Hooks
171+
~~~~~~~~~~~~~~~~~~~~~
172+
173+
Planemo pull requests are automatically linted and tested using `TravisCI
174+
<https://travis-ci.org/galaxyproject/planemo>`__. A git pre-commit `hook
175+
<http://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks>`__ can be setup
176+
to lint and/or test Planemo before committing to catch problems that would
177+
be detected by TravisCI as early as possible.
178+
179+
The following command will install a pre-commit hook that lints the Planemo
180+
code::
181+
182+
make setup-git-hook-lint
183+
184+
To also run the faster planemo tests, the following command can be used to
185+
setup a more rigorous pre-commit hook::
186+
187+
make setup-git-hook-lint-and-test
188+
189+
.. _Tox: https://tox.readthedocs.org/en/latest/
190+
.. _nose: https://nose.readthedocs.org/en/latest/

Makefile

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# Default tests run with make test and make quick-tests
2+
NOSE_TESTS=tests planemo
3+
# Default environment for make tox
4+
ENV?=py27
5+
# Extra arguments supplied to tox command
6+
ARGS?=
7+
# Location of virtualenv used for development.
8+
VENV=.venv
9+
# Source virtualenv to execute command (flake8, sphinx, twine, etc...)
10+
IN_VENV=if [ -f $(VENV)/bin/activate ]; then . $(VENV)/bin/activate; fi;
11+
112
.PHONY: clean-pyc clean-build docs clean
213

314
help:
@@ -6,13 +17,19 @@ help:
617
@echo "clean-pyc - remove Python file artifacts"
718
@echo "clean-test - remove test and coverage artifacts"
819
@echo "setup-venv - setup a development virutalenv in current directory."
9-
@echo "lint - check style with flake8"
20+
@echo "lint - check style using tox and flake8 for Python 2 and Python 3"
1021
@echo "lint-readme - check README formatting for PyPI"
11-
@echo "test - run tests quickly with the default Python"
22+
@echo "flake8 - check style using flake8 for current Python (faster than lint)"
23+
@echo "test - run tests with the default Python (faster than tox)"
24+
@echo "quick-test - run quickest tests with the default Python"
1225
@echo "coverage - check code coverage quickly with the default Python"
1326
@echo "docs - generate Sphinx HTML documentation, including API docs"
14-
@echo "release - package and upload a release"
27+
@echo "open-docs - generate Sphinx HTML documentation and open in browser"
28+
@echo "open-rtd - open docs on readthedocs.org"
29+
@echo "open-project - open project on github"
30+
@echo "release - package, review, and upload a release"
1531
@echo "dist - package"
32+
@echo "update-extern - update external artifacts copied locally"
1633

1734
clean: clean-build clean-pyc clean-test
1835

@@ -33,17 +50,32 @@ clean-test:
3350
rm -fr htmlcov/
3451

3552
setup-venv:
36-
if [ -f .venv ]; then virtualenv .venv; fi;
37-
. .venv/bin/activate && pip install -r requirements.txt && pip install -r dev-requirements.txt
53+
if [ -f $(VENV) ]; then virtualenv $(VENV); fi;
54+
$(IN_VENV) pip install -r requirements.txt && pip install -r dev-requirements.txt
55+
56+
setup-git-hook-lint:
57+
cp scripts/pre-commit-lint .git/hooks/pre-commit
58+
59+
setup-git-hook-lint-and-test:
60+
cp scripts/pre-commit-lint-and-test .git/hooks/pre-commit
61+
62+
flake8:
63+
$(IN_VENV) flake8 --max-complexity 11 planemo tests
3864

3965
lint:
40-
if [ -f .venv/bin/activate ]; then . .venv/bin/activate; fi; flake8 --max-complexity 11 planemo tests
66+
$(IN_VENV) tox -e py27-lint && tox -e py34-lint
4167

4268
lint-readme:
43-
if [ -f .venv/bin/activate ]; then . .venv/bin/activate; fi; python setup.py check -r -s
69+
$(IN_VENV) python setup.py check -r -s
4470

4571
test:
46-
if [ -f .venv/bin/activate ]; then . .venv/bin/activate; fi; nosetests tests planemo
72+
$(IN_VENV) nosetests $(NOSE_TESTS)
73+
74+
quick-test:
75+
$(IN_VENV) PLANEMO_SKIP_GALAXY_TESTS=1 nosetests $(NOSE_TESTS)
76+
77+
tox:
78+
$(IN_VENV) tox -e $(ENV) -- $(ARGS)
4779

4880
coverage:
4981
coverage run --source planemo setup.py test
@@ -55,27 +87,29 @@ docs:
5587
rm -f docs/planemo.rst
5688
rm -f docs/planemo_ext.rst
5789
rm -f docs/modules.rst
58-
if [ -f .venv/bin/activate ]; then . .venv/bin/activate; fi; sphinx-apidoc -f -o docs/ planemo_ext planemo_ext/galaxy/eggs
59-
if [ -f .venv/bin/activate ]; then . .venv/bin/activate; fi; sphinx-apidoc -f -o docs/ planemo
60-
if [ -f .venv/bin/activate ]; then . .venv/bin/activate; fi; python scripts/commands_to_rst.py
61-
if [ -f .venv/bin/activate ]; then . .venv/bin/activate; fi; $(MAKE) -C docs clean
62-
if [ -f .venv/bin/activate ]; then . .venv/bin/activate; fi; $(MAKE) -C docs html
90+
$(IN_VENV) sphinx-apidoc -f -o docs/ planemo_ext planemo_ext/galaxy/eggs
91+
$(IN_VENV) sphinx-apidoc -f -o docs/ planemo
92+
$(IN_VENV) python scripts/commands_to_rst.py
93+
$(IN_VENV) $(MAKE) -C docs clean
94+
$(IN_VENV) $(MAKE) -C docs html
6395

64-
open-docs: docs
96+
_open-docs:
6597
open docs/_build/html/index.html || xdg-open docs/_build/html/index.html
6698

99+
open-docs: docs _open-docs
100+
67101
open-rtd: docs
68102
open https://planemo.readthedocs.org || xdg-open https://planemo.readthedocs.org
69103

70104
open-project:
71105
open https://github.com/galaxyproject/planemo || xdg-open https://github.com/galaxyproject/planemo
72106

73107
dist: clean
74-
if [ -f .venv/bin/activate ]; then . .venv/bin/activate; fi; python setup.py sdist bdist_egg bdist_wheel
108+
$(IN_VENV) python setup.py sdist bdist_egg bdist_wheel
75109
ls -l dist
76110

77111
release-test: dist
78-
if [ -f .venv/bin/activate ]; then . .venv/bin/activate; fi; twine upload -r test dist/*
112+
$(IN_VENV) twine upload -r test dist/*
79113
open https://testpypi.python.org/pypi/planemo || xdg-open https://testpypi.python.org/pypi/planemo
80114

81115
release: release-test
@@ -84,7 +118,7 @@ release: release-test
84118
done ; \
85119
[ $$CONTINUE = "y" ] || [ $$CONTINUE = "Y" ] || (echo "Exiting."; exit 1;)
86120
@echo "Releasing"
87-
if [ -f .venv/bin/activate ]; then . .venv/bin/activate; fi; twine upload dist/*
121+
$(IN_VENV) twine upload dist/*
88122

89123
update-extern:
90124
sh scripts/update_extern.sh

dev-requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
wheel==0.23.0
2-
31
# For tests
42
flask
53

docs/commands/shed_upload.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Handle possible recursion through paths for uploading files to a toolshed
1717
**Options**::
1818

1919

20-
--message TEXT Commit message for tool shed upload.
20+
-m, --message TEXT Commit message for tool shed upload.
2121
--owner TEXT Tool Shed repository owner (username).
2222
--name TEXT Tool Shed repository name (defaults to the
2323
inferred tool directory name).

docs/developing.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
==========
2-
Developing
3-
==========
4-
5-
This section contains documentation for the maintainers of planemo.
6-
1+
==================
72
Release Checklist
8-
-----------------
3+
==================
4+
5+
This page describes the process of releasing new versions of Planemo.
96

107
This release checklist is based on the `Pocoo Release Management Workflow
118
<http://www.pocoo.org/internal/release-management/>`_.

scripts/pre-commit-lint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
make lint

scripts/pre-commit-lint-and-test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
make lint
4+
make quick-test

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# TODO: add py34-lint , py34 to envlist
1+
# TODO: py34 to envlist
22
# TODO: implement doc linting
33
[tox]
4-
envlist = py27-lint, py27-lint-readme, py26, py27
4+
envlist = py34-lint, py27-lint, py27-lint-readme, py26, py27
55

66
[testenv]
77
commands = {envpython} setup.py nosetests []

0 commit comments

Comments
 (0)