|
| 1 | +name: Arduino Library CI |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: 0 3 * * * |
| 6 | + workflow_dispatch: |
| 7 | + pull_request: |
| 8 | + |
| 9 | + |
| 10 | +jobs: |
| 11 | + check-if-needed: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + outputs: |
| 14 | + answer: ${{ steps.is-needed.outputs.answer }} |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + with: |
| 18 | + fetch-depth: 2 |
| 19 | + - name: Check if scheduled |
| 20 | + id: check-cron |
| 21 | + run: | |
| 22 | + iscron=false |
| 23 | + [[ "${{ github.event_name }}" == "schedule" ]] && iscron=true |
| 24 | + echo "status=$iscron" >> "$GITHUB_OUTPUT" |
| 25 | + - name: Check if dispatched |
| 26 | + id: check-dispatch |
| 27 | + run: | |
| 28 | + isdispatch=false |
| 29 | + [[ "${{ github.event_name }}" == "workflow_dispatch" ]] && isdispatch=true |
| 30 | + echo "status=$isdispatch" >> "$GITHUB_OUTPUT" |
| 31 | + - name: Check for Arduino file updates |
| 32 | + id: check-updated |
| 33 | + if: ${{ steps.check-cron.outputs.status }} == false && ${{ steps.check-dispatch.outputs.status }} == false |
| 34 | + run: | |
| 35 | + changedfiles=$(git diff --name-only -r HEAD^1 HEAD) |
| 36 | + ischanged=false |
| 37 | + for changedfile in ${changedfiles[*]}; do |
| 38 | + echo $changedfile |
| 39 | + if [[ $changedfile == *.c ]] || |
| 40 | + [[ $changedfile == *.cpp ]] || |
| 41 | + [[ $changedfile == *.h ]] || |
| 42 | + [[ $changedfile == *.hpp ]] || |
| 43 | + [[ $changedfile == *.ino ]]; then |
| 44 | + ischanged=true |
| 45 | + break |
| 46 | + fi |
| 47 | + done |
| 48 | + echo "status=$ischanged" >> "$GITHUB_OUTPUT" |
| 49 | + - name: Output Arduino needed |
| 50 | + id: is-needed |
| 51 | + run: | |
| 52 | + isneeded=false |
| 53 | + if [[ ${{ steps.check-cron.outputs.status }} == true ]] || |
| 54 | + [[ ${{ steps.check-dispatch.outputs.status }} == true ]] || |
| 55 | + [[ ${{ steps.check-updated.outputs.status }} == true ]]; then |
| 56 | + isneeded=true |
| 57 | + fi |
| 58 | + echo "answer=$isneeded" >> "$GITHUB_OUTPUT" |
| 59 | +
|
| 60 | + arduino: |
| 61 | + strategy: |
| 62 | + fail-fast: false |
| 63 | + matrix: |
| 64 | + arduino-platform: ["cpb", "cpc", "cpx_ada", "esp32", "esp8266", "feather32u4", "feather_m0_express", "feather_m4_express", "feather_rp2040", "flora", "funhouse", "gemma", "gemma_m0", "hallowing_m0", "hallowing_m4_tinyusb", "magtag", "metro_m0", "metro_m0_tinyusb", "metro_m4", "metro_m4_tinyusb", "monster_m4sk", "monster_m4sk_tinyusb", "neokeytrinkey_m0", "neotrellis_m4", "nrf52832", "nrf52840", "protrinket_5v", "proxlighttrinkey_m0", "pybadge", "pygamer", "pyportal", "qt2040_trinkey", "qtpy_m0", "qtpy_esp32s2", "rotarytrinkey_m0", "slidetrinkey_m0", "trinket_m0", "uno", "trinket_5v", "ledglasses_nrf52840" ] |
| 65 | + runs-on: ubuntu-latest |
| 66 | + if: needs.check-if-needed.outputs.answer == 'true' |
| 67 | + needs: check-if-needed |
| 68 | + steps: |
| 69 | + - uses: actions/setup-python@v4 |
| 70 | + with: |
| 71 | + python-version: "3.x" |
| 72 | + - uses: actions/checkout@v3 |
| 73 | + - uses: actions/checkout@v3 |
| 74 | + with: |
| 75 | + repository: adafruit/ci-arduino |
| 76 | + path: ci |
| 77 | + |
| 78 | + - name: pre-install |
| 79 | + run: bash ci/actions_install.sh |
| 80 | + |
| 81 | + # manually install some libraries |
| 82 | + - name: extra libraries |
| 83 | + run: | |
| 84 | + git clone --quiet https://github.com/adafruit/Cryptosuite.git /home/runner/Arduino/libraries/Cryptosuite |
| 85 | + git clone --quiet https://github.com/adafruit/WiFiNINA.git /home/runner/Arduino/libraries/WiFiNINA |
| 86 | + git clone --quiet https://github.com/adafruit/Adafruit_LSM303.git /home/runner/Arduino/libraries/Adafruit_LSM303 |
| 87 | + git clone --quiet https://github.com/moderndevice/CapSense.git /home/runner/Arduino/libraries/CapSense |
| 88 | + git clone --quiet https://github.com/PaintYourDragon/ffft.git /home/runner/Arduino/libraries/ffft |
| 89 | + git clone --quiet https://github.com/adafruit/RadioHead.git /home/runner/Arduino/libraries/RadioHead |
| 90 | + git clone --quiet https://github.com/me-no-dev/ESPAsyncTCP /home/runner/Arduino/libraries/ESPAsyncTCP |
| 91 | + git clone --quiet https://github.com/adafruit/Talkie /home/runner/Arduino/libraries/Talkie |
| 92 | + git clone --quiet https://github.com/Infineon/arduino-optiga-trust-m /home/runner/Arduino/libraries/arduinoOptigaTrustM |
| 93 | + git clone --quiet https://github.com/adafruit/HID /home/runner/Arduino/libraries/HID_Project |
| 94 | + rm -rf /home/runner/Arduino/libraries/ArduinoHttpClient |
| 95 | + git clone --quiet https://github.com/arduino-libraries/ArduinoHttpClient.git /home/runner/Arduino/libraries/ArduinoHttpClient |
| 96 | +
|
| 97 | + - name: test platforms |
| 98 | + run: python3 ci/build_platform.py ${{ matrix.arduino-platform }} |
| 99 | + |
| 100 | + |
| 101 | + - name: Upload build artifacts |
| 102 | + uses: actions/upload-artifact@v3 |
| 103 | + with: |
| 104 | + name: ${{ github.event.repository.name }}.${{ github.sha }} |
| 105 | + path: | |
| 106 | + build/*.hex |
| 107 | + build/*.bin |
| 108 | + build/*.uf2 |
| 109 | +
|
| 110 | + - name: Zip release files |
| 111 | + if: startsWith(github.ref, 'refs/tags/') |
| 112 | + run: | |
| 113 | + if [ -d build ]; then |
| 114 | + ( |
| 115 | + echo "Built from Adafruit Learning System Guides `git describe --tags` for ${{ matrix.arduino-platform }}" |
| 116 | + echo "Source code: https://github.com/adafruit/" |
| 117 | + echo "Adafruit Learning System: https://learn.adafruit.com/" |
| 118 | + ) > build/README.txt |
| 119 | + cd build && zip -9 -o ${{ matrix.arduino-platform }}.zip *.hex *.bin *.uf2 *.txt |
| 120 | + fi |
| 121 | +
|
| 122 | + - name: Create release |
| 123 | + if: startsWith(github.ref, 'refs/tags/') |
| 124 | + uses: softprops/action-gh-release@v1 |
| 125 | + with: |
| 126 | + files: build/${{ matrix.arduino-platform }}.zip |
| 127 | + fail_on_unmatched_files: false |
| 128 | + body: "Select the zip file corresponding to your board from the list below." |
0 commit comments