1010
1111# This is the name of the workflow, visible on GitHub UI.
1212name : LibraryBuild
13- on : [push, pull_request] # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request
13+ on :
14+ push : # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request
15+ paths :
16+ - ' **.ino'
17+ - ' **.cpp'
18+ - ' **.h'
19+ - ' **LibraryBuild.yml'
20+ pull_request :
1421
1522jobs :
1623 build :
1724 name : ${{ matrix.arduino-boards-fqbn }} - test compiling examples
1825
19- runs-on : ubuntu-latest # I picked Ubuntu to use shell scripts.
26+ runs-on : ubuntu-18.04 # I picked Ubuntu to use shell scripts.
2027
2128 env :
22- # Space separated list without double quotes around the list.
23- # If you need a library with a space in its name, like Adafruit NeoPixel or Adafruit INA219, you must use double quotes
24- # around the name and have at least 2 entries, where the first must be without double quotes! You may use Servo as dummy entry.
29+ # Comma separated list without double quotes around the list.
30+ PLATFORM_DEFAULT_URL : https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json
2531 REQUIRED_LIBRARIES : EspSoftwareSerial
2632
27- # Global color definitions for output colors
28- RED : ' \033[0;31m'
29- GREEN : ' \033[0;32m'
30- YELLOW : ' \033[1;33m'
31- BLUE : ' \033[0;34m'
32-
3333 strategy :
3434 matrix :
3535 # The matrix will produce one job for each configuration parameter of type `arduino-boards-fqbn`
4747 - arduino:avr:leonardo
4848 - arduino:avr:mega
4949 - arduino:sam:arduino_due_x
50+ - SparkFun:apollo3:amap3redboard
5051 - esp8266:esp8266:huzzah:eesz=4M3M,xtal=80
5152 - esp32:esp32:featheresp32:FlashFreq=80
5253 - STM32:stm32:GenF1:pnum=BLUEPILL_F103C8
@@ -57,31 +58,17 @@ jobs:
5758 # You may exclude specific examples for a board with examples-exclude: Use a space separated list.
5859 # ############################################################################################################
5960 include :
60- - arduino-boards-fqbn : arduino:avr:uno
61- platform : arduino:avr
62-
63- - arduino-boards-fqbn : arduino:avr:leonardo
64- platform : arduino:avr
65-
66- - arduino-boards-fqbn : arduino:avr:mega
67- platform : arduino:avr
68-
6961 - arduino-boards-fqbn : arduino:sam:arduino_due_x
70- platform : arduino:sam
7162 examples-exclude : Example5_LCDDemo # No SoftwareSerial available. Space separated list of (unique substrings of) example names to exclude in build
7263
7364 - arduino-boards-fqbn : esp8266:esp8266:huzzah:eesz=4M3M,xtal=80
74- platform : esp8266: esp8266
65+ platform-url : https://arduino. esp8266.com/stable/package_esp8266com_index.json
7566
7667 - arduino-boards-fqbn : esp32:esp32:featheresp32:FlashFreq=80
77- platform : esp32:esp32
68+ platform-url : https://dl.espressif.com/dl/package_esp32_index.json
7869
7970 - arduino-boards-fqbn : STM32:stm32:GenF1:pnum=BLUEPILL_F103C8
80- platform : STM32:stm32
81-
82- # #####################################################
83- # End of configuration, start of fixed script section
84- # #####################################################
71+ platform-url : https://github.com/stm32duino/BoardManagerFiles/raw/dev/STM32/package_stm_index.json
8572
8673 # Do not cancel all jobs / architectures if one job fails
8774 fail-fast : false
@@ -91,68 +78,13 @@ jobs:
9178
9279 # First of all, we clone the repo using the `checkout` action.
9380 - name : Checkout
94- uses : actions/checkout@master
95-
96- # We use the `arduino/setup-arduino-cli` action to install and
97- # configure the Arduino CLI on the system.
98- - name : Setup Arduino CLI
99- 100-
101- - name : Link this repository as Arduino library
102- run : |
103- mkdir -p $HOME/Arduino/libraries
104- ln -s $PWD $HOME/Arduino/libraries/.
105-
106- - name : Install platform from build matrix
107- env :
108- FQBN : ${{ matrix.arduino-boards-fqbn }}
109- run : |
110- arduino-cli core update-index
111- if [ "${{ matrix.platform }}" == "" ]; then echo -e ""$RED"ERROR: platform missing for board ${FQBN%|*}. Check your matrix.includes entries"; exit 1; fi
112- 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
113- arduino-cli core install ${{ matrix.platform }} # for each job / board one platform is installed
114- arduino-cli board listall
115- if [ ${{ matrix.platform }} == "esp32:esp32" ]; then pip install pyserial; fi
116-
117- - name : List installed boards with their FQBN
118- run : |
119- arduino-cli board listall
120- # ls -l $HOME/.arduino15/packages/ # I see only arduino and one of the Attiny cores but not all 3 together
121- # echo -e HOME=\"$HOME\" # /home/runner
122- # echo PWD=$PWD # /home/runner/work/Github-Actions-Test/Github-Actions-Test
123- # which arduino-cli # /opt/hostedtoolcache/arduino-cli/0.9.0/x64/arduino-cli
124-
125- - name : Install libraries
126- run : if [[ "$REQUIRED_LIBRARIES" != "" ]]; then arduino-cli lib install ${{ env.REQUIRED_LIBRARIES }}; fi
81+ uses : actions/checkout@v2
12782
128- # Finally, we compile the sketch, using the FQBN that was set in the build matrix.
12983 - name : Compile all examples
130- env :
131- FQBN : ${{ matrix.arduino-boards-fqbn }}
132- BUILD_PROPERTIES : ${{ toJson(matrix.examples-build-properties) }}
133- run : |
134- BUILD_PROPERTIES=${BUILD_PROPERTIES#\{} # remove "{"
135- # if matrix.examples-build-properties are specified, create an associative shell array
136- if [[ $BUILD_PROPERTIES != "null" ]]; then declare -A PROP_MAP="( $(echo $BUILD_PROPERTIES | sed -E 's/"(\w*)": *([^,}]*)[,}]/\[\1\]=\2/g' ) )"; fi
137- echo -e "Compiling examples for board ${{ matrix.arduino-boards-fqbn }} \n"
138- EXAMPLES=($(find . -name "*.ino"))
139- for example in "${EXAMPLES[@]}"; do # Loop over all example directories
140- EXAMPLE_NAME=$(basename $(dirname $example))
141- if [[ "${{ matrix.examples-exclude }}" == *"$EXAMPLE_NAME"* ]]; then
142- echo -e "Skipping $EXAMPLE_NAME \xe2\x9e\x9e" # Right arrow
143- else
144- # check if there is an entry in the associative array and create a compile parameter
145- echo -n "Compiling $EXAMPLE_NAME "
146- if [[ "${PROP_MAP[$EXAMPLE_NAME]}" != "" ]]; then echo -n "with ${PROP_MAP[$EXAMPLE_NAME]} "; fi
147- build_stdout=$(arduino-cli compile --verbose --warnings all --fqbn ${FQBN%|*} --build-properties compiler.cpp.extra_flags="${PROP_MAP[$EXAMPLE_NAME]}" $(dirname $example) 2>&1);
148- if [ $? -ne 0 ]; then
149- echo -e ""$RED"\xe2\x9c\x96" # If ok output a green checkmark else a red X and the command output.
150- exit_code=1
151- echo -e "$build_stdout \n"
152- else
153- echo -e ""$GREEN"\xe2\x9c\x93"
154- fi
155- fi
156- done
157- exit $exit_code
158- shell : bash {0} # Needed to avoid an exit at first error
84+ uses : ArminJo/arduino-test-compile@v2
85+ with :
86+ required-libraries : ${{ env.REQUIRED_LIBRARIES }}
87+ arduino-board-fqbn : ${{ matrix.arduino-boards-fqbn }}
88+ platform-default-url : ${{ env.PLATFORM_DEFAULT_URL }}
89+ platform-url : ${{ matrix.platform-url }}
90+ examples-exclude : ${{ matrix.examples-exclude }}
0 commit comments