With more developers working in more projects it would be nice to have some easily deployable CI settings/rules/files.
In a first pass these would probably be (for python on Github):
- A basic tox.ini file doing flake8 and pydocstyle linting (and running any tests) for python 3.
- .travis.yml for automatic
- Instructions for setting up webhooks to make the above run on (at least) every pull request.
- Merge demo into COH-tools
- Documentation and links on the Development Guidelines page.
- Stick basic setting files in an stand-alone location/repo.
Outcome
Basic settings have been done for COH-tools in /lokal-profil/COH-tools/tree/CI.
Files:
- tox.ini: Main entrypoint specifying python version to use, and tests and linting to run.
- setup.cfg: Specific settings for nosetests mostly to do with coverage.
- .travis.yml: The connection needed for TravisCI to run the tox file.
- requirements.txt: The dependencies needed to run the program. Install these using pip3 install -r requirements.txt (possibly with the --process-dependency-links flag).
- requirements-test.txt: The additional dependencies needed to run the tests.
Notes on files:
- [tox.ini] I've set pydocstyle to ignore D100-D103 errors (missing docstrings). These shouldn't be blockers for now but docstrings should be added whenever a function is updated/added. The long term goal is to not ignore these errors and local linting might wish to have these enabled. As adding your own ignores block the default ones I've also had to add D203 and D212.
- [tox.ini] I've set flake8 to ignore E501 errors (too long lines). These shouldn't be blockers for now but strings should be fixed whenever a function is updated/added. The long term goal is to not ignore these errors and local linting might wish to have these enabled. For individual exceptions (such as long urls) use the following comment at the end of the line: # noqa: E501.
- [setup.cfg] Without a proper package setup the output isn't ideal. Might consider adding cover-no-print when packages are not available and cover-inclusive when they are?
- [requirements.txt] We include mwparserfromhell here since pywikibot silently changes it behaviour (for the worse) if it is not available.
- [requirements.txt] Note that we connect to the master branch of pywikibot (not the PyPi release) and to a specific release of WikidataStuff.
- [requirements-test.txt] The first line (-r requirements.txt) ensures that the normal dependencies are also installed.
Re-use of files:
- [tox.ini] The file can be largely reused as is with the exception for [flake8] β filename, [pydocstyle] β match-dir and any unneeded ignores.
- [setup.cfg] Can be re-used as is with the exception of cover-package
- [.travis.yml] Can be re-used as is.
- [requirements.txt] Will need to be rebuilt for each repo.
- [requirements-test.txt] Can be re-used as is (but may need to be extended at a later stage).
This assumes a python3 only repo. If you also want it to be compatible with python27 a few files need to be further tweaked.
Connections:
I make connections to two services which will later vote on any PRs (and commits) allowing me to do some initial improvements before passing the PR on for review.
- I added the repo to my travis-ci.org account and enabled the "Build only if .travis.yml is present" setting. Since my TravisCI account is hooked up to my Github account it automatically added the hook to Settings β Integrations & services β Services (in GitHub).
- I also added the repo to my quantifiedcode.com account. Again since it's connected to my Github account it automatically added the hook to Settings β Webhooks (in GitHub). I normally rely on quantifiedcode to warn me about undesired (but not strictly wrong) behaviour. It is also useful to ensure you don't introduce new problems (such as missing docstrings) in a PR. It's detection algoritm isn't perfect though so I tend to use it as a recommendation rather than a blocker.
Notes on connections:
- [TravisCI] The first couple of runs will allow you to identify if any dependencies are missing from requirements.txt (in the tox_env=py3 log)
- [quantifiedcode] You can adjust the settings further by going to Settings β Webhooks and clicking the quanified code link. Specifically you can make it just trigger on PRs etc.