Skip to content
This repository was archived by the owner on Apr 1, 2022. It is now read-only.

Add initial arduino-libraries actions #3

Merged
merged 2 commits into from
Oct 4, 2019
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ available to your Workflows.

* [setup-taskfile](./setup-taskfile) makes [`task`](https://taskfile.dev/#/)
available to your Workflows.

* [libraries/compile-examples](./libraries/compile-examples) compile all the examples in an Arduino Library

* [libraries/spell-check](./libraries/spell-check) run spell checker on Arduino Library source and examples
12 changes: 12 additions & 0 deletions libraries/compile-examples/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Container image that runs your code
FROM ubuntu:latest

# Install prerequisites
RUN apt-get update && apt-get install -y wget
CMD /bin/bash

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
25 changes: 25 additions & 0 deletions libraries/compile-examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# libraries/compile-examples action

This action compiles all of the examples contained in the library.

## Inputs

### `cli-version`

The version of `arduino-cli` to use. Default `"latest"`.

### `fqbn`

**Required** The fully qualified board name to use when compiling. Default `"arduino:avr:uno"`.

### `libraries`

List of library dependencies to install (space separated). Default `""`.

## Example usage

```yaml
uses: arduino/actions/libraries/compile-examples@master
with:
fqbn: 'arduino:avr:uno'
```
20 changes: 20 additions & 0 deletions libraries/compile-examples/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Arduino Libraries - Compile Examples'
description: 'Compiles all the examples included in the library'
inputs:
cli-version:
description: 'Version of arduino-cli to use when builing'
default: 'latest'
fqbn:
description: 'Full qualified board name'
required: true
default: 'arduino:avr:uno'
libraries:
description: 'List of library dependencies to install (space separated)'
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.cli-version }}
- ${{ inputs.fqbn }}
- ${{ inputs.libraries }}
45 changes: 45 additions & 0 deletions libraries/compile-examples/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash -x

CLI_VERSION=$1
FQBN=$2
LIBRARIES=$3

# Determine cli archive
CLI_ARCHIVE=arduino-cli_${CLI_VERSION}_Linux_64bit.tar.gz

# Extract the core name from the FQBN
# for example arduino:avr:uno => arduino:avr
CORE=`echo "$FQBN" | cut -d':' -f1,2`

# Download the arduino-cli
wget -P $HOME https://downloads.arduino.cc/arduino-cli/$CLI_ARCHIVE

# Extract the arduino-cli to $HOME/bin
mkdir $HOME/bin
tar xf $HOME/$CLI_ARCHIVE -C $HOME/bin

# Add arduino-cli to the PATH
export PATH=$PATH:$HOME/bin

# Update the code index and install the required CORE
arduino-cli core update-index
arduino-cli core install $CORE

# Install libraries if needed
if [ -z "$LIBRARIES" ]
then
echo "No libraries to install"
else
arduino-cli lib install $LIBRARIES
fi

# Symlink the library that needs to be built in the sketchbook
mkdir -p $HOME/Arduino/libraries
ln -s $PWD $HOME/Arduino/libraries/.

# Find all the examples and loop build each
EXAMPLES=`find examples/ -name '*.ino' | xargs dirname | uniq`
for EXAMPLE in $EXAMPLES; do
echo Building example $EXAMPLE
arduino-cli compile --verbose --warnings all --fqbn $FQBN $EXAMPLE
done || exit 1
15 changes: 15 additions & 0 deletions libraries/spell-check/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Container image that runs your code
FROM ubuntu:latest

# Install prerequisites
RUN apt-get update && apt-get install -y python3 python3-pip
CMD /bin/bash

RUN pip3 install codespell
CMD /bin/bash

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
15 changes: 15 additions & 0 deletions libraries/spell-check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# libraries/spell-check action

Runs codespell on library source code and examples contained in the library.

## Inputs

### `ignore-words-list`

File path of list of words to ignore.

## Example usage

```yaml
uses: arduino/actions/libraries/spell-check@master
```
11 changes: 11 additions & 0 deletions libraries/spell-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 'Arduino Libraries - Spell Check'
description: 'Runs codespell on library source code and examples contained in the library'
inputs:
ignore-words-list:
description: 'File path of list of words to ignore'
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.ignore-words-list }}
11 changes: 11 additions & 0 deletions libraries/spell-check/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -x

IGNORE_WORDS_LIST=$1

CODE_SPELL_ARGS="--skip=.git"

if test -f "$IGNORE_WORDS_LIST"; then
CODE_SPELL_ARGS="${CODE_SPELL_ARGS} --ignore-words=${IGNORE_WORDS_LIST}"
fi

codespell ${CODE_SPELL_ARGS} .