Skip to content

Create GitHub Actions action to run Arduino Lint #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[codespell]
# In the event of a false positive, add the problematic word, in all lowercase, here:
ignore-words-list = afterall
check-filenames =
check-hidden =
skip = ./.git,./dist
31 changes: 31 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## Development

To work on the codebase you have to install all the dependencies:

```sh
# npm install
```

To run tests set the environment variable `GITHUB_TOKEN` with a valid Personal Access Token and then:

```sh
# npm run test
```

See the [official Github documentation][pat-docs] to learn more about Personal Access Tokens.

## Release

1. `npm install` to add all the dependencies, included development.
1. `npm run build` to build the Action under the `./lib` folder.
1. `npm run test` to see everything works as expected.
1. `npm run pack` to package for distribution
1. `git add src dist` to check in the code that matters.
1. If the release will increment the major version, update the action refs in the examples in README.md
(e.g., `uses: arduino/arduino-lint-action@v1` -> `uses: arduino/arduino-lint-action@v2`).
1. open a PR and request a review.
1. After PR is merged, create a release, following the `vX.X.X` tag name convention.
1. After the release, rebase the release branch for that major version (e.g., `v1` branch for the v1.x.x tags) on the
tag. If no branch exists for the release's major version, create one.

[pat-docs]: https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token
92 changes: 92 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Integration Tests

on:
pull_request:
push:
schedule: # Scheduled trigger checks for breakage caused by changes to arduino-lint
# run every Tuesday at 3 AM UTC
- cron: "0 3 * * 2"
# workflow_dispatch event allows the workflow to be triggered manually
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# repository_dispatch event allows the workflow to be triggered via the GitHub API
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:

jobs:
defaults:
runs-on: ubuntu-latest

steps:
- name: Checkout local repository
uses: actions/checkout@v2

- name: Build action
run: |
npm install
npm run build
npm run pack

# Run the action using default values as much as possible.
- name: Run action
uses: ./ # Use the action from the local path.
with:
path: .github/workflows/testdata/SpecificationSketch

expected-pass:
runs-on: ubuntu-latest

env:
REPORT_FILE_PATH: /tmp/report.json
steps:
- name: Checkout local repository
uses: actions/checkout@v2

- name: Build action
run: |
npm install
npm run build
npm run pack

# 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.
- name: Run action
uses: ./
with:
path: .github/workflows/testdata/some-projects
compliance: permissive
library-manager: false
project-type: library
recursive: true
report-file: ${{ env.REPORT_FILE_PATH }}
official: true

- name: Verify report file exists
run: |
[ -e "${{ env.REPORT_FILE_PATH }}" ]

expected-fail:
runs-on: ubuntu-latest

steps:
- name: Checkout local repository
uses: actions/checkout@v2

- name: Build action
run: |
npm install
npm run build
npm run pack

# The contents of the test data path are structured so that the step will fail if arduino-lint is run with the default configuration.
- name: Run action
id: arduino-lint
continue-on-error: true
uses: ./
with:
path: .github/workflows/testdata/projects

- name: Fail the job if the action run succeeded
if: steps.arduino-lint.outcome == 'success'
run: |
echo "::error::The action run was expected to fail, but passed!"
exit 1
26 changes: 26 additions & 0 deletions .github/workflows/spell-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Spell Check

on:
pull_request:
push:
schedule: # Schedule trigger for catching new misspelling detections resulting from dictionary updates.
# Run every Saturday at 3 AM UTC.
- cron: "0 3 * * 2"
# workflow_dispatch event allows the workflow to be triggered manually
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# repository_dispatch event allows the workflow to be triggered via the GitHub API
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:

jobs:
spellcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

# See: https://github.com/codespell-project/actions-codespell/blob/master/README.md
- name: Spell check
uses: codespell-project/actions-codespell@master
15 changes: 11 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Test Action

on: [push, pull_request]
on:
push:
pull_request:

jobs:
test:
Expand All @@ -11,14 +13,19 @@ jobs:

strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest]
operating-system:
- ubuntu-latest
- windows-latest

steps:
- name: Disable EOL conversions
run: git config --global core.autocrlf false

- name: Checkout
uses: actions/checkout@master
uses: actions/checkout@v2

- name: Set Node.js 10.x
uses: actions/setup-node@v1.4.4
uses: actions/setup-node@v1
with:
node-version: 10.x

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
void setup() {}
void loop() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
void setup() {}
void loop() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name=ArduinoGraphics
version=1.0.0
author=Cristian Maglie <c.maglie@example.com>, Pippo Pluto <pippo@example.com>
maintainer=Cristian Maglie <c.maglie@example.com>
sentence=A library that requires the permissive compliance setting to pass the checks.
paragraph=
category=Other
url=http://example.com/
architectures=avr
# Invalid permissive value only allowed in permissive compliance mode
permissive=foo
150 changes: 104 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,124 @@
# setup-arduino-cli
# `arduino/arduino-lint-action`

[![Actions Status](https://github.com/arduino/setup-arduino-cli/workflows/Test%20Action/badge.svg)](https://github.com/arduino/setup-arduino-cli/actions)
[![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)
[![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)
[![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)

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

## Usage
- Libraries
- Sketches
- Boards platforms

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

```yaml
- name: Install Arduino CLI
uses: arduino/setup-arduino-cli@v1.1.1
```
<!-- toc -->

If you want to pin a major or minor version you can use the `.x` wildcard:
- [Inputs](#inputs)
- [`path`](#path)
- [`version`](#version)
- [`compliance`](#compliance)
- [`format`](#format)
- [`library-manager`](#library-manager)
- [`project-type`](#project-type)
- [`recursive`](#recursive)
- [`report-file`](#report-file)
- [`token`](#token)
- [Usage](#usage)

```yaml
- name: Install Arduino CLI
uses: arduino/setup-arduino-cli@v1.1.1
with:
version: "0.x"
```
<!-- tocstop -->

To pin the exact version:
## Inputs

```yaml
- name: Install Arduino CLI
uses: arduino/setup-arduino-cli@v1.1.1
with:
version: "0.5.0"
```
### `path`

## Examples
Path containing Arduino project(s).

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

## Development
### `version`

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

```sh
# npm install
```
**Default**: `1.x`

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

```sh
# npm run test
```
Configure how strict the tool is about which checks are considered errors vs warnings if they don't pass.

#### Supported values

- `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.
- `specification` - enforces compliance with the official Arduino project specifications.
- `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.

**Default**: `specification`

### `library-manager`

Configure the checks for libraries in the [Arduino Library Manager](https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ) index.

#### Supported values

- `submit` - Also run additional checks required to pass before a library is accepted for inclusion in the index.
- `update`- Also run additional checks required to pass before a library is accepted for inclusion in the index.
- `false` - Don't run any Library Manager-specific checks.

**Default**: `submit` for libraries, `false` for other project types

### `project-type`

Configures which types of projects to check, along with their subprojects.

See the [official Github documentation][pat-docs] to know more about Personal Access Tokens.
#### Supported values

- `sketch`
- `library`
- `all` - Run checks on any type of project that is detected

**Default**: `all`

### `recursive`

Set to `true` to search path recursively for Arduino projects to check.

**Default**: `false`

### `report-file`

Save a JSON formatted report on the checks to this file.

### `verbose`

Set to `true` to show more information in the log about the checks being run.

**Default**: `false`

### `token`

GitHub access token used to get information from the GitHub API.

**Default**: [`GITHUB_TOKEN`](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow)

## Usage

The minimal workflow to run the default checks on the projects in the repository:

```yaml
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: arduino/arduino-lint-action@v1
```

## Release
## Contributing

1. `npm install` to add all the dependencies, included development.
2. `npm run build` to build the Action under the `./lib` folder.
3. `npm run test` to see everything works as expected.
4. `npm run pack` to package for distribution
5. `git add src dist` to check in the code that matters.
6. open a PR and request a review.
To report bugs or make feature requests, please submit an issue: https://github.com/arduino/arduino-lint-action/issues

[pat-docs]: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token
[example]: https://github.com/arduino/arduino-cli-example/blob/master/.github/workflows/test.yaml
[blogpost]: https://blog.arduino.cc/2019/11/14/arduino-on-github-actions/
Pull requests are welcome! Please see the [contribution guidelines](.github/CONTRIBUTING.md) for information.
Loading