Skip to content

Commit f5b6c24

Browse files
committed
add how to contribute
1 parent a36e350 commit f5b6c24

File tree

2 files changed

+232
-96
lines changed

2 files changed

+232
-96
lines changed

CONTRIBUTING.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# How to contribute
2+
3+
First of all, thanks for contributing!
4+
5+
This document provides some basic guidelines for contributing to this repository. To propose
6+
improvements or fix a bug, feel free to submit a PR.
7+
8+
## Legal requirements
9+
10+
Before we can accept your contributions you have to sign the [Contributor License Agreement][0]
11+
12+
## Prerequisites
13+
14+
To build the Arduino CLI from sources you need the following tools to be available in your local
15+
enviroment:
16+
17+
* [Go][1] version 1.12 or later
18+
* [Taskfile][2] to help you run the most common tasks from the command line
19+
20+
If you want to run integration tests you will also need:
21+
22+
* A serial port with an Arduino device attached
23+
* A working [Python][3] environment, version 3.5 or later
24+
25+
## Building the source code
26+
27+
From the project folder root, just run:
28+
29+
```shell
30+
task build
31+
```
32+
33+
The project uses Go modules so dependencies will be downloaded automatically, you should end with
34+
an `arduino-cli` executable in the same folder.
35+
36+
## Running the tests
37+
38+
There are several checks and test suites in place to ensure the code works as expected but also it
39+
is written in a way that's consistent across the whole codebase. Such tests can be run one after
40+
another by running the command:
41+
42+
```shell
43+
task test
44+
```
45+
46+
If you want to only run unit tests and skip other checks, you can run:
47+
48+
```shell
49+
task test-unit
50+
```
51+
52+
Similarly, if you're only interested in running integration tests, you can do (be sure to read the
53+
part dedicated to integration tests if something doesn't work):
54+
55+
```shell
56+
task test-integration
57+
```
58+
59+
### Integration tests
60+
61+
Being a command line interface, Arduino CLI is heavily interactive and it has to stay consistent
62+
in accepting the user input and providing the expected output and proper exit codes. On top of this,
63+
many Arduino CLI features involve communicating with external devices, most likely through a serial
64+
port, so unit tests can only put our confidence that the code is working so far.
65+
66+
For these reasons, in addition to regular unit tests the project has a suite of integration tests
67+
that actually run Arduino CLI in a different process and assess the options are correctly
68+
understood and the output is what we expect.
69+
70+
To run the full suite of integration tests you need an Arduino device attached to a serial port and
71+
a working Python environment. Chances are that you already have Python installed in your system, if
72+
this is not the case you can [download][3] the official distribution or use the package manager
73+
provided by your Operating System.
74+
75+
Some dependencies need to be installed before running the tests and to avoid polluting your global
76+
Python enviroment with dependencies that might be only used by the Arduino CLI, you can use a
77+
[virtual environment][4]. There are many ways to manage virtual environments, for example you can
78+
use a productivity tool called [hatch][5]. First you need to install it (you might need to `sudo`
79+
the following command):
80+
81+
```shell
82+
pip3 install --user hatch
83+
```
84+
85+
Then you can create a virtual environment to be used while working on Arduino CLI:
86+
87+
```shell
88+
hatch env arduino-cli
89+
```
90+
91+
At this point the virtual environment was created and you need to make it active every time you
92+
open a new terminal session with the following command:
93+
94+
```shell
95+
hatch shell arduino-cli
96+
```
97+
98+
From now on, every package installed by Python will be confined to the `arduino-cli` virtual
99+
environment, so you can proceed installing the dependencies required with:
100+
101+
```shell
102+
pip install -r test/requirements.txt
103+
```
104+
105+
If the last step was successfull, you should be able to run the tests with:
106+
107+
```shell
108+
task test-integration
109+
```
110+
111+
## Pull Requests
112+
113+
In order to ease code reviews and have your contributions merged faster, here is a list of items
114+
you can check before submitting a PR:
115+
116+
* Create small PRs that are narrowly focused on addressing a single concern.
117+
* PR titles indirectly become part of the CHANGELOG so it's crucial to provide a good
118+
record of **what** change is being made in the title; **why** it was made will go in the
119+
PR description, along with a link to a GitHub issue if it exists.
120+
* write tests for the code you wrote.
121+
* open your PR against the `master` branch.
122+
* Maintain **clean commit history** and use **meaningful commit messages**.
123+
PRs with messy commit history are difficult to review and require a lot of work to be merged.
124+
* Your PR must pass all CI tests before we will merge it. If you're seeing an error and don't think
125+
it's your fault, it may not be! The reviewer will help you if there are test failures that seem
126+
not related to the change you are making.
127+
128+
## Additional settings
129+
130+
If you need to push a commit that's only shipping documentation changes or example files, thus a
131+
complete no-op for the test suite, please start the commit message with the string **[skip ci]**
132+
to skip the build and give that slot to someone else who does need it.
133+
134+
If your PR doesn't need to be included in the changelog, please start the PR title with the string
135+
**[skip changelog]**
136+
137+
[0]: https://cla-assistant.io/arduino/arduino-cli
138+
[1]: https://golang.org/doc/install
139+
[2]: https://taskfile.dev/#/installation
140+
[3]: https://www.python.org/downloads/
141+
[4]: https://docs.python.org/3/tutorial/venv.html
142+
[5]: https://github.com/ofek/hatch

0 commit comments

Comments
 (0)