Skip to content

Commit 00c024a

Browse files
committed
Github workflow
1 parent d8f6692 commit 00c024a

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed

.github/workflows/LibraryBuild.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Before being able to push to my .github\workflows directories,
2+
# I had to create a new personal token with workflow enabled at https://github.com/settings/tokens
3+
4+
# This is the name of the workflow, visible on GitHub UI.
5+
name: LibraryBuild
6+
on: [push]
7+
8+
jobs:
9+
build:
10+
name: ${{ matrix.arduino-boards-fqbn }} - test compiling examples
11+
12+
runs-on: ubuntu-latest # I picked Ubuntu to use shell scripts.
13+
14+
env:
15+
# Space separated list without double quotes around the list.
16+
# If you need a library with a space in its name, like Adafruit NeoPixel or Adafruit INA219, you must use double quotes
17+
# around the name and have at least 2 entries, where the first must be without double quotes! You may use Servo as dummy entry.
18+
REQUIRED_LIBRARIES:
19+
20+
# Output colors
21+
RED: '\033[0;31m'
22+
GREEN: '\033[0;32m'
23+
YELLOW: '\033[1;33m'
24+
BLUE: '\033[0;34m'
25+
26+
strategy:
27+
matrix:
28+
# The matrix will produce one job for each configuration parameter of type `arduino-boards-fqbn`
29+
# In the Arduino IDE, the fqbn is printed in the first line of the verbose output for compilation as parameter -fqbn=... for the "arduino-builder -dump-prefs" command
30+
#
31+
# Examples: arduino:avr:uno, arduino:avr:leonardo, arduino:avr:nano, arduino:avr:mega
32+
# arduino:sam:arduino_due_x, arduino:samd:arduino_zero_native"
33+
# ATTinyCore:avr:attinyx5:chip=85,clock=1internal, digistump:avr:digispark-tiny, digistump:avr:digispark-pro
34+
# STM32:stm32:GenF1:pnum=BLUEPILL_F103C8
35+
# esp8266:esp8266:huzzah:eesz=4M3M,xtal=80, esp32:esp32:featheresp32:FlashFreq=80
36+
# You may add a suffix behind the fqbn with "|" to specify one board for e.g. different compile options like arduino:avr:uno|trace
37+
#############################################################################################################
38+
arduino-boards-fqbn:
39+
- arduino:avr:uno
40+
- arduino:avr:leonardo
41+
- arduino:avr:mega
42+
- arduino:sam:arduino_due_x
43+
- esp8266:esp8266:huzzah:eesz=4M3M,xtal=80
44+
- esp32:esp32:featheresp32:FlashFreq=80
45+
- STM32:stm32:GenF1:pnum=BLUEPILL_F103C8
46+
47+
# Choose the right platform for the boards we want to test. (maybe in the future Arduino will automatically do this for you).
48+
# This works like this: when the fqbn is "arduino:avr:uno" the variable `platform` is set to "arduino:avr".
49+
# Just take the first 2 token of the fqbn - this cannot be automatically done by GitHub workflow :-(
50+
# You may exclude specific examples for a board with examples-exclude: Use a space separated list.
51+
#############################################################################################################
52+
include:
53+
- arduino-boards-fqbn: arduino:avr:uno
54+
platform: arduino:avr
55+
56+
- arduino-boards-fqbn: arduino:avr:leonardo
57+
platform: arduino:avr
58+
59+
- arduino-boards-fqbn: arduino:avr:mega
60+
platform: arduino:avr
61+
62+
- arduino-boards-fqbn: arduino:sam:arduino_due_x
63+
platform: arduino:sam
64+
examples-exclude: Example5_LCDDemo Example6_ArduinoPlotterOutput Example7_Calibration # Space separated list of (unique substrings of) example names to exclude in build
65+
66+
- arduino-boards-fqbn: esp8266:esp8266:huzzah:eesz=4M3M,xtal=80
67+
platform: esp8266:esp8266
68+
examples-exclude: Example5_LCDDemo # Space separated list of (unique substrings of) example names to exclude in build
69+
70+
- arduino-boards-fqbn: esp32:esp32:featheresp32:FlashFreq=80
71+
platform: esp32:esp32
72+
examples-exclude: Example5_LCDDemo Example6_ArduinoPlotterOutput Example7_Calibration # Space separated list of (unique substrings of) example names to exclude in build
73+
74+
- arduino-boards-fqbn: STM32:stm32:GenF1:pnum=BLUEPILL_F103C8
75+
platform: STM32:stm32
76+
77+
# Do not cancel all jobs / architectures if one job fails
78+
fail-fast: false
79+
80+
# This is the list of steps this job will run.
81+
steps:
82+
83+
# First of all, we clone the repo using the `checkout` action.
84+
- name: Checkout
85+
uses: actions/checkout@master
86+
87+
# We use the `arduino/setup-arduino-cli` action to install and
88+
# configure the Arduino CLI on the system.
89+
- name: Setup Arduino CLI
90+
uses: arduino/setup-arduino-cli@v1.0.0
91+
92+
- name: Link this repository as Arduino library
93+
run: |
94+
mkdir -p $HOME/Arduino/libraries
95+
ln -s $PWD $HOME/Arduino/libraries/.
96+
97+
- name: Install platform from build matrix
98+
env:
99+
FQBN: ${{ matrix.arduino-boards-fqbn }}
100+
run: |
101+
arduino-cli core update-index
102+
if [ "${{ matrix.platform }}" == "" ]; then echo -e ""$RED"ERROR: platform missing for board ${FQBN%|*}. Check your matrix.includes entries"; exit 1; fi
103+
if [[ ${{ matrix.platform }} != *"arduino"* && ! -f ./arduino-cli.yaml ]]; then echo -e ""$RED"Non Arduino platform ${{ matrix.platform }} requested, but file arduino-cli.yaml is missing."; exit 1; fi
104+
arduino-cli core install ${{ matrix.platform }} # for each job / board one platform is installed
105+
arduino-cli board listall
106+
if [ ${{ matrix.platform }} == "esp32:esp32" ]; then pip install pyserial; fi
107+
108+
- name: List installed boards with their FQBN
109+
run: |
110+
arduino-cli board listall
111+
# ls -l $HOME/.arduino15/packages/ # I see only arduino and one of the Attiny cores but not all 3 together
112+
# echo -e HOME=\"$HOME\" # /home/runner
113+
# echo PWD=$PWD # /home/runner/work/Github-Actions-Test/Github-Actions-Test
114+
# which arduino-cli # /opt/hostedtoolcache/arduino-cli/0.9.0/x64/arduino-cli
115+
116+
- name: Install libraries
117+
run: if [[ "$REQUIRED_LIBRARIES" != "" ]]; then arduino-cli lib install ${{ env.REQUIRED_LIBRARIES }}; fi
118+
119+
# Finally, we compile the sketch, using the FQBN that was set in the build matrix.
120+
- name: Compile all examples
121+
env:
122+
FQBN: ${{ matrix.arduino-boards-fqbn }}
123+
BUILD_PROPERTIES: ${{ toJson(matrix.examples-build-properties) }}
124+
run: |
125+
BUILD_PROPERTIES=${BUILD_PROPERTIES#\{} # remove "{"
126+
# if matrix.examples-build-properties are specified, create an associative shell array
127+
if [[ $BUILD_PROPERTIES != "null" ]]; then declare -A PROP_MAP="( $(echo $BUILD_PROPERTIES | sed -E 's/"(\w*)": *([^,}]*)[,}]/\[\1\]=\2/g' ) )"; fi
128+
echo -e "Compiling examples for board ${{ matrix.arduino-boards-fqbn }} \n"
129+
EXAMPLES=($(find . -name "*.ino"))
130+
for example in "${EXAMPLES[@]}"; do # Loop over all example directories
131+
EXAMPLE_NAME=$(basename $(dirname $example))
132+
if [[ "${{ matrix.examples-exclude }}" == *"$EXAMPLE_NAME"* ]]; then
133+
echo -e "Skipping $EXAMPLE_NAME \xe2\x9e\x9e" # Right arrow
134+
else
135+
# check if there is an entry in the associative array and create a compile parameter
136+
echo -n "Compiling $EXAMPLE_NAME "
137+
if [[ "${PROP_MAP[$EXAMPLE_NAME]}" != "" ]]; then echo -n "with ${PROP_MAP[$EXAMPLE_NAME]} "; fi
138+
build_stdout=$(arduino-cli compile --verbose --warnings all --fqbn ${FQBN%|*} --build-properties compiler.cpp.extra_flags="${PROP_MAP[$EXAMPLE_NAME]}" $(dirname $example) 2>&1);
139+
if [ $? -ne 0 ]; then
140+
echo -e ""$RED"\xe2\x9c\x96" # If ok output a green checkmark else a red X and the command output.
141+
exit_code=1
142+
echo -e "$build_stdout \n"
143+
else
144+
echo -e ""$GREEN"\xe2\x9c\x93"
145+
fi
146+
fi
147+
done
148+
exit $exit_code
149+
shell: bash {0} # Needed to avoid an exit at first error

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
SparkFun Qwiic 4m Distance Sensor with VL53L1X
22
========================================
3+
[![Build Status](https://github.com/ArminJo/SparkFun_VL53L1X_Arduino_Library/workflows/LibraryBuild/badge.svg)](https://github.com/ArminJo/SparkFun_VL53L1X_Arduino_Library/actions)
4+
35

46
![SparkFun Distance Sensor Breakout - 4 Meter, VL53L1X (Qwiic)](https://cdn.sparkfun.com//assets/parts/1/2/9/4/8/14722-SparkFun_Distance_Sensor_Breakout-_4_Meter__VL53L1X__Qwiic_-01.jpg)
57

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

0 commit comments

Comments
 (0)