Contributing to Tool Inventory¶
✨ Thanks for contributing to Tool Inventory! ✨
As a contributor, here are the guidelines we would like you to follow:
- Code of conduct
- How can I contribute?
- Using the issue tracker
- Submitting a Pull Request
- Coding rules
- Working with the code
Read the reference.
We also recommend that you read How to Contribute to Open Source.
Code of conduct¶
Help us keep Tool Inventory open and inclusive. Please read and follow our Code of conduct.
How can I contribute?¶
Improve documentation¶
As a Tool Inventory user, you are the perfect candidate to help us improve our documentation: typo corrections, clarifications, more examples, etc. Take a look at the documentation issues that need help.
Please follow the Documentation guidelines.
Give feedback on issues¶
Some issues are created without information requested in the Bug report guideline. Help make them easier to resolve by adding any relevant information.
Fix bugs and implement features¶
Confirmed bugs and ready-to-implement features are marked with the help wanted label. Post a comment on an issue to indicate you would like to work on it and to request help from the community.
Using the issue tracker¶
The issue tracker is the channel for bug reports, features requests and submitting pull requests only.
Before opening an issue or a Pull Request, please use the GitHub issue search to make sure the bug or feature request hasn't been already reported or fixed.
Bug report¶
A good bug report shouldn't leave others needing to chase you for more information. Please try to be as detailed as possible in your report and fill the information requested in the Bug report template.
Feature request¶
Feature requests are welcome, but take a moment to find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible and fill the information requested in the Feature request template.
Submitting a Pull Request¶
Good pull requests, whether patches, improvements, or new features, are a fantastic help. They should remain focused in scope and avoid containing unrelated commits.
Please ask first before embarking on any significant pull requests (e.g. implementing features, refactoring code), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.
If you have never created a pull request before, welcome 🎉 😄. Here is a great tutorial on how to send one :)
Here is a summary of the steps to follow:
- Set up the workspace
- If you cloned a while ago, get the latest changes from upstream and update dependencies:
- Create a new topic branch (off the main project development branch) to contain your feature, change, or fix:
- Make your code changes, following the Coding rules
- Push your topic branch up to your fork:
- Open a Pull Request with a clear title and description.
Tips:
- For ambitious tasks, open a Pull Request as soon as possible with the
[WIP]prefix in the title, in order to get feedback and help from the community. - Allow tool-inventory maintainers to make changes to your Pull Request branch. This way, we can rebase it and make some minor changes if necessary. All changes we make will be done in new commit and we'll ask for your approval before merging them.
Coding rules¶
Source code¶
To ensure consistency and quality throughout the source code, all code modifications must have:
- No linting errors
- A test for every possible case introduced by your code change
- 100% test coverage
- Valid commit message(s)
- Documentation for new features
- Updated documentation for modified features
Documentation¶
To ensure consistency and quality, all documentation modifications must:
- Refer to brand in bold with proper capitalization, i.e. GitHub, Tool Inventory
- Prefer tables over lists when listing key values, i.e. List of options with their description
- Use links when you are referring to:
- a Tool Inventory concept described somewhere else in the documentation, i.e. How to contribute
- a third-party product/brand/service, i.e. Integrate with GitHub
- an external concept or feature, i.e. Create a GitHub release
- a package or module, i.e. The
@MicaelJarniac/tool-inventorymodule
- Use the single backtick
codequoting for:- commands inside sentences, i.e. the
poetrycommand - programming language keywords, i.e.
for,with,dict - packages or modules, i.e. The
@MicaelJarniac/tool-inventorymodule
- commands inside sentences, i.e. the
- Use the triple backtick
codeformatting for:- code examples
- configuration examples
- sequence of command lines
Commit message guidelines¶
Atomic commits¶
If possible, make atomic commits, which means: - a commit should contain exactly one self-contained functional change - a functional change should be contained in exactly one commit - a commit should not create an inconsistent state (such as test errors, linting errors, partial fix, feature with documentation etc...)
A complex feature can be broken down into multiple commits as long as each one maintains a consistent state and consists of a self-contained change.
Commit message format¶
Each commit message consists of a header, a body and a footer. The header has a special format that includes a type, a scope and a subject:
The header is mandatory and the scope of the header is optional.
The footer can contain a closing reference to an issue.
Revert¶
If the commit reverts a previous commit, it should begin with revert:, followed by the header of the reverted commit. In the body it should say: This reverts commit <hash>., where the hash is the SHA of the commit being reverted.
Type¶
The type must be one of the following:
| Type | Description |
|---|---|
| build | Changes that affect the build system or external dependencies |
| ci | Changes to our CI configuration files and scripts (example scopes: GitHub Actions) |
| docs | Documentation only changes |
| feat | A new feature |
| fix | A bug fix |
| perf | A code change that improves performance |
| refactor | A code change that neither fixes a bug nor adds a feature |
| style | Changes that do not affect the meaning of the code (white-space, formatting, etc) |
| test | Adding missing tests or correcting existing tests |
Subject¶
The subject contains succinct description of the change:
- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize first letter
- no dot (.) at the end
Body¶
Just as in the subject, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior.
Footer¶
The footer should contain any information about Breaking Changes and is also the place to reference GitHub issues that this commit Closes.
Breaking Changes should start with the word BREAKING CHANGE: with a space or two newlines. The rest of the commit message is then used for this.
Examples¶
perf(pencil): remove graphiteWidth option
BREAKING CHANGE: The graphiteWidth option has been removed.
The default graphite width of 10mm is always used for performance reasons.
Working with the code¶
Set up the workspace¶
Clone the project, configure the remotes and install the dependencies:
# Clone the repo into the current directory
git clone https://github.com/MicaelJarniac/tool-inventory
# Navigate to the newly cloned directory
cd tool-inventory
# Set up the environment
poetry install --sync --all-extras
# Set up pre-commit hooks
pre-commit install
Set up your editor¶
First of all, don't commit editor-specific configuration. That's personal, and each developer should have it locally ignored, as those files also shouldn't be on the project's .gitignore.
Here's a great article on how to do that: Don't put .idea and .vscode directories to project's .gitignore
pre-commit¶
This repository uses pre-commit to automatically check the changes prior to committing.
It can be run on demand with pre-commit run, and optionally on all files with pre-commit run --all-files.
Lint¶
This repository uses Ruff for linting and formatting.
Tips: - Set up your editor to see linting errors directly in your editor and automatically fix them on save.
Tests¶
This repository uses pytest for writing and running tests.
Before pushing your code changes make sure all tests pass and the coverage is 100%:
Docs¶
Sphinx is used to automatically parse docstrings and generate documentation.
# Change dir to /docs
cd docs/
# Update files index
sphinx-apidoc -f -o ./source ..
# Build HTML docs
make html
# On Windows
./make.bat html
Requirements¶
Read the Poetry commands docs here.
All requirements should be listed in the pyproject.toml file, under their respective sections.
To add a new requirement, run poetry add <package name>.
To see which installed packages are outdated, run poetry show --outdated.
To update installed packages, run poetry update <package name>.
Always lock the dependencies after updating them, by running poetry lock.
When updating development requirements, make sure to also update the related pre-commit hooks in .pre-commit-config.yaml.
Updating template¶
cruft can be used to update the project with the latest version of the template.
After updating, the versions of dependencies might change, so use poetry install --sync --all-extras.
Add yourself as a contributor¶
To add yourself as a contributor, follow the bot usage instructions.