Skip to content

Commit 093ce42

Browse files
committed
docs: add CONVENTIONS.md and upadte CONTRIBUTING.md
- CONTRIBUTING.md is more about general contributing guidelines, such as creating issues, creating pull reqeusts and so on - CONVENTIONS.md defines coding, formatting, and architectural standards - CONVENTIONS.md / Guidelines for writing good functional code originates from: https://github.com/Aider-AI/conventions Signed-off-by: AtomicFS <vojtech.vesely@9elements.com>
1 parent 26426ce commit 093ce42

File tree

3 files changed

+82
-14
lines changed

3 files changed

+82
-14
lines changed

.cspell.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"words": [
4242
"BOOTLOADER",
4343
"BUILDGCC",
44+
"CODEOWNERS",
4445
"CPUS",
4546
"GOARCH",
4647
"HEALTHCHECK",
@@ -90,6 +91,8 @@
9091
"githubaction",
9192
"githubactions",
9293
"gocyclo",
94+
"gofmt",
95+
"gofumpt",
9396
"golangci",
9497
"gorecurcopy",
9598
"goreleaser",
@@ -142,6 +145,7 @@
142145
"skipframes",
143146
"sloglint",
144147
"startswith",
148+
"staticcheck",
145149
"stmsg",
146150
"testregex",
147151
"textfile",

CONTRIBUTING.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,26 @@
22

33
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.
44

5+
For coding guidelines and commit message conventions, please look into [CONVENTIONS.md](https://github.com/9elements/firmware-action/blob/main/CONVENTIONS.md).
6+
57

68
## Issues
79
As usual, [check if issue already exists](https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-issues-and-pull-requests#search-by-the-title-body-or-comments) in GitHub issue tracker.
810

9-
## Commit messages
10-
Please conform to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
11-
12-
13-
## Used tools
11+
Please use issue template if applicable.
1412

15-
### Linters
1613

17-
#### MegaLinter
18-
[MegaLinter](https://megalinter.io/latest/) is used in [GitHub Flow](https://docs.github.com/en/get-started/quickstart/github-flow), which checks all the source code.
14+
## Pull Requests / Merge Requests
1915

20-
Can be run locally, but it is pain. See [MegaLinter Runner](https://megalinter.io/latest/mega-linter-runner/).
16+
We accept GitHub pull requests.
2117

18+
Fork the project on GitHub, work in your fork and in branches, push these to your GitHub fork, and when ready, do a GitHub pull requests against [https://github.com/9elements/firmware-action](https://github.com/9elements/firmware-action).
2219

23-
#### commitlint
24-
[commitlint](https://github.com/conventional-changelog/commitlint) checks if the commit message conforms to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
20+
Organize your changes in small and meaningful commits which are easy to review. Not every commit in your pull request needs to be able to build and pass the CI tests, but the whole PR must build and pass CI all tests.
2521

26-
To run locally, check [Tooling for Conventional Commits](https://www.conventionalcommits.org/en/about/#tooling-for-conventional-commits).
22+
If the pull request closes an issue please note it as: "Fixes #NNN".
2723

2824

29-
### editorconfig
30-
Please make sure to conform to provided [editorconfig](https://editorconfig.org/).
25+
## Code Reviews
3126

27+
It is not necessary to tag anyone for review, we are using [CODEOWNERS](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) file to define individuals or teams that are responsible. They will be tagged automatically.

CONVENTIONS.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Conventions
2+
3+
4+
## File formatting
5+
6+
To maintain consistent coding styles, indentation, line length and so on we are using [.editorconfig](https://editorconfig.org/).
7+
8+
9+
## Coding style
10+
11+
For golang code, please use `gofumpt` (a strict formatter for Go language, stricter than gofmt) before contributing. On top of that please fix all reported issues by linters such as `revive`, `go vet`, `staticcheck` and `golangci-lint` (up-to-date list of used linters is in `Taskfile.yml` in `lint` task.
12+
13+
14+
## Guidelines for writing good functional code
15+
16+
When writing code, you MUST follow these principles:
17+
- Code should be easy to read and understand.
18+
- Keep the code as simple as possible. Avoid unnecessary complexity.
19+
- Use meaningful names for variables, functions, etc. Names should reveal intent.
20+
- Functions should be small and do one thing well. They should not exceed a few lines.
21+
- Function names should describe the action being performed.
22+
- Prefer fewer arguments in functions. Ideally, aim for no more than two or three.
23+
- Only use comments when necessary, as they can become outdated. Instead, strive to make the code self-explanatory.
24+
- When comments are used, they should add useful information that is not readily apparent from the code itself.
25+
- Properly handle errors and exceptions to ensure the software's robustness.
26+
- Use exceptions rather than error codes for handling errors.
27+
- Consider security implications of the code. Implement security best practices to protect against vulnerabilities and attacks.
28+
- Adhere to these 4 principles of Functional Programming:
29+
1. Pure Functions
30+
2. Immutability
31+
3. Function Composition
32+
4. Declarative Code
33+
- Do not use object oriented programming.
34+
35+
36+
## Commit message guidelines
37+
38+
Please follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
39+
40+
41+
### Developer Sign-Off
42+
43+
For purposes of tracking code-origination, we follow a simple sign-off process. If you can attest to the [Developer Certificate of Origin](https://developercertificate.org/) then you append in each git commit text a line such as:
44+
45+
```
46+
Signed-off-by: Your Name <username@youremail.com>
47+
```
48+
49+
50+
### Use of AI generated content
51+
52+
Use of AI generated content is permitted, however please mark it as AI generated in the commit message body by adding:
53+
```
54+
AI-Generated: true
55+
AI-Model: <model used>
56+
```
57+
For example:
58+
```
59+
feat(...): add new feature
60+
61+
- adding new fun thing
62+
63+
AI-Generated: true
64+
AI-Model: ChatGPT o3-mini
65+
Signed-off-by: ...
66+
```
67+
68+
This must follow [git trailer convention](https://git-scm.com/docs/git-interpret-trailers).

0 commit comments

Comments
 (0)