Skip to content

Commit affebc0

Browse files
authored
Merge pull request #23 from gojimmypi/pr-arduino-examples
Update Arduino workflow with parameterized matrix
2 parents c7f6ce1 + 05ab92c commit affebc0

File tree

1 file changed

+131
-29
lines changed

1 file changed

+131
-29
lines changed

.github/workflows/arduino.yml

Lines changed: 131 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ name: Arduino CI Build (4 of 4) Arduino-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
@@ -56,16 +56,63 @@ on:
5656
workflow_dispatch:
5757

5858
concurrency:
59-
group: ${{ github.workflow }}-${{ github.ref }}
59+
# Same branch push cancels other jobs. Other PR branches untouched
60+
61+
group: ${{ github.workflow }}-${{ github.ref_name }}
6062
cancel-in-progress: true
63+
6164
# END OF COMMON SECTION
6265

6366
jobs:
6467
build:
68+
name: Compile (${{ matrix.fqbn }})
69+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6570
# if: github.repository_owner == 'wolfssl'
71+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6672
runs-on: ubuntu-latest
73+
74+
strategy:
75+
fail-fast: false
76+
matrix:
77+
fqbn:
78+
# When editing this list, be sure to also edit file: board_list.txt
79+
# The compile-all-examples.sh optionally takes a FQBN parameter to
80+
# optionally compile all examples ONLY for the respective fully qualified board name.
81+
# See https://github.com/wolfSSL/wolfssl-examples/blob/master/Arduino/sketches/board_list.txt
82+
83+
- arduino:avr:ethernet
84+
- arduino:avr:leonardoeth
85+
- arduino:avr:mega
86+
- arduino:avr:nano
87+
- arduino:avr:uno
88+
- arduino:avr:yun
89+
- arduino:samd:mkrwifi1010
90+
- arduino:samd:mkr1000
91+
- arduino:samd:mkrfox1200
92+
- arduino:mbed_edge:edge_control
93+
- arduino:mbed_nano:nanorp2040connect
94+
- arduino:mbed_portenta:envie_m7
95+
- arduino:mbed_portenta:portenta_x8
96+
- arduino:renesas_uno:unor4wifi
97+
- arduino:sam:arduino_due_x
98+
- arduino:samd:arduino_zero_native
99+
- arduino:samd:tian
100+
- esp32:esp32:esp32
101+
- esp32:esp32:esp32s2
102+
- esp32:esp32:esp32s3
103+
- esp32:esp32:esp32c3
104+
- esp32:esp32:esp32c6
105+
- esp32:esp32:esp32h2
106+
- esp8266:esp8266:generic
107+
- teensy:avr:teensy40
108+
109+
# Not yet supported, not in standard library
110+
# - esp32:esp32:nano_nora
111+
112+
# End strategy matrix
67113
env:
68114
REPO_OWNER: ${{ github.repository_owner }}
115+
69116
steps:
70117
- name: Checkout Repository
71118
uses: actions/checkout@v4
@@ -74,7 +121,7 @@ jobs:
74121
run: |
75122
# Script to fetch and run install.sh from arduino/arduino-cli
76123
77-
# The install script will test to see if the recently installed apps in in the path
124+
# The install script will test to see if the recently installed apps in the path
78125
# So set it up in advance:
79126
mkdir -p "${PWD}/bin"
80127
echo "${PWD}/bin" >> $GITHUB_PATH
@@ -85,7 +132,7 @@ jobs:
85132
# Ensures that BINDIR exists before the installer runs
86133
mkdir -p "$ROOT_BIN"
87134
88-
# Save as a lobal environment variable
135+
# Save as a global environment variable
89136
echo "$ROOT_BIN" >> "$GITHUB_PATH"
90137
91138
# Download and run install script from Arduino:
@@ -116,34 +163,53 @@ jobs:
116163
echo "Alternative install script not needed."
117164
fi
118165
119-
- name: Confirm Arduino CLI install
166+
- name: Confirm Arduino CLI Install
120167
run: arduino-cli version
121168

169+
- name: Derive CORE_ID (vendor:arch from FQBN)
170+
run: |
171+
CORE_ID="$(echo '${{ matrix.fqbn }}' | cut -d: -f1-2)"
172+
echo "CORE_ID=$CORE_ID" >> "$GITHUB_ENV"
173+
122174
- name: Setup Arduino CLI
123175
run: |
124176
arduino-cli config init
125-
arduino-cli core update-index
177+
178+
# wait 10 minutes for big downloads (or use 0 for no limit)
179+
arduino-cli config set network.connection_timeout 600s
180+
126181
arduino-cli config add board_manager.additional_urls https://www.pjrc.com/teensy/package_teensy_index.json
127-
arduino-cli core update-index
128182
arduino-cli config add board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
129183
arduino-cli core update-index
130-
arduino-cli core install esp32:esp32 # ESP32
131-
arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano
132-
arduino-cli core install arduino:sam # Arduino Due
133-
arduino-cli core install arduino:samd # Arduino Zero
134-
arduino-cli core install teensy:avr # PJRC Teensy
135-
arduino-cli core install esp8266:esp8266 # ESP8266
136-
arduino-cli core install arduino:mbed_nano # nanorp2040connect
137-
arduino-cli core install arduino:mbed_portenta # portenta_h7_m7
138-
arduino-cli core install arduino:mbed_edge
184+
185+
echo "CORE_ID: $CORE_ID"
186+
arduino-cli core install "$CORE_ID"
187+
188+
# The above is instead of:
189+
# arduino-cli core install esp32:esp32 # ESP32
190+
# arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano
191+
# arduino-cli core install arduino:sam # Arduino Due
192+
# arduino-cli core install arduino:samd # Arduino Zero
193+
# arduino-cli core install teensy:avr # PJRC Teensy
194+
# arduino-cli core install esp8266:esp8266 # ESP8266
195+
# arduino-cli core install arduino:mbed_nano # nanorp2040connect
196+
# arduino-cli core install arduino:mbed_portenta # portenta_h7_m7
197+
# arduino-cli core install arduino:mbed_edge
198+
# arduino-cli core install arduino:renesas_uno
199+
200+
# For reference:
201+
202+
# mbed nano not yet tested
139203
# sudo "/home/$USER/.arduino15/packages/arduino/hardware/mbed_nano/4.2.4/post_install.sh"
140-
arduino-cli core install arduino:renesas_uno
204+
205+
# Always install networking (not part of FQBN matrix)
206+
# The first one also creates directory: /home/runner/Arduino/libraries
141207
arduino-cli lib install "ArduinoJson" # Example dependency
142208
arduino-cli lib install "WiFiNINA" # ARDUINO_SAMD_NANO_33_IOT
143209
arduino-cli lib install "Ethernet" # Install Ethernet library
144210
arduino-cli lib install "Bridge" # Pseudo-network for things like arduino:samd:tian
145211
146-
- name: Set job environment variables
212+
- name: Set Job Environment Variables
147213
run: |
148214
# Script to assign some common environment variables after everything is installed
149215
@@ -166,18 +232,50 @@ jobs:
166232
echo "ARDUINO_ROOT = $ARDUINO_ROOT"
167233
168234
# WOLFSSL_EXAMPLES_ROOT is the report root, not example location
169-
# echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT"
235+
echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT"
236+
237+
- name: Compute cache key parts
238+
id: parts
239+
shell: bash
240+
run: |
241+
# From FQBN "vendor:arch:board" get "vendor:arch"
242+
CORE_ID="$(echo "${{ matrix.fqbn }}" | awk -F: '{print $1 ":" $2}')"
243+
echo "CORE_ID=$CORE_ID" >> "$GITHUB_OUTPUT"
244+
245+
# Also expose vendor only for broad fallbacks
246+
VENDOR="$(echo "$CORE_ID" | cut -d: -f1)"
247+
echo "VENDOR=$VENDOR" >> "$GITHUB_OUTPUT"
248+
249+
- name: Cache Arduino packages
250+
uses: actions/cache@v4
251+
with:
252+
path: |
253+
~/.arduino15
254+
~/.cache/arduino
255+
~/.arduino15/staging
256+
257+
# Arduino libraries
258+
# Specific to Arduino CI Build (2 of 4) Arduinbo Release wolfSSL for Local Examples
259+
# Include all libraries, as the latest Arduino-wolfSSL will only change upon release.
260+
~/Arduino/libraries
261+
# Ensure wolfssl is not cached, we're always using the latest. See separate cache.
262+
!~/Arduino/libraries/wolfssl
263+
key: arduino-${{ runner.os }}-${{ env.CORE_ID }}-${{ hashFiles('Arduino/sketches/board_list.txt') }}
264+
265+
restore-keys: |
266+
arduino-${{ runner.os }}-${{ env.CORE_ID }}-
267+
arduino-${{ runner.os }}-
170268
171269
# - name: Show wolfssl-examples
172-
# (not used, as wolfssl source is already here in ARduino-wolfSSL)
270+
# (not used, as wolfssl source is already here in Arduino-wolfSSL)
173271

174272
# end Show wolfssl-examples
175273

176274
# - name: Shallow clone wolfssl
177275
# (not used, as wolfssl source is already here in Arduino-wolfSSL)
178276
#
179277

180-
# ** END ** Set job environment variables
278+
# ** END ** Shallow clone wolfssl
181279

182280
- name: Get wolfssl-examples
183281
run: |
@@ -197,7 +295,8 @@ jobs:
197295
#
198296
# arduino-cli lib install "wolfSSL"
199297
#
200-
# But using the current repo as the source:
298+
# But using the current repo as the source (delete for matrix cache):
299+
rm -rf "$ARDUINO_ROOT/wolfssl"
201300
mkdir -p "$ARDUINO_ROOT/wolfssl"
202301
203302
# Methods of installing Arduino library:
@@ -236,25 +335,26 @@ jobs:
236335
echo "WOLFSSL_EXAMPLES_DIRECTORY=$WOLFSSL_EXAMPLES_DIRECTORY"
237336
238337
# Fetch script and board list into WOLFSSL_EXAMPLES_DIRECTORY
239-
# TODO edit PR branch path:
240-
curl -L "https://raw.githubusercontent.com/$REPO_OWNER/wolfssl-examples/master/Arduino/sketches/board_list_v5.8.2.txt" -o "$WOLFSSL_EXAMPLES_DIRECTORY/board_list.txt"
338+
# TODO edit board list name upon release and publish of wolfSSL 5.8.4 in Arduino-wolfSSL:
339+
curl -L "https://raw.githubusercontent.com/$REPO_OWNER/wolfssl-examples/master/Arduino/sketches/board_list_v5.8.2.txt" \
340+
-o "$WOLFSSL_EXAMPLES_DIRECTORY/board_list.txt"
241341
242-
# Check if the first line is "404: Not Found" - which would indicate the curl path above is bad.
243342
FILE="$WOLFSSL_EXAMPLES_DIRECTORY/board_list.txt"
244343
245-
# Ensure the file exists
344+
# Ensure the board list file exists
246345
if [[ ! -f "$FILE" ]]; then
247346
echo "File not found: $FILE"
248347
exit 1
249348
fi
250349
251-
# Check if the first line is "404: Not Found"
350+
# Check if the first line is "404: Not Found" - which would indicate the curl path above is bad.
252351
if [[ $(head -n 1 "$FILE") == "404: Not Found" ]]; then
253352
echo "The first line is '404: Not Found'"
254353
exit 1
255354
fi
256355
257-
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"
356+
curl -L "https://raw.githubusercontent.com/$REPO_OWNER/wolfssl-examples/master/Arduino/sketches/compile-all-examples.sh" \
357+
-o "$WOLFSSL_EXAMPLES_DIRECTORY/compile-all-examples.sh"
258358
259359
# Check if the first line is "404: Not Found" - which would indicate the curl path above is bad.
260360
FILE="$WOLFSSL_EXAMPLES_DIRECTORY/compile-all-examples.sh"
@@ -297,11 +397,13 @@ jobs:
297397
echo "ARDUINO_ROOT: $ARDUINO_ROOT"
298398
WOLFSSL_EXAMPLES_DIRECTORY="$ARDUINO_ROOT/wolfssl/examples"
299399
echo "WOLFSSL_EXAMPLES_DIRECTORY: $WOLFSSL_EXAMPLES_DIRECTORY"
400+
echo "FQBN = ${{ matrix.fqbn }}"
300401
301402
echo "Change directory to Arduino examples..."
302403
pushd "$WOLFSSL_EXAMPLES_DIRECTORY"
303404
echo "Current directory: $PWD"
405+
ls -al
304406
echo "Calling ./compile-all-examples.sh"
305-
bash ./compile-all-examples.sh
407+
bash ./compile-all-examples.sh ./board_list.txt "${{ matrix.fqbn }}"
306408
popd
307409
# End Compile Arduino Sketches for Various Boards

0 commit comments

Comments
 (0)