Skip to content

Commit 34273a9

Browse files
authored
Merge pull request #1 from arduino/development
Create GitHub Actions action to run Arduino Lint
2 parents 9a8a078 + b84644a commit 34273a9

File tree

18 files changed

+4525
-4790
lines changed

18 files changed

+4525
-4790
lines changed

.codespellrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[codespell]
2+
# In the event of a false positive, add the problematic word, in all lowercase, here:
3+
ignore-words-list = afterall
4+
check-filenames =
5+
check-hidden =
6+
skip = ./.git,./dist

.github/CONTRIBUTING.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Development
2+
3+
To work on the codebase you have to install all the dependencies:
4+
5+
```sh
6+
# npm install
7+
```
8+
9+
To run tests set the environment variable `GITHUB_TOKEN` with a valid Personal Access Token and then:
10+
11+
```sh
12+
# npm run test
13+
```
14+
15+
See the [official Github documentation][pat-docs] to learn more about Personal Access Tokens.
16+
17+
## Release
18+
19+
1. `npm install` to add all the dependencies, included development.
20+
1. `npm run build` to build the Action under the `./lib` folder.
21+
1. `npm run test` to see everything works as expected.
22+
1. `npm run pack` to package for distribution
23+
1. `git add src dist` to check in the code that matters.
24+
1. If the release will increment the major version, update the action refs in the examples in README.md
25+
(e.g., `uses: arduino/arduino-lint-action@v1` -> `uses: arduino/arduino-lint-action@v2`).
26+
1. open a PR and request a review.
27+
1. After PR is merged, create a release, following the `vX.X.X` tag name convention.
28+
1. After the release, rebase the release branch for that major version (e.g., `v1` branch for the v1.x.x tags) on the
29+
tag. If no branch exists for the release's major version, create one.
30+
31+
[pat-docs]: https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token

.github/workflows/integration.yml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Integration Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
schedule: # Scheduled trigger checks for breakage caused by changes to arduino-lint
7+
# run every Tuesday at 3 AM UTC
8+
- cron: "0 3 * * 2"
9+
# workflow_dispatch event allows the workflow to be triggered manually
10+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
11+
workflow_dispatch:
12+
# repository_dispatch event allows the workflow to be triggered via the GitHub API
13+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch
14+
repository_dispatch:
15+
16+
jobs:
17+
defaults:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout local repository
22+
uses: actions/checkout@v2
23+
24+
- name: Build action
25+
run: |
26+
npm install
27+
npm run build
28+
npm run pack
29+
30+
# Run the action using default values as much as possible.
31+
- name: Run action
32+
uses: ./ # Use the action from the local path.
33+
with:
34+
path: .github/workflows/testdata/SpecificationSketch
35+
36+
expected-pass:
37+
runs-on: ubuntu-latest
38+
39+
env:
40+
REPORT_FILE_PATH: /tmp/report.json
41+
steps:
42+
- name: Checkout local repository
43+
uses: actions/checkout@v2
44+
45+
- name: Build action
46+
run: |
47+
npm install
48+
npm run build
49+
npm run pack
50+
51+
# The contents of the test data path are structured so that the step will fail if arduino-lint is not run with the configuration according to these inputs.
52+
- name: Run action
53+
uses: ./
54+
with:
55+
path: .github/workflows/testdata/some-projects
56+
compliance: permissive
57+
library-manager: false
58+
project-type: library
59+
recursive: true
60+
report-file: ${{ env.REPORT_FILE_PATH }}
61+
official: true
62+
63+
- name: Verify report file exists
64+
run: |
65+
[ -e "${{ env.REPORT_FILE_PATH }}" ]
66+
67+
expected-fail:
68+
runs-on: ubuntu-latest
69+
70+
steps:
71+
- name: Checkout local repository
72+
uses: actions/checkout@v2
73+
74+
- name: Build action
75+
run: |
76+
npm install
77+
npm run build
78+
npm run pack
79+
80+
# The contents of the test data path are structured so that the step will fail if arduino-lint is run with the default configuration.
81+
- name: Run action
82+
id: arduino-lint
83+
continue-on-error: true
84+
uses: ./
85+
with:
86+
path: .github/workflows/testdata/projects
87+
88+
- name: Fail the job if the action run succeeded
89+
if: steps.arduino-lint.outcome == 'success'
90+
run: |
91+
echo "::error::The action run was expected to fail, but passed!"
92+
exit 1

.github/workflows/spell-check.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Spell Check
2+
3+
on:
4+
pull_request:
5+
push:
6+
schedule: # Schedule trigger for catching new misspelling detections resulting from dictionary updates.
7+
# Run every Saturday at 3 AM UTC.
8+
- cron: "0 3 * * 2"
9+
# workflow_dispatch event allows the workflow to be triggered manually
10+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
11+
workflow_dispatch:
12+
# repository_dispatch event allows the workflow to be triggered via the GitHub API
13+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch
14+
repository_dispatch:
15+
16+
jobs:
17+
spellcheck:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v2
23+
24+
# See: https://github.com/codespell-project/actions-codespell/blob/master/README.md
25+
- name: Spell check
26+
uses: codespell-project/actions-codespell@master

.github/workflows/test.yml

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Test Action
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
pull_request:
46

57
jobs:
68
test:
@@ -11,14 +13,19 @@ jobs:
1113

1214
strategy:
1315
matrix:
14-
operating-system: [ubuntu-latest, windows-latest]
16+
operating-system:
17+
- ubuntu-latest
18+
- windows-latest
1519

1620
steps:
21+
- name: Disable EOL conversions
22+
run: git config --global core.autocrlf false
23+
1724
- name: Checkout
18-
uses: actions/checkout@master
25+
uses: actions/checkout@v2
1926

2027
- name: Set Node.js 10.x
21-
uses: actions/setup-node@v1.4.4
28+
uses: actions/setup-node@v1
2229
with:
2330
node-version: 10.x
2431

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
void setup() {}
2+
void loop() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
void setup() {}
2+
void loop() {}

.github/workflows/testdata/some-projects/PermissiveLibrary/PermissiveLibrary.h

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name=ArduinoGraphics
2+
version=1.0.0
3+
author=Cristian Maglie <[email protected]>, Pippo Pluto <[email protected]>
4+
maintainer=Cristian Maglie <[email protected]>
5+
sentence=A library that requires the permissive compliance setting to pass the checks.
6+
paragraph=
7+
category=Other
8+
url=http://example.com/
9+
architectures=avr
10+
# Invalid permissive value only allowed in permissive compliance mode
11+
permissive=foo

README.md

+104-46
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,124 @@
1-
# setup-arduino-cli
1+
# `arduino/arduino-lint-action`
22

3-
[![Actions Status](https://github.com/arduino/setup-arduino-cli/workflows/Test%20Action/badge.svg)](https://github.com/arduino/setup-arduino-cli/actions)
3+
[![Tests Status](https://github.com/arduino/arduino-lint-action/workflows/Test%20Action/badge.svg)](https://github.com/arduino/arduino-lint-action/actions?workflow=Test+Action)
4+
[![Integration Tests Status](https://github.com/arduino/arduino-lint-action/workflows/Integration%20Tests/badge.svg)](https://github.com/arduino/arduino-lint-action/actions?workflow=Integration+Tests)
5+
[![Spellcheck Status](https://github.com/arduino/arduino-lint-action/workflows/Spell%20Check/badge.svg)](https://github.com/arduino/arduino-lint-action/actions?workflow=Spell+Check)
46

5-
This action makes the `arduino-cli` tool available to Workflows.
7+
[GitHub Actions](https://docs.github.com/en/free-pro-team@latest/actions) action that uses
8+
[Arduino Lint](https://github.com/arduino/arduino-lint) to check for problems with [Arduino](https://www.arduino.cc/)
9+
projects:
610

7-
## Usage
11+
- Libraries
12+
- Sketches
13+
- Boards platforms
814

9-
To get the latest stable version of `arduino-cli` just add this step:
15+
## Table of contents
1016

11-
```yaml
12-
- name: Install Arduino CLI
13-
uses: arduino/[email protected]
14-
```
17+
<!-- toc -->
1518

16-
If you want to pin a major or minor version you can use the `.x` wildcard:
19+
- [Inputs](#inputs)
20+
- [`path`](#path)
21+
- [`version`](#version)
22+
- [`compliance`](#compliance)
23+
- [`format`](#format)
24+
- [`library-manager`](#library-manager)
25+
- [`project-type`](#project-type)
26+
- [`recursive`](#recursive)
27+
- [`report-file`](#report-file)
28+
- [`token`](#token)
29+
- [Usage](#usage)
1730

18-
```yaml
19-
- name: Install Arduino CLI
20-
uses: arduino/[email protected]
21-
with:
22-
version: "0.x"
23-
```
31+
<!-- tocstop -->
2432

25-
To pin the exact version:
33+
## Inputs
2634

27-
```yaml
28-
- name: Install Arduino CLI
29-
uses: arduino/[email protected]
30-
with:
31-
version: "0.5.0"
32-
```
35+
### `path`
3336

34-
## Examples
37+
Path containing Arduino project(s).
3538

36-
[Here][example] there is a good example on how to use the action.
37-
See also the [Arduino on GitHub Actions blogpost][blogpost] to learn more.
39+
**Default**: `./`
3840

39-
## Development
41+
### `version`
4042

41-
To work on the codebase you have to install all the dependencies:
43+
The version of [Arduino Lint](https://github.com/arduino/arduino-lint) to use.
44+
Can be an exact version (e.g., `1.0.0`) or a version range (e.g., `1.x`).
4245

43-
```sh
44-
# npm install
45-
```
46+
**Default**: `1.x`
4647

47-
To run tests set the environment variable `GITHUB_TOKEN` with a valid Personal Access Token and then:
48+
### `compliance`
4849

49-
```sh
50-
# npm run test
51-
```
50+
Configure how strict the tool is about which checks are considered errors vs warnings if they don't pass.
51+
52+
#### Supported values
53+
54+
- `strict` - enforces best practices, above and beyond the minimum requirements for specification compliance. Use this setting to ensure the best experience for the users of the project.
55+
- `specification` - enforces compliance with the official Arduino project specifications.
56+
- `permissive` - will cause the checks to fail only when severe problems are found. Although a project that passes at the permissive setting will work with the current Arduino development software versions, it may not be fully specification-compliant, risking incompatibility or a poor experience for the users.
57+
58+
**Default**: `specification`
59+
60+
### `library-manager`
61+
62+
Configure the checks for libraries in the [Arduino Library Manager](https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ) index.
63+
64+
#### Supported values
65+
66+
- `submit` - Also run additional checks required to pass before a library is accepted for inclusion in the index.
67+
- `update`- Also run additional checks required to pass before a library is accepted for inclusion in the index.
68+
- `false` - Don't run any Library Manager-specific checks.
69+
70+
**Default**: `submit` for libraries, `false` for other project types
71+
72+
### `project-type`
73+
74+
Configures which types of projects to check, along with their subprojects.
5275

53-
See the [official Github documentation][pat-docs] to know more about Personal Access Tokens.
76+
#### Supported values
77+
78+
- `sketch`
79+
- `library`
80+
- `all` - Run checks on any type of project that is detected
81+
82+
**Default**: `all`
83+
84+
### `recursive`
85+
86+
Set to `true` to search path recursively for Arduino projects to check.
87+
88+
**Default**: `false`
89+
90+
### `report-file`
91+
92+
Save a JSON formatted report on the checks to this file.
93+
94+
### `verbose`
95+
96+
Set to `true` to show more information in the log about the checks being run.
97+
98+
**Default**: `false`
99+
100+
### `token`
101+
102+
GitHub access token used to get information from the GitHub API.
103+
104+
**Default**: [`GITHUB_TOKEN`](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow)
105+
106+
## Usage
107+
108+
The minimal workflow to run the default checks on the projects in the repository:
109+
110+
```yaml
111+
on: [push, pull_request]
112+
jobs:
113+
lint:
114+
runs-on: ubuntu-latest
115+
steps:
116+
- uses: actions/checkout@v2
117+
- uses: arduino/arduino-lint-action@v1
118+
```
54119
55-
## Release
120+
## Contributing
56121
57-
1. `npm install` to add all the dependencies, included development.
58-
2. `npm run build` to build the Action under the `./lib` folder.
59-
3. `npm run test` to see everything works as expected.
60-
4. `npm run pack` to package for distribution
61-
5. `git add src dist` to check in the code that matters.
62-
6. open a PR and request a review.
122+
To report bugs or make feature requests, please submit an issue: https://github.com/arduino/arduino-lint-action/issues
63123
64-
[pat-docs]: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token
65-
[example]: https://github.com/arduino/arduino-cli-example/blob/master/.github/workflows/test.yaml
66-
[blogpost]: https://blog.arduino.cc/2019/11/14/arduino-on-github-actions/
124+
Pull requests are welcome! Please see the [contribution guidelines](.github/CONTRIBUTING.md) for information.

0 commit comments

Comments
 (0)