|
| 1 | +name: Arduino CI Build (2 of 4) Release Arduino wolfSSL for Local Examples |
| 2 | + |
| 3 | +# TODO - implement this once future wolfSSL is released |
| 4 | +# |
| 5 | +# Known to fail on current 5.8.2 wolfSSL Arduino Release |
| 6 | +# |
| 7 | +# See ardduino.yml - Arduino CI Build (3 of 4) Latest wolfSSL for Local Examples |
| 8 | + |
| 9 | +# |
| 10 | +# Test local Arduino examples with published Arduino wolfssl |
| 11 | +# |
| 12 | +# These 4 workflows across 3 repos are interdependent for the current $REPO_OWNER: |
| 13 | +# |
| 14 | +# Arduino CI Build 1: https://github.com/$REPO_OWNER/wolfssl # /.github/workflows/arduino.yml |
| 15 | +# - Builds Arduino library from local clone of wolfssl master branch |
| 16 | +# - Fetches examples from https://github.com/$REPO_OWNER/wolfssl-examples |
| 17 | +# |
| 18 | +# THIS Arduino CI Build 2: https://github.com/$REPO_OWNER/wolfssl-examples # /.github/workflows/arduino-release.yml |
| 19 | +# - Tests examples based on latest published release of Arduino library, NOT latest on wolfssl github. |
| 20 | +# - Should be identical to Arduino CI Build 3 in every way but wolfssl install. |
| 21 | +# - Copies only compile script from wolfssl-examples |
| 22 | +# - Builds local examples |
| 23 | +# - No other repos used |
| 24 | +# |
| 25 | +# Arduino CI Build 3: https://github.com/$REPO_OWNER/wolfssl-examples # /.github/workflows/arduino.yml |
| 26 | +# - Fetches current wolfSSL from https://github.com/$REPO_OWNER/wolfssl |
| 27 | +# - Creates an updated Arduino library |
| 28 | +# - Compiles local examples |
| 29 | +# - Contains the source of `compile-all-examples.sh` and respective board-list.txt |
| 30 | +# |
| 31 | +# Arduino CI Build 4: https://github.com/$REPO_OWNER/Arduino-wolfssl # /.github/workflows/arduino.yml |
| 32 | +# - Assembles and installs an updated Arduino wolfssl library from LOCAL wolfssl master source |
| 33 | +# - Copies only compile script copied from wolfssl-examples |
| 34 | +# - Builds local examples |
| 35 | +# - No other repos used |
| 36 | +# |
| 37 | +# |
| 38 | +# ** NOTE TO MAINTAINERS ** |
| 39 | +# |
| 40 | +# Consider using winmerge or similar tool to keep the 4 arduino[-release].yml files in relative sync. |
| 41 | +# Although there are some specific differences, most of the contents are otherwise identical. |
| 42 | +# |
| 43 | +# See https://github.com/wolfSSL/Arduino-wolfSSL |
| 44 | +# |
| 45 | +# To test locally: |
| 46 | +# cd [your WOLFSSL_ROOT], e.g. cd /mnt/c/workspace/wolfssl-$USER |
| 47 | +# [optional checkout] e.g. git checkout tags/v5.8.2-stable |
| 48 | +# pushd ./IDE/ARDUINO |
| 49 | +# export ARDUINO_ROOT="$HOME/Arduino/libraries" |
| 50 | +# ./wolfssl-arduino.sh INSTALL |
| 51 | +# cd [your WOLFSSL_EXAMPLES_ROOT] e.g. /mnt/c/workspace/wolfssl-examples-$USER |
| 52 | +# |
| 53 | + |
| 54 | +# START OF COMMON SECTION |
| 55 | +on: |
| 56 | + push: |
| 57 | + branches: [ '**', 'master', 'main', 'release/**' ] |
| 58 | + paths: |
| 59 | + - 'Arduino/**' |
| 60 | + - '!Arduino/sketches/board_list.txt' # Not triggered on arduino.yml file. TODO remove this line after next Arduino wolfssl release |
| 61 | + - '.github/workflows/arduino-release.yml' |
| 62 | + pull_request: |
| 63 | + branches: [ '**' ] |
| 64 | + paths: |
| 65 | + - 'Arduino/**' |
| 66 | + - '!Arduino/sketches/board_list.txt' # Not triggered on arduino.yml file. TODO remove this line after next Arduino wolfssl release |
| 67 | + - '.github/workflows/arduino-release.yml' |
| 68 | + workflow_dispatch: |
| 69 | + |
| 70 | +concurrency: |
| 71 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 72 | + cancel-in-progress: true |
| 73 | +# END OF COMMON SECTION |
| 74 | + |
| 75 | +jobs: |
| 76 | + build: |
| 77 | + # if: github.repository_owner == 'wolfssl' |
| 78 | + runs-on: ubuntu-latest |
| 79 | + env: |
| 80 | + REPO_OWNER: ${{ github.repository_owner }} |
| 81 | + steps: |
| 82 | + - name: Checkout Repository |
| 83 | + uses: actions/checkout@v4 |
| 84 | + |
| 85 | + - name: Install Arduino CLI |
| 86 | + run: | |
| 87 | + # Script to fetch and run install.sh from arduino/arduino-cli |
| 88 | +
|
| 89 | + # The install script will test to see if the recently installed apps in in the path |
| 90 | + # So set it up in advance: |
| 91 | + mkdir -p "${PWD}/bin" |
| 92 | + echo "${PWD}/bin" >> $GITHUB_PATH |
| 93 | +
|
| 94 | + # Sets the install directory to a consistent path at the repo root. |
| 95 | + ROOT_BIN="$GITHUB_WORKSPACE/bin" |
| 96 | +
|
| 97 | + # Ensures that BINDIR exists before the installer runs |
| 98 | + mkdir -p "$ROOT_BIN" |
| 99 | +
|
| 100 | + # Save as a lobal environment variable |
| 101 | + echo "$ROOT_BIN" >> "$GITHUB_PATH" |
| 102 | +
|
| 103 | + # Download and run install script from Arduino: |
| 104 | + # -S show errors; -L follow redirects; -v Verbose |
| 105 | + set +e # don't abort on error |
| 106 | + set -o pipefail |
| 107 | +
|
| 108 | + curl -vSL --retry 5 --retry-delay 10 \ |
| 109 | + https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh \ |
| 110 | + | sh -x |
| 111 | + rc=$? |
| 112 | + c_rc=${PIPESTATUS[0]} # curl's exit code |
| 113 | + s_rc=${PIPESTATUS[1]} # sh's exit code |
| 114 | +
|
| 115 | + set -e # restore default abort-on-error |
| 116 | +
|
| 117 | + # If there was a curl error, we have our own local copy that is more reliable and can add our own debugging |
| 118 | + if [ "$rc" -ne 0 ]; then |
| 119 | + echo "Primary install failed: curl=$c_rc, sh=$s_rc. Falling back..." >&2 |
| 120 | + echo "Using local copy of arduino_install.sh" |
| 121 | + pushd ./Arduino/sketches |
| 122 | + chmod +x ./arduino_install.sh |
| 123 | +
|
| 124 | + # Mimic curl install, does not use current directory: |
| 125 | + BINDIR="$ROOT_BIN" sh -x ./arduino_install.sh |
| 126 | + popd |
| 127 | + else |
| 128 | + echo "Alternative install script not needed." |
| 129 | + fi |
| 130 | +
|
| 131 | + - name: Confirm Arduino CLI install |
| 132 | + run: arduino-cli version |
| 133 | + |
| 134 | + - name: Setup Arduino CLI |
| 135 | + run: | |
| 136 | + arduino-cli config init |
| 137 | + arduino-cli core update-index |
| 138 | + arduino-cli config add board_manager.additional_urls https://www.pjrc.com/teensy/package_teensy_index.json |
| 139 | + arduino-cli core update-index |
| 140 | + arduino-cli config add board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json |
| 141 | + 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 |
| 151 | + # sudo "/home/$USER/.arduino15/packages/arduino/hardware/mbed_nano/4.2.4/post_install.sh" |
| 152 | + arduino-cli core install arduino:renesas_uno |
| 153 | + arduino-cli lib install "ArduinoJson" # Example dependency |
| 154 | + arduino-cli lib install "WiFiNINA" # ARDUINO_SAMD_NANO_33_IOT |
| 155 | + arduino-cli lib install "Ethernet" # Install Ethernet library |
| 156 | + arduino-cli lib install "Bridge" # Pseudo-network for things like arduino:samd:tian |
| 157 | +
|
| 158 | + - name: Set job environment variables |
| 159 | + run: | |
| 160 | + # Script to assign some common environment variables after everything is installed |
| 161 | +
|
| 162 | + ICON_OK=$(printf "\xE2\x9C\x85") |
| 163 | + ICON_FAIL=$(printf "\xE2\x9D\x8C") |
| 164 | +
|
| 165 | + echo "GITHUB_WORK=$(realpath "$GITHUB_WORKSPACE/../..")" >> "$GITHUB_ENV" |
| 166 | + echo "ARDUINO_ROOT=$(realpath "$HOME/Arduino/libraries")" >> "$GITHUB_ENV" |
| 167 | +
|
| 168 | + # Show repo-specific location of examples: |
| 169 | + echo "WOLFSSL_EXAMPLES_ROOT=$(realpath "./Arduino/sketches")" >> "$GITHUB_ENV" |
| 170 | +
|
| 171 | + # Show predefined summary: |
| 172 | + echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE" |
| 173 | +
|
| 174 | + # Show assigned build:env values (e.g. "wolfssl", "gojimmpi" or other owners): |
| 175 | + echo "REPO_OWNER = $REPO_OWNER" |
| 176 | +
|
| 177 | + # Show our custom values: |
| 178 | + echo "GITHUB_WORK = $GITHUB_WORK" |
| 179 | + echo "ARDUINO_ROOT = $ARDUINO_ROOT" |
| 180 | +
|
| 181 | + # WOLFSSL_EXAMPLES_ROOT is the report root, not example location |
| 182 | + echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT" |
| 183 | +
|
| 184 | + - name: Show wolfssl-examples |
| 185 | + run: | |
| 186 | + # The examples are local in this wolfssl-example repo, but should have been copied to library, above |
| 187 | + ls ./Arduino/sketches |
| 188 | +
|
| 189 | + # end Show wolfssl-examples |
| 190 | +
|
| 191 | + # - name: Shallow clone wolfssl |
| 192 | + # |
| 193 | + # not used here, we'll install with arduino-cli in next step |
| 194 | +
|
| 195 | + # |
| 196 | + # These comments are mainly here to help align with arduino.yml source side-by-side sync |
| 197 | + # |
| 198 | + # end wolfssl source |
| 199 | +
|
| 200 | + - name: Install wolfSSL Published Arduino library |
| 201 | + |
| 202 | + run: | |
| 203 | + # Install wolfssl via latest published version with arduino-cli lib install |
| 204 | +
|
| 205 | +
|
| 206 | + arduino-cli lib install "wolfSSL" |
| 207 | +
|
| 208 | + # End Install wolfSSL Arduino library |
| 209 | +
|
| 210 | + - name: List installed Arduino libraries |
| 211 | + run: arduino-cli lib list |
| 212 | + |
| 213 | + # This will fail with Arduino published wolfSSL v5.7.6 and older |
| 214 | + # as the examples moved. See https://github.com/wolfSSL/wolfssl/pull/8514 |
| 215 | + # |
| 216 | + - name: Compile Arduino Sketches for Various Boards |
| 217 | + run: | |
| 218 | + # Call the compile-all-examples.sh script to compile all the examples for each of the fqbn names in the local copy of board_list.txt |
| 219 | +
|
| 220 | + echo "Current directory = $PWD" |
| 221 | + echo "ARDUINO_ROOT = $ARDUINO_ROOT" |
| 222 | + echo "WOLFSSL_EXAMPLES_ROOT = $WOLFSSL_EXAMPLES_ROOT" |
| 223 | +
|
| 224 | + pushd ./Arduino/sketches |
| 225 | + chmod +x ./compile-all-examples.sh |
| 226 | +
|
| 227 | + # 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. |
| 229 | + cp ./compile-all-examples.sh "$ARDUINO_ROOT/wolfssl/examples/compile-all-examples.sh" |
| 230 | + cp ./board_list.txt "$ARDUINO_ROOT/wolfssl/examples/board_list.txt" |
| 231 | +
|
| 232 | + # TODO Use standard board_list.txt after next release of wolfSSL |
| 233 | + cp ./board_list_v5.8.2.txt "$ARDUINO_ROOT/wolfssl/examples/board_list_v5.8.2.txt" |
| 234 | +
|
| 235 | + # Compile the Arduino library examples in-place |
| 236 | + pushd "$ARDUINO_ROOT/wolfssl/examples/" |
| 237 | + echo "PWD=$PWD" |
| 238 | + ./compile-all-examples.sh board_list_v5.8.2.txt |
| 239 | + popd |
| 240 | + popd |
| 241 | +
|
| 242 | + # End Compile Arduino Sketches for Various Boards |
0 commit comments