Skip to content

Commit 870a43e

Browse files
authored
Merge pull request #7 from ewoks-kit/6-contributing-for-ruff
add CONTRIBUTING file generation
2 parents 5b39f84 + da75e7e commit 870a43e

16 files changed

Lines changed: 347 additions & 7 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Check generated files
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
check-generated:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Run generation script
20+
run: scripts/github_generate.sh
21+
22+
- name: Check for uncommitted changes
23+
run: git diff --exit-code

scripts/contributing/build_docs.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Build documentation
2+
3+
The documentation is built with [Sphinx](https://www.sphinx-doc.org/en/master/) that generates HTML pages out of the RST files. The configuration of Sphinx is in `doc/conf.py`.
4+
5+
Requirements (including Sphinx) can be installed with
6+
7+
```bash
8+
pip install .[doc]
9+
```
10+
11+
Then, build the documentation with
12+
13+
```bash
14+
sphinx-build doc build/sphinx/html -E -a
15+
```
16+
17+
The generated HTML pages will be available in `build/sphinx/html`. You can browse them by opening `build/sphinx/html/index.html` in your browser.
18+
19+
When rebuilding the documentation, don't forget to remove generated files to have a fresh `autodoc` documentation:
20+
21+
```bash
22+
rm -rf doc/_generated/; sphinx-build doc build/sphinx/html -E -a
23+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Formatting
2+
3+
All code must be formatted with [black](https://black.readthedocs.io/en/stable) latest version or the CI will break. Editor integration such as [Black VSCode extension](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter) or [Git hooks](https://git-scm.com/book/ms/v2/Customizing-Git-Git-Hooks) can be set-up for automatic formatting.
4+
5+
The configuration can be found in `pyproject.toml`.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Formatting
2+
3+
[ruff](https://docs.astral.sh/ruff/) is used to format the code. It gives formatting equivalent to [black](https://docs.astral.sh/ruff/faq/#how-does-ruffs-formatter-compare-to-black).
4+
5+
Editor integration such as [Ruff VSCode extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) or [Git hooks](https://git-scm.com/book/ms/v2/Customizing-Git-Git-Hooks) can be set-up for automatic formatting.
6+
7+
The configuration can be found in `pyproject.toml` under `[tool.ruff.format]` sections.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Getting started
2+
3+
Requirements are listed in `pyproject.toml` and can be installed with
4+
5+
```bash
6+
pip install [--user] .[dev]
7+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Import order
2+
3+
Order of imports is enforced by [isort](https://pycqa.github.io/isort/). Same as for black, editor extensions such as [isort VSCode extension](https://marketplace.visualstudio.com/items?itemName=ms-python.isort) can be used to sort imports automatically when saving.
4+
5+
The configuration in `pyproject.toml` is made to be [compatible with black](https://pycqa.github.io/isort/docs/configuration/black_compatibility.html).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Import order
2+
3+
Order of imports is enforced by [ruff](https://docs.astral.sh/ruff/) **linter**. The [imports can be automatically sorted](https://docs.astral.sh/ruff/formatter/#sorting-imports) by running:
4+
5+
```bash
6+
ruff check --select I --fix
7+
ruff format
8+
```
9+
10+
As for formatting, we advise to use the [Ruff VSCode extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) or [a Git hook](https://git-scm.com/book/ms/v2/Customizing-Git-Git-Hooks) to sort imports automatically when saving.
11+
12+
Configuration can be found in `pyproject.toml` under `[tool.ruff.lint.isort]` sections.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Linting
2+
3+
[flake8](https://flake8.pycqa.org/en/latest/index.html) is used to lint the code.
4+
5+
The configuration is located in `.flake8`. It is written specifically to be compatible with black so that changes should not be needed. If needed, linting errors can be [ignored inline by adding comments](https://flake8.pycqa.org/en/latest/user/violations.html#in-line-ignoring-errors) (e.g.`# noqa: E123`).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Linting
2+
3+
[ruff](https://docs.astral.sh/ruff/) is used to lint the code. The linting is equivalent to [flake8](https://docs.astral.sh/ruff/faq/#how-does-ruffs-linter-compare-to-flake8) linting.
4+
5+
[Configuration](https://docs.astral.sh/ruff/configuration/) can be changed in `pyproject.toml` but the default configuration is compatible with black so that changes should not be needed. If needed, linting errors can be [ignored inline by adding comments](https://docs.astral.sh/ruff/linter/#line-level) (e.g.`# noqa: E123`).

scripts/contributing/releasing.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Releasing
2+
3+
1. Checkout `main` and verify that it is up to date with the server and that your working tree is clean.
4+
5+
1. Add the [changes](https://changelog.md) to `CHANGELOG.md` under a version number that matches the
6+
[regex pattern](https://regex101.com/r/Ly7O1x/3/) provided by the [semantic versioning](https://semver.org)
7+
guidelines. For example the lifecycle of a single version could be
8+
9+
```
10+
1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-beta < 1.0.0-beta.1 < 1.0.0-rc.1 < 1.0.0
11+
```
12+
13+
1. Change the version number in `<project>/pyproject.toml` to the version number put in the CHANGELOG.
14+
15+
1. Push your changes to a branch and create a MR to merge your changes in `main`.
16+
17+
1. Deploy the project using one of the two methods below:
18+
19+
- Deploy through CI jobs (recommended)
20+
21+
Once the tests have passed on `main`, CI jobs for deployment on [pypi](https://pypi.org) and [testpypi](https://test.pypi.org)
22+
will be available in the CI pipeline page. Launching these jobs manually will trigger the deployment on the corresponding
23+
python package index. In case of the `pypi` job a git tag for the version will be added to the repository.
24+
25+
- Deploy manually from the terminal with `build` and `twine`
26+
27+
```bash
28+
rm -rf dist
29+
pip install build
30+
python3 -m build -s
31+
twine upload -r testpypi dist/*
32+
twine upload -r pypi dist/*
33+
```
34+
35+
1. A git tag for the version is created automatically when deploying through the `pypi` CI job. Manual deployment however
36+
requires manual tagging
37+
38+
```bash
39+
git tag v1.2.3
40+
git push && git push --tags
41+
```
42+
43+
Release notes can be added in the `Tags` page of the gitlab repository.

0 commit comments

Comments
 (0)