Unverified Commit 44d0f4de authored by Massimiliano Pippi's avatar Massimiliano Pippi Committed by GitHub

[ci skip] mention style check (#460)

parent 3ad5e1a3
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
First of all, thanks for contributing! First of all, thanks for contributing!
This document provides some basic guidelines for contributing to this repository. To propose This document provides some basic guidelines for contributing to this
improvements or fix a bug, feel free to submit a PR. repository. To propose improvements or fix a bug, feel free to submit a PR.
## Legal requirements ## Legal requirements
...@@ -11,8 +11,8 @@ Before we can accept your contributions you have to sign the [Contributor Licens ...@@ -11,8 +11,8 @@ Before we can accept your contributions you have to sign the [Contributor Licens
## Prerequisites ## Prerequisites
To build the Arduino CLI from sources you need the following tools to be available in your local To build the Arduino CLI from sources you need the following tools to be
enviroment: available in your local enviroment:
* [Go][1] version 1.12 or later * [Go][1] version 1.12 or later
* [Taskfile][2] to help you run the most common tasks from the command line * [Taskfile][2] to help you run the most common tasks from the command line
...@@ -30,27 +30,31 @@ From the project folder root, just run: ...@@ -30,27 +30,31 @@ From the project folder root, just run:
task build task build
``` ```
The project uses Go modules so dependencies will be downloaded automatically, you should end with The project uses Go modules so dependencies will be downloaded automatically;
an `arduino-cli` executable in the same folder. at the end of the build, you should find an `arduino-cli` executable in the
same folder.
## Running the tests ## Running the tests
There are several checks and test suites in place to ensure the code works as expected but also it There are several checks and test suites in place to ensure the code works as
is written in a way that's consistent across the whole codebase. Such tests can be run one after expected but it's also written in a way that's consistent across the whole
another by running the command: codebase. To avoid pushing changes that will cause the CI system to fail, you
can run most of the tests locally.
To ensure code style is consistent, run:
```shell ```shell
task test task check
``` ```
If you want to only run unit tests and skip other checks, you can run: To run unit tests:
```shell ```shell
task test-unit task test-unit
``` ```
Similarly, if you're only interested in running integration tests, you can do (be sure to read the To run integration tests (these will take some time and require special setup,
part dedicated to integration tests if something doesn't work): see following paragraph):
```shell ```shell
task test-integration task test-integration
...@@ -58,45 +62,49 @@ task test-integration ...@@ -58,45 +62,49 @@ task test-integration
### Integration tests ### Integration tests
Being a command line interface, Arduino CLI is heavily interactive and it has to stay consistent Being a command line interface, Arduino CLI is heavily interactive and it has to
in accepting the user input and providing the expected output and proper exit codes. On top of this, stay consistent in accepting the user input and providing the expected output
many Arduino CLI features involve communicating with external devices, most likely through a serial and proper exit codes. On top of this, many Arduino CLI features involve
communicating with external devices, most likely through a serial
port, so unit tests can only put our confidence that the code is working so far. port, so unit tests can only put our confidence that the code is working so far.
For these reasons, in addition to regular unit tests the project has a suite of integration tests For these reasons, in addition to regular unit tests the project has a suite of
that actually run Arduino CLI in a different process and assess the options are correctly integration tests that actually run Arduino CLI in a different process and
understood and the output is what we expect. assess the options are correctly understood and the output is what we expect.
To run the full suite of integration tests you need an Arduino device attached to a serial port and To run the full suite of integration tests you need an Arduino device attached
a working Python environment. Chances are that you already have Python installed in your system, if to a serial port and a working Python environment. Chances are that you already
this is not the case you can [download][3] the official distribution or use the package manager have Python installed in your system, if this is not the case you can
provided by your Operating System. [download][3] the official distribution or use the package manager provided by your Operating System.
Some dependencies need to be installed before running the tests and to avoid polluting your global Some dependencies need to be installed before running the tests and to avoid
Python enviroment with dependencies that might be only used by the Arduino CLI, you can use a polluting your global Python enviroment with dependencies that might be only
[virtual environment][4]. There are many ways to manage virtual environments, for example you can used by the Arduino CLI, you can use a [virtual environment][4]. There are many
use a productivity tool called [hatch][5]. First you need to install it (you might need to `sudo` ways to manage virtual environments, for example you can use a productivity tool
called [hatch][5]. First you need to install it (you might need to `sudo`
the following command): the following command):
```shell ```shell
pip3 install --user hatch pip3 install --user hatch
``` ```
Then you can create a virtual environment to be used while working on Arduino CLI: Then you can create a virtual environment to be used while working on Arduino
CLI:
```shell ```shell
hatch env arduino-cli hatch env arduino-cli
``` ```
At this point the virtual environment was created and you need to make it active every time you At this point the virtual environment was created and you need to make it active
open a new terminal session with the following command: every time you open a new terminal session with the following command:
```shell ```shell
hatch shell arduino-cli hatch shell arduino-cli
``` ```
From now on, every package installed by Python will be confined to the `arduino-cli` virtual From now on, every package installed by Python will be confined to the
environment, so you can proceed installing the dependencies required with: `arduino-cli` virtual environment, so you can proceed installing the
dependencies required with:
```shell ```shell
pip install -r test/requirements.txt pip install -r test/requirements.txt
...@@ -110,29 +118,33 @@ task test-integration ...@@ -110,29 +118,33 @@ task test-integration
## Pull Requests ## Pull Requests
In order to ease code reviews and have your contributions merged faster, here is a list of items In order to ease code reviews and have your contributions merged faster, here is
you can check before submitting a PR: a list of items you can check before submitting a PR:
* Create small PRs that are narrowly focused on addressing a single concern. * Create small PRs that are narrowly focused on addressing a single concern.
* PR titles indirectly become part of the CHANGELOG so it's crucial to provide a good * PR titles indirectly become part of the CHANGELOG so it's crucial to provide a
record of **what** change is being made in the title; **why** it was made will go in the good record of **what** change is being made in the title; **why** it was made
PR description, along with a link to a GitHub issue if it exists. will go in the PR description, along with a link to a GitHub issue if it
exists.
* Write tests for the code you wrote. * Write tests for the code you wrote.
* Open your PR against the `master` branch. * Open your PR against the `master` branch.
* Maintain **clean commit history** and use **meaningful commit messages**. * Maintain **clean commit history** and use **meaningful commit messages**.
PRs with messy commit history are difficult to review and require a lot of work to be merged. PRs with messy commit history are difficult to review and require a lot of
* Your PR must pass all CI tests before we will merge it. If you're seeing an error and don't think work to be merged.
it's your fault, it may not be! The reviewer will help you if there are test failures that seem * Your PR must pass all CI tests before we will merge it. If you're seeing an error and don't think
it's your fault, it may not be! The reviewer will help you if there are test
failures that seem
not related to the change you are making. not related to the change you are making.
## Additional settings ## Additional settings
If you need to push a commit that's only shipping documentation changes or example files, thus a If you need to push a commit that's only shipping documentation changes or
complete no-op for the test suite, please start the commit message with the string **[skip ci]** example files, thus a complete no-op for the test suite, please start the commit
to skip the build and give that slot to someone else who does need it. message with the string **[skip ci]** to skip the build and give that slot to
someone else who does need it.
If your PR doesn't need to be included in the changelog, please start the PR title with the string If your PR doesn't need to be included in the changelog, please start the PR
**[skip changelog]** title with the string **[skip changelog]**
[0]: https://cla-assistant.io/arduino/arduino-cli [0]: https://cla-assistant.io/arduino/arduino-cli
[1]: https://golang.org/doc/install [1]: https://golang.org/doc/install
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment