Skip to content

Commit d2217b5

Browse files
authored
Merge pull request wolfSSL#533 from gojimmypi/pr-arduino-examples
Parameterize compile-all-examples.sh for matrix use
2 parents 9f65fff + 799ce1c commit d2217b5

File tree

4 files changed

+340
-108
lines changed

4 files changed

+340
-108
lines changed

.github/workflows/arduino-release.yml

Lines changed: 112 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Arduino CI Build (2 of 4) Release Arduino wolfSSL for Local Examples
44
#
55
# Known to fail on current 5.8.2 wolfSSL Arduino Release
66
#
7-
# See ardduino.yml - Arduino CI Build (3 of 4) Latest wolfSSL for Local Examples
7+
# See arduino.yml - Arduino CI Build (3 of 4) Latest wolfSSL for Local Examples
88

99
#
1010
# Test local Arduino examples with published Arduino wolfssl
@@ -44,7 +44,7 @@ name: Arduino CI Build (2 of 4) Release Arduino wolfSSL for Local Examples
4444
#
4545
# To test locally:
4646
# cd [your WOLFSSL_ROOT], e.g. cd /mnt/c/workspace/wolfssl-$USER
47-
# [optional checkout] e.g. git checkout tags/v5.8.2-stable
47+
# [optional checkout] e.g. git checkout tags/v5.8.4-stable
4848
# pushd ./IDE/ARDUINO
4949
# export ARDUINO_ROOT="$HOME/Arduino/libraries"
5050
# ./wolfssl-arduino.sh INSTALL
@@ -56,28 +56,73 @@ on:
5656
push:
5757
branches: [ '**', 'master', 'main', 'release/**' ]
5858
paths:
59+
# Specific to this Arduino CI Build (2 of 4)
5960
- 'Arduino/**'
60-
- '!Arduino/sketches/board_list.txt' # Not triggered on arduino.yml file. TODO remove this line after next Arduino wolfssl release
6161
- '.github/workflows/arduino-release.yml'
6262
pull_request:
6363
branches: [ '**' ]
6464
paths:
65+
# Specific to this Arduino CI Build (2 of 4)
6566
- 'Arduino/**'
66-
- '!Arduino/sketches/board_list.txt' # Not triggered on arduino.yml file. TODO remove this line after next Arduino wolfssl release
6767
- '.github/workflows/arduino-release.yml'
6868
workflow_dispatch:
6969

7070
concurrency:
71-
group: ${{ github.workflow }}-${{ github.ref }}
71+
# Same branch push cancels other jobs. Other PR branches untouched
72+
73+
group: ${{ github.workflow }}-${{ github.ref_name }}
7274
cancel-in-progress: true
75+
7376
# END OF COMMON SECTION
7477

7578
jobs:
7679
build:
77-
# if: github.repository_owner == 'wolfssl'
80+
name: on FQBN (${{ matrix.fqbn }})
81+
if: github.repository_owner == 'wolfssl'
7882
runs-on: ubuntu-latest
83+
84+
strategy:
85+
fail-fast: false
86+
matrix:
87+
fqbn:
88+
# When editing this list, be sure to also edit file: board_list.txt
89+
# The compile-all-examples.sh optionally takes a FQBN parameter to
90+
# optionally compile all examples ONLY for the respective fully qualified board name.
91+
# See https://github.com/wolfSSL/wolfssl-examples/blob/master/Arduino/sketches/board_list.txt
92+
93+
- arduino:avr:ethernet
94+
- arduino:avr:leonardoeth
95+
- arduino:avr:mega
96+
- arduino:avr:nano
97+
- arduino:avr:uno
98+
- arduino:avr:yun
99+
- arduino:samd:mkrwifi1010
100+
- arduino:samd:mkr1000
101+
- arduino:samd:mkrfox1200
102+
- arduino:mbed_edge:edge_control
103+
- arduino:mbed_nano:nanorp2040connect
104+
- arduino:mbed_portenta:envie_m7
105+
- arduino:mbed_portenta:portenta_x8
106+
- arduino:renesas_uno:unor4wifi
107+
- arduino:sam:arduino_due_x
108+
- arduino:samd:arduino_zero_native
109+
- arduino:samd:tian
110+
- esp32:esp32:esp32
111+
- esp32:esp32:esp32s2
112+
- esp32:esp32:esp32s3
113+
- esp32:esp32:esp32c3
114+
- esp32:esp32:esp32c6
115+
- esp32:esp32:esp32h2
116+
- esp8266:esp8266:generic
117+
- teensy:avr:teensy40
118+
119+
# Not yet supported, not in standard library
120+
# - esp32:esp32:nano_nora
121+
122+
# End strategy matrix
79123
env:
80124
REPO_OWNER: ${{ github.repository_owner }}
125+
81126
steps:
82127
- name: Checkout Repository
83128
uses: actions/checkout@v4
@@ -86,7 +131,7 @@ jobs:
86131
run: |
87132
# Script to fetch and run install.sh from arduino/arduino-cli
88133
89-
# The install script will test to see if the recently installed apps in in the path
134+
# The install script will test to see if the recently installed apps in the path
90135
# So set it up in advance:
91136
mkdir -p "${PWD}/bin"
92137
echo "${PWD}/bin" >> $GITHUB_PATH
@@ -97,7 +142,7 @@ jobs:
97142
# Ensures that BINDIR exists before the installer runs
98143
mkdir -p "$ROOT_BIN"
99144
100-
# Save as a lobal environment variable
145+
# Save as a global environment variable
101146
echo "$ROOT_BIN" >> "$GITHUB_PATH"
102147
103148
# Download and run install script from Arduino:
@@ -128,34 +173,53 @@ jobs:
128173
echo "Alternative install script not needed."
129174
fi
130175
131-
- name: Confirm Arduino CLI install
176+
- name: Confirm Arduino CLI Install
132177
run: arduino-cli version
133178

179+
- name: Derive CORE_ID (vendor:arch from FQBN)
180+
run: |
181+
CORE_ID="$(echo '${{ matrix.fqbn }}' | cut -d: -f1-2)"
182+
echo "CORE_ID=$CORE_ID" >> "$GITHUB_ENV"
183+
134184
- name: Setup Arduino CLI
135185
run: |
136186
arduino-cli config init
137-
arduino-cli core update-index
187+
188+
# wait 10 minutes for big downloads (or use 0 for no limit)
189+
arduino-cli config set network.connection_timeout 600s
190+
138191
arduino-cli config add board_manager.additional_urls https://www.pjrc.com/teensy/package_teensy_index.json
139-
arduino-cli core update-index
140192
arduino-cli config add board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
141193
arduino-cli core update-index
142-
arduino-cli core install esp32:esp32 # ESP32
143-
arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano
144-
arduino-cli core install arduino:sam # Arduino Due
145-
arduino-cli core install arduino:samd # Arduino Zero
146-
arduino-cli core install teensy:avr # PJRC Teensy
147-
arduino-cli core install esp8266:esp8266 # ESP8266
148-
arduino-cli core install arduino:mbed_nano # nanorp2040connect
149-
arduino-cli core install arduino:mbed_portenta # portenta_h7_m7
150-
arduino-cli core install arduino:mbed_edge
194+
195+
echo "CORE_ID: $CORE_ID"
196+
arduino-cli core install "$CORE_ID"
197+
198+
# The above is instead of:
199+
# arduino-cli core install esp32:esp32 # ESP32
200+
# arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano
201+
# arduino-cli core install arduino:sam # Arduino Due
202+
# arduino-cli core install arduino:samd # Arduino Zero
203+
# arduino-cli core install teensy:avr # PJRC Teensy
204+
# arduino-cli core install esp8266:esp8266 # ESP8266
205+
# arduino-cli core install arduino:mbed_nano # nanorp2040connect
206+
# arduino-cli core install arduino:mbed_portenta # portenta_h7_m7
207+
# arduino-cli core install arduino:mbed_edge
208+
# arduino-cli core install arduino:renesas_uno
209+
210+
# For reference:
211+
212+
# mbed nano not yet tested
151213
# sudo "/home/$USER/.arduino15/packages/arduino/hardware/mbed_nano/4.2.4/post_install.sh"
152-
arduino-cli core install arduino:renesas_uno
214+
215+
# Always install networking (not part of FQBN matrix)
216+
# The first one also creates directory: /home/runner/Arduino/libraries
153217
arduino-cli lib install "ArduinoJson" # Example dependency
154218
arduino-cli lib install "WiFiNINA" # ARDUINO_SAMD_NANO_33_IOT
155219
arduino-cli lib install "Ethernet" # Install Ethernet library
156220
arduino-cli lib install "Bridge" # Pseudo-network for things like arduino:samd:tian
157221
158-
- name: Set job environment variables
222+
- name: Set Job Environment Variables
159223
run: |
160224
# Script to assign some common environment variables after everything is installed
161225
@@ -181,13 +245,34 @@ jobs:
181245
# WOLFSSL_EXAMPLES_ROOT is the report root, not example location
182246
echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT"
183247
248+
- name: Cache Arduino Packages
249+
uses: actions/cache@v4
250+
with:
251+
path: |
252+
~/.arduino15
253+
~/.cache/arduino
254+
~/.arduino15/staging
255+
256+
# Arduino libraries
257+
# Specific to Arduino CI Build (2 of 4) Arduinbo Release wolfSSL for Local Examples
258+
# Include all libraries, as the latest Arduino-wolfSSL will only change upon release.
259+
~/Arduino/libraries
260+
# Ensure wolfssl is not cached, we're always using the latest. See separate cache.
261+
!~/Arduino/libraries/wolfssl
262+
key: arduino-${{ runner.os }}-${{ env.CORE_ID }}-${{ hashFiles('Arduino/sketches/board_list.txt') }}
263+
264+
restore-keys: |
265+
arduino-${{ runner.os }}-${{ env.CORE_ID }}-
266+
arduino-${{ runner.os }}-
267+
184268
- name: Show wolfssl-examples
185269
run: |
186270
# The examples are local in this wolfssl-example repo, but should have been copied to library, above
187271
ls ./Arduino/sketches
188272
189273
# end Show wolfssl-examples
190274
275+
# Specific to Arduino CI Build (3 of 4) Arduinbo Release wolfSSL for Local Examples
191276
# - name: Shallow clone wolfssl
192277
#
193278
# not used here, we'll install with arduino-cli in next step
@@ -220,22 +305,25 @@ jobs:
220305
echo "Current directory = $PWD"
221306
echo "ARDUINO_ROOT = $ARDUINO_ROOT"
222307
echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT"
308+
echo "FQBN = ${{ matrix.fqbn }}"
223309
310+
echo "Change directory to Arduino examples..."
224311
pushd ./Arduino/sketches
225312
chmod +x ./compile-all-examples.sh
226313
227314
# The script expects all the examples to be in the current directory.
228-
# So copy from local directory to newly instlled wolfssl arduino library to compile there.
315+
# So copy from local directory to newly installed wolfssl arduino library to compile there.
229316
cp ./compile-all-examples.sh "$ARDUINO_ROOT/wolfssl/examples/compile-all-examples.sh"
230317
cp ./board_list.txt "$ARDUINO_ROOT/wolfssl/examples/board_list.txt"
231318
232319
# TODO Use standard board_list.txt after next release of wolfSSL
320+
# Remove this line and edit parameter to /compile-all-examples.sh board_list.txt
233321
cp ./board_list_v5.8.2.txt "$ARDUINO_ROOT/wolfssl/examples/board_list_v5.8.2.txt"
234322
235323
# Compile the Arduino library examples in-place
236324
pushd "$ARDUINO_ROOT/wolfssl/examples/"
237325
echo "PWD=$PWD"
238-
./compile-all-examples.sh board_list_v5.8.2.txt
326+
./compile-all-examples.sh board_list_v5.8.2.txt "${{ matrix.fqbn }}"
239327
popd
240328
popd
241329

0 commit comments

Comments
 (0)