Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
644ecc5
commit da8c62b
Showing
1 changed file
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,388 @@ | ||
# Contributing to BuildURL | ||
|
||
✨ Thanks for contributing to **BuildURL**! ✨ | ||
|
||
As a contributor, here are the guidelines we would like you to follow: | ||
- [Code of conduct](#code-of-conduct) | ||
- [How can I contribute?](#how-can-i-contribute) | ||
- [Using the issue tracker](#using-the-issue-tracker) | ||
- [Submitting a Pull Request](#submitting-a-pull-request) | ||
- [Coding rules](#coding-rules) | ||
- [Working with the code](#working-with-the-code) | ||
|
||
We also recommend that you read [How to Contribute to Open Source](https://opensource.guide/how-to-contribute). | ||
|
||
<details> | ||
<summary>Quick Reference</summary> | ||
|
||
- Tools | ||
- Formatting | ||
- [Black][black] <sup>[config][pyproject_toml]</sup> | ||
- [Compatible configs][black_cc] | ||
- [isort][isort] <sup>[config][setup_cfg]</sup> | ||
- Linting | ||
- [Flake8][flake8] <sup>[config][setup_cfg]</sup> | ||
- Plugins | ||
- [flake8-black][flake8-black] | ||
- [flake8-isort][flake8-isort] | ||
- Automating | ||
- [pre-commit][pre-commit] <sup>[config][_pre-commit-config_yaml]</sup> | ||
<details> | ||
<summary>Hooks</summary> | ||
|
||
- [`isort`][isort] | ||
- [`black`][black] | ||
- [`flake8`][flake8] | ||
- [`mypy` (mirror)][pre-commit_mypy] | ||
- [`pre-commit-hooks`][pre-commit-hooks] | ||
</details> | ||
- [Semantic Pull Requests][semantic-pull-requests] | ||
- [semantic-release][semantic-release] (used indirectly) | ||
- [python-semantic-release][python-semantic-release] <sup>[config][setup_cfg]</sup> | ||
- [Codecov][codecov] | ||
- [Action][codecov-action] | ||
- [BuildURL][codecov-BuildURL] | ||
- Type checking | ||
- [Mypy][mypy] | ||
- Testing | ||
- [pytest][pytest] <sup>[config][setup_cfg]</sup> | ||
- Plugins | ||
- [pytest-cov][pytest-cov] | ||
- [Coverage.py][coveragepy] <sup>[config][setup_cfg]</sup> | ||
- Documenting | ||
- [Sphinx][sphinx] | ||
- Building | ||
- [Setuptools][setuptools] | ||
- [`setup.py`][setup_py] | ||
- Configuration Files | ||
- [`setup.cfg`][setup_cfg] | ||
- [`pyproject.toml`][pyproject_toml] | ||
- [`.pre-commit-config.yaml`][_pre-commit-config_yaml] | ||
- Standards | ||
- Commits | ||
- [Conventional Commits][conventionalcommits] | ||
- Versioning | ||
- [Semantic Versioning][semver] | ||
- Editor | ||
- [EditorConfig][editorconfig] | ||
- Guidelines | ||
- [Angular `CONTRIBUTING.md`][angular-contributing] | ||
- Workflows | ||
- https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow | ||
- https://nvie.com/posts/a-successful-git-branching-model | ||
- https://github.community/t/syncing-a-fork-leaves-me-one-commit-ahead-of-upstream-master/1435/5 | ||
- Articles | ||
- [Don't commit `.vscode`][no-editor-config-gitignore] | ||
- <https://towardsdatascience.com/state-of-the-art-python-project-setup-82a046fc1f20> (pretty bad article, but useful) | ||
|
||
[_pre-commit-config_yaml]: .pre-commit-config.yaml | ||
[pyproject_toml]: pyproject.toml | ||
[setup_cfg]: setup.cfg | ||
|
||
[setup_py]: setup.py | ||
|
||
[black]: https://github.com/psf/black | ||
[black_cc]: https://black.readthedocs.io/en/stable/compatible_configs.html | ||
[isort]: https://github.com/PyCQA/isort | ||
[flake8]: https://gitlab.com/pycqa/flake8 | ||
[flake8-black]: https://github.com/peterjc/flake8-black | ||
[flake8-isort]: https://github.com/gforcada/flake8-isort | ||
[pre-commit]: https://github.com/pre-commit/pre-commit | ||
[pre-commit-hooks]: https://github.com/pre-commit/pre-commit-hooks | ||
[pre-commit_mypy]: https://github.com/pre-commit/mirrors-mypy | ||
[rstcheck]: https://github.com/myint/rstcheck | ||
[semantic-pull-requests]: https://github.com/zeke/semantic-pull-requests | ||
[semantic-release]: https://github.com/semantic-release/semantic-release | ||
[python-semantic-release]: https://github.com/relekang/python-semantic-release | ||
[codecov]: https://codecov.io | ||
[codecov-action]: https://github.com/marketplace/actions/codecov | ||
[codecov-BuildURL]: https://app.codecov.io/gh/MicaelJarniac/BuildURL | ||
[mypy]: https://github.com/python/mypy | ||
[pytest]: https://github.com/pytest-dev/pytest | ||
[pytest-cov]: https://github.com/pytest-dev/pytest-cov | ||
[coveragepy]: https://github.com/nedbat/coveragepy | ||
[sphinx]: https://www.sphinx-doc.org | ||
[setuptools]: https://github.com/pypa/setuptools | ||
[conventionalcommits]: https://www.conventionalcommits.org | ||
[semver]: https://semver.org | ||
[no-editor-config-gitignore]: https://blog.martinhujer.cz/dont-put-idea-vscode-directories-to-projects-gitignore | ||
[editorconfig]: https://editorconfig.org | ||
[angular-contributing]: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit | ||
</details> | ||
|
||
## Code of conduct | ||
|
||
Help us keep **BuildURL** open and inclusive. Please read and follow our [Code of conduct](CODE_OF_CONDUCT.md). | ||
|
||
## How can I contribute? | ||
|
||
### Improve documentation | ||
|
||
As a **BuildURL** 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](https://github.com/MicaelJarniac/BuildURL/issues?q=is%3Aopen+label%3Adocumentation+label%3A"help+wanted"). | ||
|
||
Please follow the [Documentation guidelines](#documentation). | ||
|
||
### Give feedback on issues | ||
|
||
Some issues are created without information requested in the [Bug report guideline](#bug-report). 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](https://github.com/MicaelJarniac/BuildURL/labels/help+wanted). 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](#bug-report), [features requests](#feature-request) and [submitting pull requests](#submitting-a-pull-request) only. <!-- Please use the [Support](docs/support/README.md) and [Get help](README.md#get-help) sections for support, troubleshooting and questions. --> | ||
|
||
Before opening an issue or a Pull Request, please use the [GitHub issue search](https://github.com/MicaelJarniac/BuildURL/issues) 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](https://github.com/MicaelJarniac/BuildURL/issues/new?template=bug_report.md). | ||
|
||
### 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](https://github.com/MicaelJarniac/BuildURL/issues/new?template=feature_request.md). | ||
|
||
## 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](https://opensource.guide/how-to-contribute/#opening-a-pull-request) on how to send one :) | ||
|
||
Here is a summary of the steps to follow: | ||
|
||
1. [Set up the workspace](#set-up-the-workspace) | ||
2. If you cloned a while ago, get the latest changes from upstream and update dependencies: | ||
```bash | ||
$ git checkout main | ||
$ git pull upstream main | ||
$ pip install -U -r requirements.txt | ||
$ pip install -U -r requirements-dev.txt | ||
``` | ||
3. Create a new topic branch (off the main project development branch) to contain your feature, change, or fix: | ||
```bash | ||
$ git checkout -b <topic-branch-name> | ||
``` | ||
4. Make your code changes, following the [Coding rules](#coding-rules) | ||
5. Push your topic branch up to your fork: | ||
```bash | ||
$ git push origin <topic-branch-name> | ||
``` | ||
6. [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request/#creating-the-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 BuildURL maintainers to make changes to your Pull Request branch](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork). 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](#lint) errors | ||
- A [test](#tests) for every possible case introduced by your code change | ||
- **100%** test coverage | ||
- [Valid commit message(s)](#commit-message-guidelines) | ||
- Documentation for new features | ||
- Updated documentation for modified features | ||
|
||
### Documentation | ||
|
||
To ensure consistency and quality, all documentation modifications must: | ||
- Refer to brand in [bold](https://help.github.com/articles/basic-writing-and-formatting-syntax/#styling-text) with proper capitalization, i.e. **GitHub**, **BuildURL** | ||
- Prefer [tables](https://help.github.com/articles/organizing-information-with-tables) over [lists](https://help.github.com/articles/basic-writing-and-formatting-syntax/#lists) when listing key values, i.e. List of options with their description | ||
- Use [links](https://help.github.com/articles/basic-writing-and-formatting-syntax/#links) when you are referring to: | ||
- a **BuildURL** concept described somewhere else in the documentation, i.e. How to [contribute](CONTRIBUTING.md) | ||
- a third-party product/brand/service, i.e. Integrate with [GitHub](https://github.com) | ||
- an external concept or feature, i.e. Create a [GitHub release](https://help.github.com/articles/creating-releases) | ||
- a package or module, i.e. The [`@MicaelJarniac/BuildURL`](https://github.com/MicaelJarniac/BuildURL) module | ||
- Use the [single backtick `code` quoting](https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code) for: | ||
- commands inside sentences, i.e. the `pip` command | ||
- programming language keywords, i.e. `for`, `with`, `dict` | ||
- packages or modules, i.e. The [`@MicaelJarniac/BuildURL`](https://github.com/MicaelJarniac/BuildURL) module | ||
- Use the [triple backtick `code` formatting](https://help.github.com/articles/creating-and-highlighting-code-blocks) for: | ||
- code examples | ||
- configuration examples | ||
- sequence of command lines | ||
|
||
### Commit message guidelines | ||
|
||
#### Atomic commits | ||
|
||
If possible, make [atomic commits](https://en.wikipedia.org/wiki/Atomic_commit), 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**: | ||
|
||
```commit | ||
<type>(<scope>): <subject> | ||
<BLANK LINE> | ||
<body> | ||
<BLANK LINE> | ||
<footer> | ||
``` | ||
|
||
The **header** is mandatory and the **scope** of the header is optional. | ||
|
||
The **footer** can contain a [closing reference to an issue](https://help.github.com/articles/closing-issues-via-commit-messages). | ||
|
||
#### 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 | ||
|
||
```commit | ||
fix(pencil): stop graphite breaking when too much pressure applied | ||
``` | ||
|
||
```commit | ||
feat(pencil): add 'graphiteWidth' option | ||
Fix #42 | ||
``` | ||
|
||
```commit | ||
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](https://guides.github.com/activities/forking/#clone) the project, configure the remotes and install the dependencies: | ||
|
||
```bash | ||
# Clone the repo into the current directory | ||
git clone https://github.com/MicaelJarniac/BuildURL | ||
|
||
# Navigate to the newly cloned directory | ||
cd BuildURL | ||
|
||
# Set up the virtual environment | ||
python -m venv venv | ||
# Replace `python` with `python3` if necessary | ||
|
||
# Activate the virtual environment (Unix) | ||
source venv/bin/activate | ||
|
||
# Activate the virtual environment (Windows) | ||
.\venv\Scripts\activate | ||
|
||
# Install the dependencies | ||
# pip install -U -r requirements.txt - currently not being used | ||
pip install -U -r requirements-dev.txt | ||
|
||
# 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][no-editor-config-gitignore] | ||
|
||
### pre-commit | ||
|
||
This repository uses [pre-commit](https://pre-commit.com) 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 [flake8](https://flake8.pycqa.org) for linting and [black](https://black.readthedocs.io) for formatting. black formatting will be automatically verified and fixed. | ||
|
||
**Tips**: | ||
- [Set up your editor](#set-up-your-editor) to see linting errors directly in your editor and automatically fix them on save. | ||
|
||
### Tests | ||
|
||
This repository uses [pytest](https://docs.pytest.org) for writing and running tests. | ||
|
||
Before pushing your code changes make sure all **tests pass** and the **coverage is 100%**: | ||
|
||
```bash | ||
$ pytest --cov | ||
``` | ||
|
||
### Docs | ||
|
||
Sphinx is used to automatically parse docstrings and generate documentation. | ||
|
||
```bash | ||
# 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 | ||
|
||
Packages that are necessary for the code to run should be on [`requirements.txt`](/requirements.txt), and those only necessary while developing should be on [`requirements-dev.txt`](/requirements-dev.txt). | ||
|
||
To see which installed packages are outdated, run `pip list --outdated`. | ||
|
||
To update installed packages, run `pip install --upgrade <package name>`. | ||
|
||
To generate a list of the currently installed packages and their versions, do the following: | ||
|
||
```bash | ||
pip freeze > requirements-current.txt | ||
``` | ||
|
||
That will create a new file, `requirements-current.txt`, with them. | ||
|
||
You can then compare it with the current requirements listed in the other files, and update them as needed. |