Skip to content

Commit d2c0901

Browse files
committed
Update Arduino workflow with parameterized matrix
1 parent 5c421a1 commit d2c0901

File tree

1 file changed

+114
-21
lines changed

1 file changed

+114
-21
lines changed

.github/workflows/arduino.yml

Lines changed: 114 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ name: Arduino CI Build (1 of 4) wolfssl
3838
#
3939
# To test locally:
4040
# cd [your WOLFSSL_ROOT], e.g. cd /mnt/c/workspace/wolfssl-$USER
41-
# [optional checkout] e.g. git checkout tags/v5.8.2-stable
41+
# [optional checkout] e.g. git checkout tags/v5.8.4-stable
4242
# pushd ./IDE/ARDUINO
4343
# export ARDUINO_ROOT="$HOME/Arduino/libraries"
4444
# ./wolfssl-arduino.sh INSTALL
@@ -50,6 +50,7 @@ on:
5050
push:
5151
branches: [ '**', 'master', 'main', 'release/**' ]
5252
paths:
53+
# Specific to this Arduino CI Build (1 of 4)
5354
- '.github/workflows/arduino.yml'
5455
- 'IDE/ARDUINO/**'
5556
- 'src/**'
@@ -66,16 +67,60 @@ on:
6667
workflow_dispatch:
6768

6869
concurrency:
69-
group: ${{ github.workflow }}-${{ github.ref }}
70+
# Same branch push cancels other jobs. Other PR branches untouched
71+
72+
group: ${{ github.workflow }}-${{ github.ref_name }}
7073
cancel-in-progress: true
74+
7175
# END OF COMMON SECTION
7276

7377
jobs:
7478
build:
7579
if: github.repository_owner == 'wolfssl'
7680
runs-on: ubuntu-latest
81+
82+
strategy:
83+
fail-fast: false
84+
matrix:
85+
fqbn:
86+
# When editing this list, be sure to also edit file: board_list.txt
87+
# The compile-all-examples.sh optionally takes a FQBN parameter to
88+
# optionally compile all examples ONLY for the respective fully qualified board name.
89+
# See https://github.com/wolfSSL/wolfssl-examples/blob/master/Arduino/sketches/board_list.txt
90+
91+
- arduino:avr:ethernet
92+
- arduino:avr:leonardoeth
93+
- arduino:avr:mega
94+
- arduino:avr:nano
95+
- arduino:avr:uno
96+
- arduino:avr:yun
97+
- arduino:samd:mkrwifi1010
98+
- arduino:samd:mkr1000
99+
- arduino:samd:mkrfox1200
100+
- arduino:mbed_edge:edge_control
101+
- arduino:mbed_nano:nanorp2040connect
102+
- arduino:mbed_portenta:envie_m7
103+
- arduino:mbed_portenta:portenta_x8
104+
- arduino:renesas_uno:unor4wifi
105+
- arduino:sam:arduino_due_x
106+
- arduino:samd:arduino_zero_native
107+
- arduino:samd:tian
108+
- esp32:esp32:esp32
109+
- esp32:esp32:esp32s2
110+
- esp32:esp32:esp32s3
111+
- esp32:esp32:esp32c3
112+
- esp32:esp32:esp32c6
113+
- esp32:esp32:esp32h2
114+
- esp8266:esp8266:generic
115+
- teensy:avr:teensy40
116+
117+
# Not yet supported, not in standard library
118+
# - esp32:esp32:nano_nora
119+
120+
# End strategy matrix
77121
env:
78122
REPO_OWNER: ${{ github.repository_owner }}
123+
79124
steps:
80125
- name: Checkout Repository
81126
uses: actions/checkout@v4
@@ -84,7 +129,7 @@ jobs:
84129
run: |
85130
# Script to fetch and run install.sh from arduino/arduino-cli
86131
87-
# The install script will test to see if the recently installed apps in in the path
132+
# The install script will test to see if the recently installed apps in the path
88133
# So set it up in advance:
89134
mkdir -p "${PWD}/bin"
90135
echo "${PWD}/bin" >> $GITHUB_PATH
@@ -95,7 +140,7 @@ jobs:
95140
# Ensures that BINDIR exists before the installer runs
96141
mkdir -p "$ROOT_BIN"
97142
98-
# Save as a lobal environment variable
143+
# Save as a global environment variable
99144
echo "$ROOT_BIN" >> "$GITHUB_PATH"
100145
101146
# Download and run install script from Arduino:
@@ -126,34 +171,53 @@ jobs:
126171
echo "Alternative install script not needed."
127172
fi
128173
129-
- name: Confirm Arduino CLI install
174+
- name: Confirm Arduino CLI Install
130175
run: arduino-cli version
131176

177+
- name: Derive CORE_ID (vendor:arch from FQBN)
178+
run: |
179+
CORE_ID="$(echo '${{ matrix.fqbn }}' | cut -d: -f1-2)"
180+
echo "CORE_ID=$CORE_ID" >> "$GITHUB_ENV"
181+
132182
- name: Setup Arduino CLI
133183
run: |
134184
arduino-cli config init
135-
arduino-cli core update-index
185+
186+
# wait 10 minutes for big downloads (or use 0 for no limit)
187+
arduino-cli config set network.connection_timeout 600s
188+
136189
arduino-cli config add board_manager.additional_urls https://www.pjrc.com/teensy/package_teensy_index.json
137-
arduino-cli core update-index
138190
arduino-cli config add board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
139191
arduino-cli core update-index
140-
arduino-cli core install esp32:esp32 # ESP32
141-
arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano
142-
arduino-cli core install arduino:sam # Arduino Due
143-
arduino-cli core install arduino:samd # Arduino Zero
144-
arduino-cli core install teensy:avr # PJRC Teensy
145-
arduino-cli core install esp8266:esp8266 # ESP8266
146-
arduino-cli core install arduino:mbed_nano # nanorp2040connect
147-
arduino-cli core install arduino:mbed_portenta # portenta_h7_m7
148-
arduino-cli core install arduino:mbed_edge
192+
193+
echo "CORE_ID: $CORE_ID"
194+
arduino-cli core install "$CORE_ID"
195+
196+
# The above is instead of:
197+
# arduino-cli core install esp32:esp32 # ESP32
198+
# arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano
199+
# arduino-cli core install arduino:sam # Arduino Due
200+
# arduino-cli core install arduino:samd # Arduino Zero
201+
# arduino-cli core install teensy:avr # PJRC Teensy
202+
# arduino-cli core install esp8266:esp8266 # ESP8266
203+
# arduino-cli core install arduino:mbed_nano # nanorp2040connect
204+
# arduino-cli core install arduino:mbed_portenta # portenta_h7_m7
205+
# arduino-cli core install arduino:mbed_edge
206+
# arduino-cli core install arduino:renesas_uno
207+
208+
# For reference:
209+
210+
# mbed nano not yet tested
149211
# sudo "/home/$USER/.arduino15/packages/arduino/hardware/mbed_nano/4.2.4/post_install.sh"
150-
arduino-cli core install arduino:renesas_uno
212+
213+
# Always install networking (not part of FQBN matrix)
214+
# The first one also creates directory: /home/runner/Arduino/libraries
151215
arduino-cli lib install "ArduinoJson" # Example dependency
152216
arduino-cli lib install "WiFiNINA" # ARDUINO_SAMD_NANO_33_IOT
153217
arduino-cli lib install "Ethernet" # Install Ethernet library
154218
arduino-cli lib install "Bridge" # Pseudo-network for things like arduino:samd:tian
155219
156-
- name: Set job environment variables
220+
- name: Set Job Environment Variables
157221
run: |
158222
# Script to assign some common environment variables after everything is installed
159223
@@ -178,6 +242,26 @@ jobs:
178242
# WOLFSSL_EXAMPLES_ROOT is the repo root, not example location
179243
echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT"
180244
245+
- name: Cache Arduino Packages
246+
uses: actions/cache@v4
247+
with:
248+
path: |
249+
~/.arduino15
250+
~/.cache/arduino
251+
~/.arduino15/staging
252+
253+
# Arduino libraries
254+
# Specific to Arduino CI Build (2 of 4) Arduinbo Release wolfSSL for Local Examples
255+
# Include all libraries, as the latest Arduino-wolfSSL will only change upon release.
256+
~/Arduino/libraries
257+
# Ensure wolfssl is not cached, we're always using the latest. See separate cache.
258+
!~/Arduino/libraries/wolfssl
259+
key: arduino-${{ runner.os }}-${{ env.CORE_ID }}-${{ hashFiles('Arduino/sketches/board_list.txt') }}
260+
261+
restore-keys: |
262+
arduino-${{ runner.os }}-${{ env.CORE_ID }}-
263+
arduino-${{ runner.os }}-
264+
181265
- name: Get wolfssl-examples
182266
run: |
183267
# Fetch Arduino examples from the wolfssl-examples repo
@@ -211,6 +295,9 @@ jobs:
211295
run: |
212296
# Run the local wolfssl-arduino.sh install script to install wolfssl Arduino library.
213297
298+
echo "Installing wolfSSL Arduino library (no cache hit)."
299+
rm -rf "$ARDUINO_ROOT/wolfssl"
300+
214301
# Methods of installing Arduino library:
215302
# 1) arduino-cli lib install "wolfSSL"
216303
# 2) manual copy of files (typical of the Arduino-wolfssl repo)
@@ -253,7 +340,8 @@ jobs:
253340
254341
# Fetch script and board list into WOLFSSL_EXAMPLES_DIRECTORY
255342
echo "Fetching board_list.txt from REPO_OWNER=$REPO_OWNER"
256-
curl -L "https://raw.githubusercontent.com/$REPO_OWNER/wolfssl-examples/master/Arduino/sketches/board_list.txt" -o "$WOLFSSL_EXAMPLES_DIRECTORY/$THIS_BOARD_LIST"
343+
curl -L "https://raw.githubusercontent.com/$REPO_OWNER/wolfssl-examples/master/Arduino/sketches/board_list.txt" \
344+
-o "$WOLFSSL_EXAMPLES_DIRECTORY/$THIS_BOARD_LIST"
257345
258346
# Check if the first line is "404: Not Found" - which would indicate the curl path above is bad.
259347
FILE="$WOLFSSL_EXAMPLES_DIRECTORY/board_list.txt"
@@ -272,7 +360,8 @@ jobs:
272360
273361
# Fetch the compile script from repo: https://github.com/[$USER]/wolfssl-examples/
274362
echo "Fetching compile-all-examples.sh from REPO_OWNER=$REPO_OWNER"
275-
curl -L "https://raw.githubusercontent.com/$REPO_OWNER/wolfssl-examples/master/Arduino/sketches/compile-all-examples.sh" -o "$WOLFSSL_EXAMPLES_DIRECTORY/compile-all-examples.sh"
363+
curl -L "https://raw.githubusercontent.com/$REPO_OWNER/wolfssl-examples/master/Arduino/sketches/compile-all-examples.sh" \
364+
-o "$WOLFSSL_EXAMPLES_DIRECTORY/compile-all-examples.sh"
276365
277366
# Check if the first line is "404: Not Found" - which would indicate the curl path above is bad.
278367
FILE="$WOLFSSL_EXAMPLES_DIRECTORY/compile-all-examples.sh"
@@ -318,8 +407,12 @@ jobs:
318407
319408
echo "Change directory to Arduino examples..."
320409
pushd "$WOLFSSL_EXAMPLES_DIRECTORY"
410+
chmod +x ./compile-all-examples.sh
411+
412+
# The script expects all the examples to be in the current directory.
413+
# Along with ./board_list.txt from examples repo
321414
echo "Current directory: $PWD"
322415
echo "Calling ./compile-all-examples.sh"
323-
bash ./compile-all-examples.sh
416+
bash ./compile-all-examples.sh ./board_list.txt "${{ matrix.fqbn }}"
324417
popd
325418
# End Compile Arduino Sketches for Various Boards

0 commit comments

Comments
 (0)