|
| 1 | +name: Arduino CI Build |
| 2 | + |
| 3 | +# See https://github.com/wolfSSL/Arduino-wolfSSL |
| 4 | + |
| 5 | +# TODO remove '*' om push/ branches, and uncomment github.repository_owner == 'wolfssl' |
| 6 | + |
| 7 | +# START OF COMMON SECTION |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: [ '*', 'master', 'main', 'release/**' ] |
| 11 | + pull_request: |
| 12 | + branches: [ '*' ] |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | +# END OF COMMON SECTION |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + # if: github.repository_owner == 'wolfssl' |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - name: Checkout Repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Install Arduino CLI |
| 29 | + run: | |
| 30 | + curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh |
| 31 | + echo "$(pwd)/bin" >> $GITHUB_PATH |
| 32 | +
|
| 33 | + - name: Setup Arduino CLI |
| 34 | + run: | |
| 35 | + arduino-cli config init |
| 36 | + arduino-cli core update-index |
| 37 | + arduino-cli config add board_manager.additional_urls https://www.pjrc.com/teensy/package_teensy_index.json |
| 38 | + arduino-cli core update-index |
| 39 | + arduino-cli config add board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json |
| 40 | + arduino-cli core update-index |
| 41 | + arduino-cli core install esp32:esp32 # ESP32 |
| 42 | + arduino-cli core install arduino:avr # Arduino Uno, Mega, Nano |
| 43 | + arduino-cli core install arduino:sam # Arduino Due |
| 44 | + arduino-cli core install arduino:samd # Arduino Zero |
| 45 | + arduino-cli core install teensy:avr # PJRC Teensy |
| 46 | + arduino-cli core install esp8266:esp8266 # ESP8266 |
| 47 | + arduino-cli lib install "ArduinoJson" # Example dependency |
| 48 | + arduino-cli lib install "WiFiNINA" # ARDUINO_SAMD_NANO_33_IOT |
| 49 | + arduino-cli lib install "Ethernet" # Install Ethernet library |
| 50 | +
|
| 51 | + # arduino-cli lib install "wolfSSL" # Install wolfSSL library from Arduino |
| 52 | +
|
| 53 | + # Install current wolfSSL as an Arduino library: |
| 54 | + - name: Shallow clone wolfssl |
| 55 | + run: | |
| 56 | + git clone --depth 1 https://github.com/wolfSSL/wolfssl.git |
| 57 | + echo "Checking Arduino library directories..." |
| 58 | +
|
| 59 | + - name: Install wolfSSL Arduino library |
| 60 | + run: | |
| 61 | + pushd wolfssl/IDE/ARDUINO |
| 62 | +
|
| 63 | + # Set default ARDUINO_ROOT. TODO: once script is updated, this should be removed. |
| 64 | + export ARDUINO_ROOT="$HOME/Arduino/libraries" |
| 65 | +
|
| 66 | + bash wolfssl-arduino.sh INSTALL # Install wolfSSL library |
| 67 | + popd |
| 68 | +
|
| 69 | + # This will fail with Arduino published wolfSSL v5.7.6 and older |
| 70 | + # See https://github.com/wolfSSL/wolfssl/pull/8514 |
| 71 | + # Pending: "arduino:sam:arduino_due_x" |
| 72 | + - name: Compile Arduino Sketches for various boards |
| 73 | + run: | |
| 74 | + set +e |
| 75 | + SUCCESS=true |
| 76 | + for BOARD in "arduino:avr:uno" "esp32:esp32:esp32" "arduino:avr:mega" "arduino:avr:nano" "arduino:samd:arduino_zero_native" "esp8266:esp8266:generic" "teensy:avr:teensy40"; do |
| 77 | + echo "Compiling for $BOARD" |
| 78 | + for EXAMPLE in $(find Arduino/sketches -mindepth 1 -maxdepth 1 -type d); do |
| 79 | + if [[ "$BOARD" =~ "arduino:avr:uno"|"arduino:avr:mega"|"arduino:avr:nano"|"arduino:samd:arduino_zero_native" && ( "$EXAMPLE" =~ "wolfssl_server" || "$EXAMPLE" =~ "wolfssl_client" || "$EXAMPLE" =~ "test" ) ]]; then |
| 80 | + echo "Skipping $EXAMPLE for $BOARD (No WiFi support)" |
| 81 | + continue |
| 82 | + fi |
| 83 | +
|
| 84 | + if [[ "$BOARD" =~ "arduino:avr:uno"|"arduino:avr:nano" && ( "$EXAMPLE" != "template" ) && ( "$EXAMPLE" != "wolfssl_version" ) ]]; then |
| 85 | + echo "Skipping $EXAMPLE for $BOARD (memory limited)" |
| 86 | + continue |
| 87 | + fi |
| 88 | +
|
| 89 | + # TODO: new template known to fail. Fixed in https://github.com/wolfSSL/wolfssl/pull/8514 |
| 90 | + if [[ "$EXAMPLE" =~ "Arduino/sketches/template" ]]; then |
| 91 | + echo "Skipping $EXAMPLE for $BOARD (needs code update. see wolfssl/pull/8514)" |
| 92 | + continue |
| 93 | + fi |
| 94 | +
|
| 95 | + # TODO: new wolfssl_AES_CTR known to fail. Fixed in https://github.com/wolfSSL/wolfssl/pull/8514 |
| 96 | + if [[ "$EXAMPLE" =~ "Arduino/sketches/wolfssl_AES_CTR" ]]; then |
| 97 | + echo "Skipping $EXAMPLE for $BOARD (needs updated user_settings.h - see wolfssl/pull/8514)" |
| 98 | + continue |
| 99 | + fi |
| 100 | +
|
| 101 | + # TODO skip Compiling Arduino/sketches/wolfssl_version for arduino:avr:mega |
| 102 | + if [[ "$BOARD" =~ "arduino:avr:mega" && "$EXAMPLE" =~ "Arduino/sketches/wolfssl_version" ]]; then |
| 103 | + echo "Skipping $EXAMPLE for $BOARD (needs updated code - see wolfssl/pull/8514)" |
| 104 | + continue |
| 105 | + fi |
| 106 | +
|
| 107 | + # TODO skip ESP8266 |
| 108 | + if [[ "$BOARD" =~ "esp8266:esp8266:generic" ]]; then |
| 109 | + echo "Skipping $EXAMPLE for $BOARD (needs testing)" |
| 110 | + continue |
| 111 | + fi |
| 112 | +
|
| 113 | + # Arduino/sketches/wolfssl_server on teensy:avr:teensy40 |
| 114 | + if [[ "$BOARD" =~ "teensy:avr:teensy40" && ( "$EXAMPLE" =~ "Arduino/sketches/wolfssl_client"|"Arduino/sketches/wolfssl_server" ) ]]; then |
| 115 | + echo "Skipping $EXAMPLE for $BOARD (needs ethernet update)" |
| 116 | + continue |
| 117 | + fi |
| 118 | +
|
| 119 | + # If otherwise not excluded, compile this $EXAMPLE for this $BOARD |
| 120 | + echo "Compiling $EXAMPLE for $BOARD" |
| 121 | + arduino-cli compile --fqbn $BOARD "$EXAMPLE" |
| 122 | + EXIT_CODE=$? |
| 123 | + if [ "$EXIT_CODE" -ne 0 ]; then |
| 124 | + echo "❌ Compilation failed for $EXAMPLE on $BOARD (Exit code: $EXIT_CODE)" |
| 125 | + SUCCESS=false |
| 126 | + else |
| 127 | + echo "✅ Compilation succeeded for $EXAMPLE on $BOARD" |
| 128 | + fi |
| 129 | + done |
| 130 | + done |
| 131 | +
|
| 132 | + if [ "$SUCCESS" = true ]; then |
| 133 | + echo "✅ All sketches compiled successfully!" |
| 134 | + else |
| 135 | + echo "❌ One or more sketches failed to compile." |
| 136 | + exit 1 |
| 137 | + fi |
| 138 | +
|
| 139 | + - name: Upload Compilation Artifacts |
| 140 | + uses: actions/upload-artifact@v4 |
| 141 | + with: |
| 142 | + name: compiled-sketch |
| 143 | + path: Arduino/sketches/template/build/* |
0 commit comments