Skip to content

Commit 8bceb35

Browse files
committed
docs: add contribution guidelines
1 parent 949a9ed commit 8bceb35

File tree

1 file changed

+248
-0
lines changed

1 file changed

+248
-0
lines changed

Contributing.md

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
<!--
2+
# SPDX-FileCopyrightText: (c) 2025 Siemens
3+
# SPDX-License-Identifier: MIT
4+
-->
5+
6+
# Contributing to sw360python
7+
8+
We **welcome** contributions in several forms, e.g.
9+
10+
* Improve user documenting
11+
12+
* Testing
13+
* e.g. by using the SW360 base library in different scenarios
14+
* Write unit tests and learn how the code works
15+
16+
* Working on [issues](https://github.com/sw360/sw360python/issues)
17+
* Fix a bug
18+
* Add a new feature
19+
20+
* etc.
21+
22+
## Reporting Bugs
23+
24+
sw360python uses GitHub's issue tracker. All bugs and enhancements should be
25+
entered so that we don't lose track of them, can prioritize, assign, and so code
26+
fixes can refer to the bug number in its check-in comments.
27+
28+
The issue usually contains much more detail (including test cases) than can be
29+
reasonably put in check-in comments, so being able to correlate the two is
30+
important.
31+
32+
Consider the usual best practice for writing issues, among them:
33+
34+
* More verbosity rather than one liners
35+
* Screenshots are a great help
36+
* Providing example files (in case for example scanning crashes)
37+
* Please determine the version, better the commit id
38+
* Details on operating system you are using
39+
40+
## New Features
41+
42+
You can request a new feature by submitting an [issue](https://github.com/sw360/sw360python/issues/new).
43+
44+
If you would like to implement a new feature, please consider the scope of the new feature:
45+
46+
* *Large feature*: first submit an issue and communicate your proposal so that the community can
47+
review and provide feedback. Getting early feedback will help ensure your implementation work is
48+
accepted by the community. This will also allow us to better coordinate our efforts and minimize
49+
duplicated effort.
50+
* *Small feature*: can be implemented and directly submitted as a Merge Request.
51+
52+
## Setup
53+
54+
This project uses [poetry]. Have it installed and setup first.
55+
56+
To install dev-dependencies and tools:
57+
58+
```shell
59+
poetry install
60+
```
61+
62+
## Coding Conventions and Style
63+
64+
We use [Flake8](https://flake8.pycqa.org/en/latest/) to check the code style.
65+
66+
```shell
67+
poetry run flake8
68+
```
69+
70+
We use [markdownlint](https://github.com/DavidAnson/markdownlint) to check the markdownlint style.
71+
72+
```shell
73+
npx -q markdownlint-cli *.md
74+
```
75+
76+
We use [isort](https://pycqa.github.io/isort/) to order imports.
77+
78+
```shell
79+
poetry run isort .
80+
```
81+
82+
We use [mypy](https://mypy-lang.org/) for static code analysis.
83+
84+
```shell
85+
poetry run mypy .
86+
```
87+
88+
We use [codespell](https://github.com/codespell-project/codespell) to to find typos.
89+
90+
```shell
91+
poetry run codespell .
92+
```
93+
94+
On Windows you can also run `RunChecks.ps1` to run all checks at once.
95+
96+
**If one of the checks fails, the build fails ... and we probably will not merge your code...**
97+
98+
## Testing
99+
100+
```shell
101+
poetry run pytest
102+
```
103+
104+
We should always have unit test that reflect new features or other changes.
105+
106+
### Building Python package (locally)
107+
108+
The build is triggered using
109+
110+
```shell
111+
poetry build
112+
```
113+
114+
This creates the source and wheel files in ```dist/``` subdirectory -- which
115+
can then be uploaded or installed locally using ```pip```.
116+
117+
## Documentation
118+
119+
Please document you changes in [Changelog.md](Changelog.md). The text should help as well other contributors
120+
as normal users to understand what has changed.
121+
122+
Because of the many sub-commands it is at least helpful to have in the sub-command Python file
123+
a description which options really apply to this sub-command.
124+
125+
## Git Guidelines
126+
127+
### Workflow
128+
129+
We are using the [Feature Branch Workflow (also known as GitHub Flow)](https://guides.github.com/introduction/flow/),
130+
and prefer delivery as pull requests.
131+
132+
Create a feature branch:
133+
134+
```sh
135+
# Create and checkout the branch
136+
git checkout -B feat/tune-vagrant-vm
137+
```
138+
139+
Create Commits
140+
141+
```sh
142+
# Add each modified file you'd like to include in the commit
143+
git add <file1> <file2>
144+
145+
# Create a commit
146+
git commit
147+
```
148+
149+
### Git Commit
150+
151+
The cardinal rule for creating good commits is to ensure there is only one
152+
"logical change" per commit. Why is this an important rule?
153+
154+
* The smaller the amount of code being changed, the quicker & easier it is to
155+
review & identify potential flaws.
156+
157+
* If a change is found to be flawed later, it may be necessary to revert the
158+
broken commit. This is much easier to do if there are not other unrelated
159+
code changes entangled with the original commit.
160+
161+
* When troubleshooting problems using Git's bisect capability, small well
162+
defined changes will aid in isolating exactly where the code problem was
163+
introduced.
164+
165+
* When browsing history using Git annotate/blame, small well defined changes
166+
also aid in isolating exactly where & why a piece of code came from.
167+
168+
Things to avoid when creating commits
169+
170+
* Mixing whitespace changes with functional code changes.
171+
* Mixing two unrelated functional changes.
172+
* Sending large new features in a single giant commit.
173+
174+
### Git Commit Conventions
175+
176+
We use git commit as per [Conventional Changelog](https://github.com/ajoslin/conventional-changelog):
177+
178+
```none
179+
<type>(<scope>): <subject>
180+
```
181+
182+
Example:
183+
184+
```none
185+
feat(excel import): increase buffer size
186+
```
187+
188+
Allowed types:
189+
190+
* **feat**: A new feature
191+
* **fix**: A bug fix
192+
* **docs**: Documentation only changes
193+
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing
194+
semi-colons, newline, line endings, etc)
195+
* **refactor**: A code change that neither fixes a bug or adds a feature
196+
* **perf**: A code change that improves performance
197+
* **test**: Adding missing tests
198+
* **chore**: Changes to the build process or auxiliary tools and libraries such as
199+
documentation generation
200+
201+
You can add additional details after a new line to describe the change in detail or automatically
202+
close a issue on Github.
203+
204+
```none
205+
feat(CONTRIBUTING.md): create initial CONTRIBUTING.md
206+
207+
This closes #22
208+
```
209+
210+
### Upstream Sync and Clean Up
211+
212+
Prior to submitting your pull request, you might want to do a few things to clean up your branch
213+
and make it as simple as possible for the original repo's maintainer to test, accept, and merge
214+
your work.
215+
216+
If any commits have been made to the upstream main branch, you should rebase your development
217+
branch so that merging it will be a simple fast-forward that won't require any conflict resolution
218+
work.
219+
220+
```sh
221+
# Fetch upstream main and merge with your repo's main branch
222+
git checkout main
223+
git pull upstream main
224+
225+
# If there were any new commits, rebase your development branch
226+
git checkout <branch-name>
227+
git rebase main
228+
```
229+
230+
Now, it may be desirable to squash some of your smaller commits down into a small number of larger
231+
more cohesive commits. You can do this with an interactive rebase:
232+
233+
```sh
234+
# Rebase all commits on your development branch
235+
git checkout
236+
git rebase -i main
237+
```
238+
239+
This will open up a text editor where you can specify which commits to squash.
240+
241+
## Sign off your commits
242+
243+
Please sign off your commits,
244+
to show that you agree to publish your changes under the current terms and licenses of the project.
245+
246+
```shell
247+
git commit --signoff ...
248+
```

0 commit comments

Comments
 (0)