Skip to content

Commit 0280a09

Browse files
committed
GitHub Actions
1 parent e81579e commit 0280a09

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed

.github/workflows/build.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# This is the name of the workflow, visible on GitHub UI.
2+
name: buildTest
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
name: Test compiling examples for set of boards
8+
9+
runs-on: ubuntu-latest # I picked Ubuntu to use shell scripts.
10+
11+
env: # Output colors
12+
RED: '\033[0;31m'
13+
GREEN: '\033[0;32m'
14+
YELLOW: '\033[1;33m'
15+
BLUE: '\033[0;34m'
16+
17+
strategy:
18+
matrix:
19+
# The matrix will produce one job for each configuration parameter of type `arduino-boards-fqbn`
20+
####################################################################
21+
arduino-boards-fqbn: ["digistump:avr:digispark-tiny1", "ATTinyCore:avr:attinyx5:chip=85,clock=1internal", "arduino:avr:uno"]
22+
23+
# Choose the right platform for the boards we want to test.
24+
# This works like this: when the platformn is "digistump:avr:digispark-tiny", or "digistump:avr:digispark-tiny1" the
25+
# variable `platform` is set to "digistump:avr". Just take the first 2 token of the fqbn - this cannot be automatically done by GitHub workflow :-(
26+
##################################################################
27+
include:
28+
- arduino-boards-fqbn: "digistump:avr:digispark-tiny1" # ATtiny85 board @1 MHz
29+
platform: "digistump:avr"
30+
# examples: "SimpleFrequencyDetector" # Space separated list of examples to build, build all if omitted or empty
31+
32+
- arduino-boards-fqbn: "ATTinyCore:avr:attinyx5:chip=85,clock=1internal"
33+
platform: "ATTinyCore:avr"
34+
35+
- arduino-boards-fqbn: "arduino:avr:uno"
36+
platform: "arduino:avr"
37+
38+
39+
# Do not cancel all jobs / architectures if one job fails
40+
fail-fast: false
41+
42+
# This is the list of steps this job will run.
43+
steps:
44+
45+
# First of all, we clone the repo using the `checkout` action.
46+
- name: Checkout
47+
uses: actions/checkout@master
48+
49+
# We use the `arduino/setup-arduino-cli` action to install and
50+
# configure the Arduino CLI on the system.
51+
- name: Setup Arduino CLI
52+
uses: arduino/setup-arduino-cli@v1.0.0
53+
54+
# Here we have only the matrix values for this job i.e. only one platform and fqbn
55+
#- name: Dump matrix context
56+
# run: echo " ${{ toJson(matrix) }} "
57+
58+
- name: Link this repository as Arduino library
59+
run: |
60+
mkdir -p $HOME/Arduino/libraries
61+
ln -s $PWD $HOME/Arduino/libraries/.
62+
63+
- name: Install platform from build matrix
64+
run: |
65+
arduino-cli core update-index
66+
arduino-cli core install ${{ matrix.platform }} # for each job / board one platform is installed
67+
68+
- name: List installed boards with their FQBN
69+
run: |
70+
arduino-cli board listall
71+
# ls -l $HOME/.arduino15/packages/ # I see only arduino and one of the Attiny cores but not all 3 together
72+
# echo -e HOME=\"$HOME\" # /home/runner
73+
# echo PWD=$PWD # /home/runner/work/Github-Actions-Test/Github-Actions-Test
74+
# which arduino-cli # /opt/hostedtoolcache/arduino-cli/0.9.0/x64/arduino-cli
75+
76+
77+
# Finally, we compile the sketch, using the FQBN that was set in the build matrix.
78+
- name: Compile all examples
79+
run: |
80+
if [ "${{ matrix.examples }}" == "" ]; then
81+
echo -e "Compiling ALL examples for board ${{ matrix.arduino-boards-fqbn }} \n"
82+
examples=($(find . -name "*.ino"))
83+
for example in "${examples[@]}"; do # Loop over all example directories
84+
echo -n "Compiling $(dirname $example) "
85+
build_stdout=$(arduino-cli compile --verbose --warnings all --fqbn ${{ matrix.arduino-boards-fqbn }} $(dirname $example) 2>&1);
86+
if [ $? -ne 0 ]; then echo -e """$RED""\xe2\x9c\x96"; exit_code=1; echo "$build_stdout"; else echo -e ""$GREEN"\xe2\x9c\x93"; fi # If ok output a green check else a red X and the command output.
87+
done
88+
else
89+
echo -e "Compiling SELECTED examples for board ${{ matrix.arduino-boards-fqbn }} \n"
90+
for example in "${{ matrix.examples }}"; do
91+
echo -n "Compiling $example "
92+
build_stdout=$(arduino-cli compile --verbose --warnings all --fqbn ${{ matrix.arduino-boards-fqbn }} ./examples/$example 2>&1); if [ $? -ne 0 ];
93+
then echo -e """$RED""\xe2\x9c\x96"; exit_code=1; echo "$build_stdout"; else echo -e ""$GREEN"\xe2\x9c\x93"; fi # If ok output a green check else a red X and the command output.
94+
done
95+
fi
96+
exit $exit_code
97+
shell: bash {0} # Needed to avoid an exit at first error
98+
99+
##########################################################
100+
# THIS DOES NOT YET WORK
101+
#- name: Cache Arduino packages
102+
# does not work, since the cache does not contain all installed platforms :-(
103+
# And we can not build separate caches for each platform
104+
# id: arduino15-packages-env.MATRIX_PLATFORM <- This is a syntax error and this too: arduino15-packages-${{ matrix.platform }}
105+
# uses: actions/cache@v1 # using version 1
106+
# with:
107+
# path: $HOME/.arduino15/packages/
108+
# key: arduino15-packages-env.MATRIX_PLATFORM

arduino-cli.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
board_manager:
2+
additional_urls:
3+
- http://digistump.com/package_digistump_index.json
4+
- http://drazzy.com/package_drazzy.com_index.json
5+
- http://arduino.esp8266.com/stable/package_esp8266com_index.json
6+
- https://dl.espressif.com/dl/package_esp32_index.json
7+
- https://github.com/stm32duino/BoardManagerFiles/raw/dev/STM32/package_stm_index.json
File renamed without changes.

0 commit comments

Comments
 (0)