Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 131 additions & 29 deletions .github/workflows/arduino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ name: Arduino CI Build (4 of 4) Arduino-wolfSSL
#
# To test locally:
# cd [your WOLFSSL_ROOT], e.g. cd /mnt/c/workspace/wolfssl-$USER
# [optional checkout] e.g. git checkout tags/v5.8.2-stable
# [optional checkout] e.g. git checkout tags/v5.8.4-stable
# pushd ./IDE/ARDUINO
# export ARDUINO_ROOT="$HOME/Arduino/libraries"
# ./wolfssl-arduino.sh INSTALL
Expand All @@ -56,16 +56,63 @@ on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# Same branch push cancels other jobs. Other PR branches untouched

group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

# END OF COMMON SECTION

jobs:
build:
name: Compile (${{ matrix.fqbn }})
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# if: github.repository_owner == 'wolfssl'
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
fqbn:
# When editing this list, be sure to also edit file: board_list.txt
# The compile-all-examples.sh optionally takes a FQBN parameter to
# optionally compile all examples ONLY for the respective fully qualified board name.
# See https://github.com/wolfSSL/wolfssl-examples/blob/master/Arduino/sketches/board_list.txt

- arduino:avr:ethernet
- arduino:avr:leonardoeth
- arduino:avr:mega
- arduino:avr:nano
- arduino:avr:uno
- arduino:avr:yun
- arduino:samd:mkrwifi1010
- arduino:samd:mkr1000
- arduino:samd:mkrfox1200
- arduino:mbed_edge:edge_control
- arduino:mbed_nano:nanorp2040connect
- arduino:mbed_portenta:envie_m7
- arduino:mbed_portenta:portenta_x8
- arduino:renesas_uno:unor4wifi
- arduino:sam:arduino_due_x
- arduino:samd:arduino_zero_native
- arduino:samd:tian
- esp32:esp32:esp32
- esp32:esp32:esp32s2
- esp32:esp32:esp32s3
- esp32:esp32:esp32c3
- esp32:esp32:esp32c6
- esp32:esp32:esp32h2
- esp8266:esp8266:generic
- teensy:avr:teensy40

# Not yet supported, not in standard library
# - esp32:esp32:nano_nora

# End strategy matrix
env:
REPO_OWNER: ${{ github.repository_owner }}

steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -74,7 +121,7 @@ jobs:
run: |
# Script to fetch and run install.sh from arduino/arduino-cli

# The install script will test to see if the recently installed apps in in the path
# The install script will test to see if the recently installed apps in the path
# So set it up in advance:
mkdir -p "${PWD}/bin"
echo "${PWD}/bin" >> $GITHUB_PATH
Expand All @@ -85,7 +132,7 @@ jobs:
# Ensures that BINDIR exists before the installer runs
mkdir -p "$ROOT_BIN"

# Save as a lobal environment variable
# Save as a global environment variable
echo "$ROOT_BIN" >> "$GITHUB_PATH"

# Download and run install script from Arduino:
Expand Down Expand Up @@ -116,34 +163,53 @@ jobs:
echo "Alternative install script not needed."
fi

- name: Confirm Arduino CLI install
- name: Confirm Arduino CLI Install
run: arduino-cli version

- name: Derive CORE_ID (vendor:arch from FQBN)
run: |
CORE_ID="$(echo '${{ matrix.fqbn }}' | cut -d: -f1-2)"
echo "CORE_ID=$CORE_ID" >> "$GITHUB_ENV"

- name: Setup Arduino CLI
run: |
arduino-cli config init
arduino-cli core update-index

# wait 10 minutes for big downloads (or use 0 for no limit)
arduino-cli config set network.connection_timeout 600s

arduino-cli config add board_manager.additional_urls https://www.pjrc.com/teensy/package_teensy_index.json
arduino-cli core update-index
arduino-cli config add board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
arduino-cli core update-index
arduino-cli core install esp32:esp32 # ESP32
arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano
arduino-cli core install arduino:sam # Arduino Due
arduino-cli core install arduino:samd # Arduino Zero
arduino-cli core install teensy:avr # PJRC Teensy
arduino-cli core install esp8266:esp8266 # ESP8266
arduino-cli core install arduino:mbed_nano # nanorp2040connect
arduino-cli core install arduino:mbed_portenta # portenta_h7_m7
arduino-cli core install arduino:mbed_edge

echo "CORE_ID: $CORE_ID"
arduino-cli core install "$CORE_ID"

# The above is instead of:
# arduino-cli core install esp32:esp32 # ESP32
# arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano
# arduino-cli core install arduino:sam # Arduino Due
# arduino-cli core install arduino:samd # Arduino Zero
# arduino-cli core install teensy:avr # PJRC Teensy
# arduino-cli core install esp8266:esp8266 # ESP8266
# arduino-cli core install arduino:mbed_nano # nanorp2040connect
# arduino-cli core install arduino:mbed_portenta # portenta_h7_m7
# arduino-cli core install arduino:mbed_edge
# arduino-cli core install arduino:renesas_uno

# For reference:

# mbed nano not yet tested
# sudo "/home/$USER/.arduino15/packages/arduino/hardware/mbed_nano/4.2.4/post_install.sh"
arduino-cli core install arduino:renesas_uno

# Always install networking (not part of FQBN matrix)
# The first one also creates directory: /home/runner/Arduino/libraries
arduino-cli lib install "ArduinoJson" # Example dependency
arduino-cli lib install "WiFiNINA" # ARDUINO_SAMD_NANO_33_IOT
arduino-cli lib install "Ethernet" # Install Ethernet library
arduino-cli lib install "Bridge" # Pseudo-network for things like arduino:samd:tian

- name: Set job environment variables
- name: Set Job Environment Variables
run: |
# Script to assign some common environment variables after everything is installed

Expand All @@ -166,18 +232,50 @@ jobs:
echo "ARDUINO_ROOT = $ARDUINO_ROOT"

# WOLFSSL_EXAMPLES_ROOT is the report root, not example location
# echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT"
echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT"

- name: Compute cache key parts
id: parts
shell: bash
run: |
# From FQBN "vendor:arch:board" get "vendor:arch"
CORE_ID="$(echo "${{ matrix.fqbn }}" | awk -F: '{print $1 ":" $2}')"
echo "CORE_ID=$CORE_ID" >> "$GITHUB_OUTPUT"

# Also expose vendor only for broad fallbacks
VENDOR="$(echo "$CORE_ID" | cut -d: -f1)"
echo "VENDOR=$VENDOR" >> "$GITHUB_OUTPUT"

- name: Cache Arduino packages
uses: actions/cache@v4
with:
path: |
~/.arduino15
~/.cache/arduino
~/.arduino15/staging

# Arduino libraries
# Specific to Arduino CI Build (2 of 4) Arduinbo Release wolfSSL for Local Examples
# Include all libraries, as the latest Arduino-wolfSSL will only change upon release.
~/Arduino/libraries
# Ensure wolfssl is not cached, we're always using the latest. See separate cache.
!~/Arduino/libraries/wolfssl
key: arduino-${{ runner.os }}-${{ env.CORE_ID }}-${{ hashFiles('Arduino/sketches/board_list.txt') }}

restore-keys: |
arduino-${{ runner.os }}-${{ env.CORE_ID }}-
arduino-${{ runner.os }}-

# - name: Show wolfssl-examples
# (not used, as wolfssl source is already here in ARduino-wolfSSL)
# (not used, as wolfssl source is already here in Arduino-wolfSSL)

# end Show wolfssl-examples

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

# ** END ** Set job environment variables
# ** END ** Shallow clone wolfssl

- name: Get wolfssl-examples
run: |
Expand All @@ -197,7 +295,8 @@ jobs:
#
# arduino-cli lib install "wolfSSL"
#
# But using the current repo as the source:
# But using the current repo as the source (delete for matrix cache):
rm -rf "$ARDUINO_ROOT/wolfssl"
mkdir -p "$ARDUINO_ROOT/wolfssl"

# Methods of installing Arduino library:
Expand Down Expand Up @@ -236,25 +335,26 @@ jobs:
echo "WOLFSSL_EXAMPLES_DIRECTORY=$WOLFSSL_EXAMPLES_DIRECTORY"

# Fetch script and board list into WOLFSSL_EXAMPLES_DIRECTORY
# TODO edit PR branch path:
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"
# TODO edit board list name upon release and publish of wolfSSL 5.8.4 in Arduino-wolfSSL:
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"

# Check if the first line is "404: Not Found" - which would indicate the curl path above is bad.
FILE="$WOLFSSL_EXAMPLES_DIRECTORY/board_list.txt"

# Ensure the file exists
# Ensure the board list file exists
if [[ ! -f "$FILE" ]]; then
echo "File not found: $FILE"
exit 1
fi

# Check if the first line is "404: Not Found"
# Check if the first line is "404: Not Found" - which would indicate the curl path above is bad.
if [[ $(head -n 1 "$FILE") == "404: Not Found" ]]; then
echo "The first line is '404: Not Found'"
exit 1
fi

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"
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"

# Check if the first line is "404: Not Found" - which would indicate the curl path above is bad.
FILE="$WOLFSSL_EXAMPLES_DIRECTORY/compile-all-examples.sh"
Expand Down Expand Up @@ -297,11 +397,13 @@ jobs:
echo "ARDUINO_ROOT: $ARDUINO_ROOT"
WOLFSSL_EXAMPLES_DIRECTORY="$ARDUINO_ROOT/wolfssl/examples"
echo "WOLFSSL_EXAMPLES_DIRECTORY: $WOLFSSL_EXAMPLES_DIRECTORY"
echo "FQBN = ${{ matrix.fqbn }}"

echo "Change directory to Arduino examples..."
pushd "$WOLFSSL_EXAMPLES_DIRECTORY"
echo "Current directory: $PWD"
ls -al
echo "Calling ./compile-all-examples.sh"
bash ./compile-all-examples.sh
bash ./compile-all-examples.sh ./board_list.txt "${{ matrix.fqbn }}"
popd
# End Compile Arduino Sketches for Various Boards