Mutable defaults The Master Is full of regrets —-after Yosa Buson (1716-1784)
7.4.1. Developing principles¶
- Contributing documentation? ReST and Sphinx. Contribute as code.
- Contributing I18N translations? GNU gettext. See I18N.
- Contributing code?
- Read The Zen of Python.
- Read Python Anti-Patterns.
- Code with style. Plug pycodestyle (PEP-8), pydocstyle (PEP-257), Flake8, ISort tools into your editor.
- Use sensible commit history. (See below.)
- Run kwalitee checks locally.
kwalitee check message master..my-feature-branch
kwalitee check files master..my-feature-branch
kwalitee check authors master..my-feature-branch
kwalitee prepare release master..my-feature-branch
- Follow egoless programming principles. See Code of Conduct.
- Read the following contributing guide and developer guidelines.
7.4.2. Contributing guide¶
126.96.36.199. Bug reports and feature requests¶
If you find a bug or have a feature request, please search for already reported problems before submitting a new issue.
188.8.131.52. Code contributions¶
We follow typical GitHub flow.
- Fork this repository into your personal space.
- Start a new topical branch for any contribution. Name it sensibly,
- Test your branch on a local site. If everything works as expected, please sign your commits to indicate its quality.
- Create logically separate commits for logically separate things.
- Please add any
(addresses #123)directives in your commit log message if your pull request closes or addresses an open issue.
- Issue a pull request. If the branch is not quite ready yet, please
WIP(=work in progress) in the pull request title.
184.108.40.206. Developer Guidelines¶
Here is more detailed checklist of things to do when contributing code to Invenio.
- Before starting any wider-impact changes, submit a ticket and use a
- Found a bug in a module and have a fix for it? Great, please jump right in!
- Have a new feature request or thinking of a new facility that would impact several modules? Submit a ticket and discuss the change before starting any implementation.
- Small intra-module changes? Discuss even in small circles with the module maintainer.
- Big inter-module changes? Discuss in wider circle among module maintainers and lead developers. Take advantage of the weekly developer forum.
- Ensure there is a consensus about functionality and design before starting any implementation.
- Publish your code under GNU General Public License.
- Use GNU General Public License header following our usual style. Update copyright years.
- If you include any code, style, or icons created by others, check the original license information to make sure it can be included. Do not forget to acknowledge the original author in the THANKS file. When appropriate, commit in the original author’s name, and commit your changes on top of them.
- Willing to include your code under CERN copyright? Please send an email about this to the Lead Developer. Otherwise add a new copyright line for your institution in the files you have touched.
- Choose good starting point to build your topical branch upon.
- Fixing a bug in a given version? Start from
maint-x.y. Name your topical branch
johndoe/999-bibfoo-fix-xyzzyusing ticket number and a short branch description.
- Introducing a new feature? Always start from
- Must introduce new feature to
maint-1.1? Really? OK, so be it, but make it configurable via new
CFG_BIBFOO_XYZZYconfiguration variable. Do not rely on its existence, since people can upgrade/downgrade within
v1.1.xpoint releases frequently. Have it imported in a try/except manner and provide fallback for older point releases. Example:
- Introducing a new experimental feature? Start from
- Fixing a bug in a given version? Start from
- Make things easily configurable and reusable by others.
- Need some feature that may break existing functionality used by other production sites? Need some feature that other production sites may want to switch off? Take care and make things configurable to be able to easily share the code.
get_tag_from_name('journal title')vs hard-coded
- Enable/disable custom features via role-based access control
system, e.g. action
- Ensure configurability of functionality via
- Ensure configurability of code via
- Writing service-specific code or service-specific configuration? Use your service-specific overlay repository.
- Writing generally-interested code that may be reused by others? Write against Invenio Atlantis defaults, not against local service specific overlay assumptions and context.
- Create logically separate commits for logically separate
- Fixing a minor problem on the site of the topic branch at hand? Create separate topical branch or at least a separate logical commit.
- Having a basically working version and improving upon its performance? Maintain two separate commits.
- Committing partially working code and fixing it later? Squash the commits together.
- Commit early, commit often... all the while ensuring continuous integration principles. Make sure the topical branch is merge-ready at almost any given moment in time, even when not completed. Hence use of configurability upfront.
- See git workflow documentation on rebasing for more.
- Use sensible commit messages and stamp them with QA and ticket
- Describe what the patch does so that the commit message is self-understandable without reading the code.
- If the patch closes a ticket, use
(closes #123)ticket directive. If the patch only addresses the issue, use
(addresses #123)ticket directive.
- If you tested your code thoroughly and stand by its perfection,
Signed-off-bycommit QA stamp. If you reviewed the code created by others, use
Reviewed-byQA stamp. Helps to get them onto fast integration track.
- See git workflow documentation on commit log messages for more.
- Include test cases with the code.
- Always write unit and functional tests alongside coding. Helps making sure the code runs OK on all supported platforms. Helps speeding up the review and integration processes. Helps understanding the code written by others by looking at their unit test cases.
- Include documentation with the code.
- “It’s not finished until it’s documented.” –This may originally have been said by Tom Limoncelli.
- “Documentation isn’t done until someone else understands it.” –Originally submitted by William S. Annis on 12jan2000.
- “Good code is its own best documentation. As you’re about to add a comment, ask yourself, ‘How can I improve the code so that this comment isn’t needed?’ Improve the code and then document it to make it even clearer.”–Steve McConnell, “Code Complete”
- “If the code and the comments disagree, then both are probably wrong.” –attributed to Norm Schryer
- “Incorrect documentation is often worse than no documentation.” –Bertrand Meyer”
- Check the overall code kwalitee.
- Does your branch fully implement the functionality it promises to implement? Are all corner cases covered? E.g. citation history graph when there are no citations?
- Are you changing DB schema? Write an upgrade recipe.
- Does your branch pass all our standard kwalitee tests? Have you run invenio-check-branch locally? Does your branch pass Travis or Jenkins builds?
- Name things properly. Use
- Do not forget to sanitise all your input arguments. Escape your
HTML outputs to protect against XSS. Supply your
run_sql()arguments in a tuple to protect against SQL injection. Avoid using
- Respect minimal requirements, e.g. write for Python-2.4 for
maint-x.ybranches that still require it. Use Vagrant virtual development environment when necessary.
- Make conditional use of optional dependencies, e.g. test
try/exceptimporting. Check that the rest of the site still works OK without
- Send the code for review and integration.
- Distinguish between design-review process (that should have happened earlier, already in the first step) and the code-review process (that happens now).
- No API change, only bugfixes? All commits duly signed by authors and responsible module maintainers aka integration lieutenants? Fast integration track.
- Possible API changes, possible user/admin feature changes? Need to synchronise about needs and to ensure configurability and compatibility? Slow integration track.
- Help improving overall development, deployment, and operational
- Developers can help by adopting good practices upfront early in the process.
- Reviewers can help by using QA stamps and fast integration tracks in live sessions.
- Testers can help by widening the test suite so that nightly builds can be relied upon for deployment.
- Administrators can help by sharing needs, requirements, solutions, and “howto” recipes.
- Share thoughts, needs, requirements, solutions, “howto” recipes
- Check existing list of known bugs and known feature requests for any given module. Troubles with collections? Go to Modules/invenio-collections.
- Did you perform some service operation such as changing your site URL? Did you log the several steps needed to achieve this? Document them.
- Have you tried to improve performance of some tools Invenio relies on? Have you run experiments and obtained observations and tips on MySQL performance? Document them.