Skip to content

[DO NOT MERGE] Add Github Actions workflow to build library examples #31

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

Closed
Closed
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
57 changes: 57 additions & 0 deletions .github/workflows/build-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build Library Examples
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
fqbn: [
"arduino:samd:mkrwifi1010",
"arduino:samd:nano_33_iot",
"arduino:megaavr:uno2018:mode=on",
"arduino:mbed:nano33ble"
]

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Setup arduino-cli
env:
VERSION: latest
run: |
set -x
wget -P $HOME https://downloads.arduino.cc/arduino-cli/arduino-cli_${VERSION}_Linux_64bit.tar.gz
mkdir $HOME/bin
tar xf $HOME/arduino-cli_${VERSION}_Linux_64bit.tar.gz -C $HOME/bin
echo ::add-path::$HOME/bin
Comment on lines +21 to +29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't use the official setup-arduino-cli github action to remove a bit of boilerplate? In #32 You can see the action working.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on using the official GitHub action. Everything else looks perfectly good to me. Well done!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can slim the GitHub action down? It seems overcomplicated internally (depends on Node.js) etc.

Copy link

@rsora rsora Oct 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed the nodejs code gives more flexibility (i.e. pinning only the minor version for the cli) and the chance to leverage other actions code as modules. Additionally the action code is testable with unit testing. KISS is always to prefer, but in case you discover you need something more powerful, we'll be happy to help 😺


- name: Export FQBN and BOARD
run: |
FQBN=${{ matrix.fqbn }}
CORE=`echo "$FQBN" | cut -d':' -f1,2`
echo ::set-env name=FQBN::"$FQBN"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandeepmistry May I ask also for a small comment explaining each step? In this line it took me a couple of minutes before realizing this is a simple message echo, instead of an obscure bash magic to export the variable :)

Also in https://github.com/arduino-libraries/ArduinoBLE/pull/31/files#diff-3ce900fec73e52de9493561cd47d3a5bR44 would be nice to say why we symlink the folder instead of, for example, moving the library into my sketchbook or something similar.

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, will add some comments :)

simple message echo, instead of an obscure bash magic to export the variable :)

it is magic! It's the trick to export env vars to steps: https://help.github.com/en/articles/development-tools-for-github-actions#set-an-environment-variable-set-env

echo ::set-env name=CORE::"$CORE"

- name: Install Core
run: |
set -x
arduino-cli core update-index
arduino-cli core install $CORE

- name: Symlink Library
run: |
set -x
mkdir -p $HOME/Arduino/libraries
ln -s $PWD $HOME/Arduino/libraries/.

- name: Compile Examples
run: |
set -x
EXAMPLES=`find examples/ -name *.ino | xargs`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a bit smarter and ignore examples sketches that need contain more than one .ino file ...

Copy link
Contributor

@facchinm facchinm Oct 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the cli can accept the folder (and not the file) we can go with find examples/ -name '*.ino' | xargs dirname | uniq

Copy link

@rsora rsora Oct 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@facchinm @sandeepmistry the cli do accept folders! In #32 you can see the fix I made in the meantime :)

for EXAMPLE in $EXAMPLES; do
echo Building example $EXAMPLE
arduino-cli compile --verbose --warnings all --fqbn $FQBN $EXAMPLE
done || exit 1