Skip to content

Commit b17d17d

Browse files
committed
Update the contributing guide to be focused on contribution
The contributing guide was mainly a development and maintainer' guide, not really saying much about how to contribute itself. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 9923e60 commit b17d17d

File tree

6 files changed

+282
-1088
lines changed

6 files changed

+282
-1088
lines changed
Lines changed: 47 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -1,235 +1,65 @@
1-
# Contributing to {{cookiecutter.title}}
1+
# Contributing Guide
22

3-
## Build
3+
We are very glad that you want to contribute to {{cookiecutter.title}}. Welcome!
44

5-
You can use `build` to simply build the source and binary distribution:
5+
This guide will help you get started with the project and explain how you can
6+
contribute to it.
67

7-
```sh
8-
python -m pip install build
9-
python -m build
10-
```
118

12-
## Local development
13-
{%- if cookiecutter.type == "api" %}
9+
## Reporting bugs or requesting new features or enhancements
1410

15-
You need to make sure you have the `git submodules` updated:
11+
If you find a bug or want to propose a change or enhancement, please [open an
12+
issue].
1613

17-
```sh
18-
git submodule update --init
19-
```
14+
Make sure to include a clear description of the bug and steps to reproduce it.
15+
The most comprehensive and clear the report, the more chances are that we can
16+
act on it.
2017

21-
### Running protolint
18+
## Contributing code
2219

23-
To make sure some common mistakes are avoided and to ensure a consistent style
24-
it is recommended to run `protolint`. After you [installed
25-
`protolint`](https://github.com/yoheimuta/protolint#installation), just run:
20+
If you plan to contribute code, you probably want to check out the [development
21+
guide]. This guide explains how to install dependencies and run tests.
2622

27-
```sh
28-
protolint lint proto
29-
```
23+
If you want to fix a small bug or contribute some small improvements, you are
24+
very welcome to [submit a pull request](#submitting-a-pull-request) directly.
3025

31-
### Python setup
32-
{%- endif %}
26+
When a contribution is expected to take a non-trivial amount of time, we prefer
27+
if you first [open an issue] (in case of a bug fix or a small improvement), or
28+
[submit an idea] (in case of a big feature or change) to make sure that your
29+
contribution fits the project's goals and that you are not duplicating work.
3330

34-
You can use editable installs to develop the project locally (it will install
35-
all the dependencies too):
31+
This will help avoid wasting time and effort, either because the change doesn't
32+
fit our goals or because it could have been addressed differently, and it also
33+
helps keeping frustration low and motivation high.
3634

37-
```sh
38-
python -m pip install -e .
39-
```
40-
{%- if cookiecutter.type == "api" %}
35+
After the details on how the issue or enhancement should be addressed, you can
36+
start working on it with the confidence that the results have a high change of
37+
getting accepted and [submit a pull request](#submitting-a-pull-request) with
38+
the results of your work.
4139

42-
This will also generate the Python files from the `proto/` files and leave them
43-
in `py/`, so you can inspect them.
44-
{%- endif %}
40+
### Submitting a pull request
4541

46-
Or you can install all development dependencies (`mypy`, `pylint`, `pytest`,
47-
etc.) in one go too:
48-
```sh
49-
python -m pip install -e .[dev]
50-
```
42+
If you are not familiar with how, please read [GitHub's guide on how to create
43+
a pull
44+
request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).
5145

52-
If you don't want to install all the dependencies, you can also use `nox` to
53-
run the tests and other checks creating its own virtual environments:
46+
At a bare minimum you should follow this checklist:
5447

55-
```sh
56-
python -m pip install .[dev-noxfile]
57-
nox
58-
```
48+
- [x] All tests and checks pass. Please check the [development guide] for more
49+
information on how to run tests and checks.
50+
- [x] Both code comments (*docstrings*, etc.) and user documentation
51+
(`README.md`, `docs/`, etc.) are up-to-date and reflect the changes you
52+
made.
53+
- [x] The generated documentation can be built, and it looks good. Please also
54+
check the [development guide] for more information on this.
55+
- [x] Update the `RELEASE_NOTES.md` file in case there are user-visible
56+
changes.
57+
- [x] Appropriately [link the corresponding
58+
issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue)
59+
if the pull request is addressing one.
5960

60-
You can also use `nox -R` to reuse the current testing environment to speed up
61-
test at the expense of a higher chance to end up with a dirty test environment.
62-
{%- if cookiecutter.type == "api" %}
6361

64-
### Upgrading dependencies
65-
66-
If you want to update the dependency `frequenz-api-common`, then you need to:
67-
68-
1. Update the submodule `frequenz-api-common`
69-
2. Update the version of the `frequenz-api-common` package in `pyproject.toml`
70-
71-
The version of `frequenz-api-common` used in both places mentioned above should
72-
be the same.
73-
74-
Here is an example of upgrading the `frequenz-api-common` dependency to version
75-
`v0.2.0`:
76-
```sh
77-
ver="0.2.0"
78-
ver_minor=$(echo $ver | cut -d. -f1,2)
79-
80-
cd submodules/frequenz-api-common
81-
git remote update
82-
git checkout v${ver}
83-
cd -
84-
85-
sed 's/frequenz-api-common == [0-9]\.[0-9]\.[0-9]/frequenz-api-common == '"${ver}/" -i pyproject.toml
86-
sed 's|https://frequenz-floss.github.io/frequenz-api-common/v[0-9]\.[0-9]/objects.inv|https://frequenz-floss.github.io/frequenz-api-common/v'${ver_minor}'/objects.inv|' -i mkdocs.yml
87-
```
88-
{%- endif %}
89-
90-
### Running tests / checks individually
91-
92-
For a better development test cycle you can install the runtime and test
93-
dependencies and run `pytest` manually.
94-
95-
```sh
96-
python -m pip install .[dev-pytest] # included in .[dev] too
97-
98-
# And for example
99-
pytest tests/test_*.py
100-
```
101-
102-
Or you can use `nox`:
103-
104-
```sh
105-
nox -R -s pytest -- test/test_*.py
106-
```
107-
108-
The same appliest to `pylint` or `mypy` for example:
109-
110-
```sh
111-
nox -R -s pylint -- test/test_*.py
112-
nox -R -s mypy -- test/test_*.py
113-
```
114-
115-
### Building the documentation
116-
117-
To build the documentation, first install the dependencies (if you didn't
118-
install all `dev` dependencies):
119-
120-
```sh
121-
python -m pip install -e .[dev-mkdocs]
122-
```
123-
124-
Then you can build the documentation (it will be written in the `site/`
125-
directory):
126-
127-
```sh
128-
mkdocs build
129-
```
130-
131-
Or you can just serve the documentation without building it using:
132-
133-
```sh
134-
mkdocs serve
135-
```
136-
137-
Your site will be updated **live** when you change your files (provided that
138-
you used `pip install -e .`, beware of a common pitfall of using `pip install`
139-
without `-e`, in that case the API reference won't change unless you do a new
140-
`pip install`).
141-
142-
To build multi-version documentation, we use
143-
[mike](https://github.com/jimporter/mike). If you want to see how the
144-
multi-version sites looks like locally, you can use:
145-
146-
```sh
147-
mike deploy my-version
148-
mike set-default my-version
149-
mike serve
150-
```
151-
152-
`mike` works in mysterious ways. Some basic information:
153-
154-
* `mike deploy` will do a `mike build` and write the results to your **local**
155-
`gh-pages` branch. `my-version` is an arbitrary name for the local version
156-
you want to preview.
157-
* `mike set-default` is needed so when you serve the documentation, it goes to
158-
your newly produced documentation by default.
159-
* `mike serve` will serve the contents of your **local** `gh-pages` branch. Be
160-
aware that, unlike `mkdocs serve`, changes to the sources won't be shown
161-
live, as the `mike deploy` step is needed to refresh them.
162-
163-
Be careful not to use `--push` with `mike deploy`, otherwise it will push your
164-
local `gh-pages` branch to the `origin` remote.
165-
166-
That said, if you want to test the actual website in **your fork**, you can
167-
always use `mike deploy --push --remote your-fork-remote`, and then access the
168-
GitHub pages produced for your fork.
169-
170-
## Releasing
171-
172-
These are the steps to create a new release:
173-
174-
1. Get the latest head you want to create a release from.
175-
176-
2. Update the `RELEASE_NOTES.md` file if it is not complete, up to date, and
177-
remove template comments (`<!-- ... ->`) and empty sections. Submit a pull
178-
request if an update is needed, wait until it is merged, and update the
179-
latest head you want to create a release from to get the new merged pull
180-
request.
181-
182-
3. Create a new signed tag using the release notes and
183-
a [semver](https://semver.org/) compatible version number with a `v` prefix,
184-
for example:
185-
186-
```sh
187-
git tag -s --cleanup=whitespace -F RELEASE_NOTES.md v0.0.1
188-
```
189-
190-
4. Push the new tag.
191-
192-
5. A GitHub action will test the tag and if all goes well it will create
193-
a [GitHub
194-
Release](https://github.com/{{cookiecutter.github_org}}/{{cookiecutter.github_repo_name}}/releases),
195-
and upload a new package to
196-
[PyPI](https://pypi.org/project/{{cookiecutter.pypi_package_name}}/)
197-
automatically.
198-
199-
6. Once this is done, reset the `RELEASE_NOTES.md` with the template:
200-
201-
```sh
202-
cp .github/RELEASE_NOTES.template.md RELEASE_NOTES.md
203-
```
204-
205-
Commit the new release notes and create a PR (this step should be automated
206-
eventually too).
207-
208-
7. Celebrate!
209-
210-
## Cross-Arch Testing
211-
212-
This project has built-in support for testing across multiple architectures.
213-
Currently, our CI conducts tests on `arm64` machines using QEMU emulation. We
214-
also have the flexibility to expand this support to include additional
215-
architectures in the future.
216-
217-
This project contains Dockerfiles that can be used in the CI to test the
218-
python package in non-native machine architectures, e.g., `arm64`. The
219-
Dockerfiles exist in the directory `.github/containers/nox-cross-arch`, and
220-
follow a naming scheme so that they can be easily used in build matrices in the
221-
CI, in `nox-cross-arch` job. The naming scheme is:
222-
223-
```
224-
<arch>-<os>-python-<python-version>.Dockerfile
225-
```
226-
227-
E.g.,
228-
229-
```
230-
arm64-ubuntu-20.04-python-3.11.Dockerfile
231-
```
232-
233-
If a Dockerfile for your desired target architecture, OS, and python version
234-
does not exist here, please add one before proceeding to add your options to
235-
the test matrix.
62+
[open an issue]: https://github.com/{{cookiecutter.github_org}}/{{cookiecutter.github_repo_name}}/issues/new/choose
63+
[submit an idea]: https://github.com/{{cookiecutter.github_org}}/{{cookiecutter.github_repo_name}}/discussions/new?category=ideas
64+
[submit a pull]: https://github.com/{{cookiecutter.github_org}}/{{cookiecutter.github_repo_name}}/compare
65+
[development guide]: DEVELOPMENT.md

0 commit comments

Comments
 (0)