|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master ] |
| 6 | + tags: ['v*'] |
| 7 | + pull_request: |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ci-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + lint-metadata: |
| 16 | + name: Arduino Lint |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Arduino Lint |
| 23 | + uses: arduino/arduino-lint-action@v1 |
| 24 | + with: |
| 25 | + library-manager: false |
| 26 | + project-type: library |
| 27 | + |
| 28 | + build-examples: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + board: [esp32dev, esp32-s3-devkitc-1, esp32-c3-devkitm-1, esp32-p4-evboard] |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - name: Set up Python |
| 39 | + uses: actions/setup-python@v5 |
| 40 | + with: |
| 41 | + python-version: '3.13' |
| 42 | + |
| 43 | + - name: Cache PlatformIO |
| 44 | + uses: actions/cache@v4 |
| 45 | + with: |
| 46 | + path: ~/.platformio |
| 47 | + key: ${{ runner.os }}-platformio-${{ hashFiles('**/library.json') }} |
| 48 | + restore-keys: | |
| 49 | + ${{ runner.os }}-platformio- |
| 50 | +
|
| 51 | + - name: Install PIOArduino Core |
| 52 | + run: python -m pip install --upgrade https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.18.zip |
| 53 | + |
| 54 | + - name: Install PIOArduino ESP32 Platform |
| 55 | + run: pio platform install https://github.com/pioarduino/platform-espressif32.git |
| 56 | + |
| 57 | + - name: Build library examples (ESP32 Arduino) |
| 58 | + run: | |
| 59 | + set -e |
| 60 | + for d in examples/*; do |
| 61 | + if [ -d "$d" ]; then |
| 62 | + echo "Building $d on ${{ matrix.board }} via PlatformIO CI" |
| 63 | + pio ci "$d" \ |
| 64 | + --board ${{ matrix.board }} \ |
| 65 | + --lib="." \ |
| 66 | + --project-option "platform=https://github.com/pioarduino/platform-espressif32.git" \ |
| 67 | + --project-option "build_unflags=-std=gnu++11" \ |
| 68 | + --project-option "build_flags=-std=gnu++20" \ |
| 69 | + --project-option "lib_deps=ArduinoJson@>=7.0.0, https://github.com/ESPToolKit/esp-worker.git, https://github.com/ESPToolKit/esp-eventbus.git" |
| 70 | + fi |
| 71 | + done |
| 72 | +
|
| 73 | + arduino-cli: |
| 74 | + runs-on: ubuntu-latest |
| 75 | + needs: build-examples |
| 76 | + env: |
| 77 | + ESP32_CORE_VERSION: 3.3.3 |
| 78 | + ESP32_PACKAGE_URL: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json |
| 79 | + ARDUINO_BOARDS: | |
| 80 | + esp32:esp32:esp32 esp32dev |
| 81 | + esp32:esp32:esp32s3 esp32-s3-devkitc-1 |
| 82 | + esp32:esp32:esp32c3 esp32-c3-devkitm-1 |
| 83 | + esp32:esp32:esp32p4 esp32-p4-evboard |
| 84 | + steps: |
| 85 | + - name: Checkout |
| 86 | + uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Set up Arduino CLI |
| 89 | + uses: arduino/setup-arduino-cli@v1 |
| 90 | + |
| 91 | + - name: Prepare Arduino directories |
| 92 | + run: | |
| 93 | + mkdir -p "${HOME}/.arduino15" |
| 94 | + mkdir -p "${HOME}/Arduino/libraries" |
| 95 | +
|
| 96 | + - name: Cache Arduino dependencies |
| 97 | + uses: actions/cache@v4 |
| 98 | + with: |
| 99 | + path: | |
| 100 | + ~/.arduino15 |
| 101 | + ~/Arduino/libraries |
| 102 | + key: ${{ runner.os }}-arduino-esp32-${{ env.ESP32_CORE_VERSION }}-${{ hashFiles('library.properties') }} |
| 103 | + restore-keys: | |
| 104 | + ${{ runner.os }}-arduino-esp32-${{ env.ESP32_CORE_VERSION }}- |
| 105 | + ${{ runner.os }}-arduino-esp32- |
| 106 | +
|
| 107 | + - name: Configure board manager for ESP32 |
| 108 | + run: | |
| 109 | + set -e |
| 110 | + arduino-cli config init --overwrite |
| 111 | + arduino-cli config set library.enable_unsafe_install true |
| 112 | + arduino-cli config add board_manager.additional_urls "${ESP32_PACKAGE_URL}" |
| 113 | + arduino-cli config dump |
| 114 | +
|
| 115 | + - name: Install ESP32 core |
| 116 | + run: | |
| 117 | + arduino-cli core update-index --additional-urls "${ESP32_PACKAGE_URL}" |
| 118 | + arduino-cli core install esp32:esp32@${ESP32_CORE_VERSION} --additional-urls "${ESP32_PACKAGE_URL}" |
| 119 | +
|
| 120 | + - name: Install libraries |
| 121 | + run: | |
| 122 | + arduino-cli lib update-index |
| 123 | + arduino-cli lib install "ArduinoJson" |
| 124 | + arduino-cli lib install --git-url "https://github.com/ESPToolKit/esp-worker.git" |
| 125 | + arduino-cli lib install --git-url "https://github.com/ESPToolKit/esp-eventbus.git" |
| 126 | +
|
| 127 | + - name: Add local library to sketchbook |
| 128 | + run: | |
| 129 | + set -e |
| 130 | + SKETCHBOOK_DIR="${HOME}/Arduino" |
| 131 | + mkdir -p "$SKETCHBOOK_DIR/libraries/ESPLifecycle" |
| 132 | + rsync -a --delete --exclude ".git" ./ "$SKETCHBOOK_DIR/libraries/ESPLifecycle/" |
| 133 | +
|
| 134 | + - name: Build examples |
| 135 | + env: |
| 136 | + BOARDS: ${{ env.ARDUINO_BOARDS }} |
| 137 | + run: | |
| 138 | + set -euo pipefail |
| 139 | + while read -r fqbn board_name; do |
| 140 | + if [ -z "$fqbn" ]; then |
| 141 | + continue |
| 142 | + fi |
| 143 | + echo "::group::Compiling examples for ${board_name} (${fqbn})" |
| 144 | + for d in examples/*; do |
| 145 | + if [ -d "$d" ]; then |
| 146 | + echo "Compiling $d" |
| 147 | + arduino-cli compile --fqbn "$fqbn" "$d" |
| 148 | + fi |
| 149 | + done |
| 150 | + echo "::endgroup::" |
| 151 | + done <<< "$BOARDS" |
| 152 | +
|
| 153 | + package-library: |
| 154 | + runs-on: ubuntu-latest |
| 155 | + needs: |
| 156 | + - build-examples |
| 157 | + - arduino-cli |
| 158 | + steps: |
| 159 | + - name: Checkout |
| 160 | + uses: actions/checkout@v4 |
| 161 | + |
| 162 | + - name: Set up Python |
| 163 | + uses: actions/setup-python@v5 |
| 164 | + with: |
| 165 | + python-version: '3.13' |
| 166 | + |
| 167 | + - name: Install PIOArduino Core |
| 168 | + run: python -m pip install --upgrade https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.18.zip |
| 169 | + |
| 170 | + - name: Pack library (PlatformIO) |
| 171 | + run: | |
| 172 | + mkdir -p dist |
| 173 | + pio pkg pack --output dist |
| 174 | +
|
| 175 | + - name: Upload package artifact |
| 176 | + uses: actions/upload-artifact@v4 |
| 177 | + with: |
| 178 | + name: esplifecycle-${{ github.sha }} |
| 179 | + path: dist/* |
0 commit comments