DShotRMT/.github/workflows/ci.yml

214 lines
8.8 KiB
YAML

name: ESP32 Build & Quality Check
permissions:
contents: read
on:
push:
branches: [ '*' ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ============================================================================
# Code Quality & Linting
# ============================================================================
quality-check-linux:
name: Arduino Lint Check (Linux)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
- uses: arduino/setup-arduino-cli@v2
- name: Restore Arduino Core Cache
id: cache-core-linux
uses: actions/cache/restore@v4
with:
path: |
~/.arduino15/packages
~/.arduino15/cache
key: arduino-core-linux-esp32-v1
restore-keys: |
arduino-core-linux-
- name: Ensure ESP32 Core is installed (Linux)
shell: bash
run: |
if [[ "${{ steps.cache-core-linux.outputs.cache-hit }}" != "true" ]]; then
arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
fi
if ! arduino-cli core list | grep -q 'esp32'; then
arduino-cli core install esp32:esp32
fi
- name: Save Arduino Core Cache
if: always() && steps.cache-core-linux.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/.arduino15/packages
~/.arduino15/cache
key: arduino-core-linux-esp32-v1
- uses: arduino/arduino-lint-action@v2
with:
path: ${{ github.workspace }}
compliance: strict
library-manager: update
verbose: true
quality-check-windows:
name: Arduino Lint Check (Windows)
runs-on: windows-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
- uses: arduino/setup-arduino-cli@v2
- name: Restore Arduino Core Cache
id: cache-core-win
uses: actions/cache/restore@v4
with:
path: |
~/.arduino15/packages
~/.arduino15/cache
key: arduino-core-windows-esp32-v1
restore-keys: |
arduino-core-windows-
- name: Ensure ESP32 Core is installed (Windows)
if: steps.cache-core-win.outputs.cache-hit != 'true'
shell: pwsh
run: |
if ($env:cache-core-win.outputs.cache-hit -ne 'true') {
arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
}
if (-not (arduino-cli core list | Select-String 'esp32')) {
arduino-cli core install esp32:esp32
}
- name: Save Arduino Core Cache
if: always() && steps.cache-core-win.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/.arduino15/packages
~/.arduino15/cache
key: arduino-core-windows-esp32-v1
- uses: arduino/arduino-lint-action@v2
with:
path: ${{ github.workspace }}
compliance: strict
library-manager: update
verbose: true
# ============================================================================
# Compilation Test
# ============================================================================
compile-all-sketches:
name: Compile ${{ matrix.sketch }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
sketch:
- examples/throttle_percent/throttle_percent.ino
- examples/dshot300/dshot300.ino
- examples/web_control/web_control.ino
- examples/web_client/web_client.ino
steps:
- uses: actions/checkout@v5
- uses: arduino/setup-arduino-cli@v2
- name: Restore Arduino Core & Libraries Cache
id: cache-all
uses: actions/cache/restore@v4
with:
path: |
~/.arduino15/packages
~/.arduino15/cache
~/Arduino/libraries
key: ${{ runner.os }}-arduino-full-esp32-v1-${{ hashFiles('**/library.properties', '**/platform.txt') }}
restore-keys: |
${{ runner.os }}-arduino-full-esp32-v1-
- name: Ensure ESP32 Core and Dependencies (Linux)
if: runner.os == 'Linux' && steps.cache-all.outputs.cache-hit != 'true'
shell: bash
run: |
arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
arduino-cli core install esp32:esp32
mkdir -p ~/Arduino/libraries
git clone --depth=1 https://github.com/bblanchon/ArduinoJson.git ~/Arduino/libraries/ArduinoJson
git clone --depth=1 https://github.com/ESP32Async/ESPAsyncWebServer ~/Arduino/libraries/ESPAsyncWebServer
git clone --depth=1 https://github.com/ESP32Async/AsyncTCP ~/Arduino/libraries/AsyncTCP
- name: Ensure ESP32 Core and Dependencies (Windows)
if: runner.os == 'Windows' && steps.cache-all.outputs.cache-hit != 'true'
shell: pwsh
run: |
arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
arduino-cli core install esp32:esp32
if (-not (Test-Path -Path "$env:USERPROFILE/Arduino/libraries/ArduinoJson")) {
git clone --depth=1 https://github.com/bblanchon/ArduinoJson.git "$env:USERPROFILE/Arduino/libraries/ArduinoJson"
}
if (-not (Test-Path -Path "$env:USERPROFILE/Arduino/libraries/ESPAsyncWebServer")) {
git clone --depth=1 https://github.com/ESP32Async/ESPAsyncWebServer "$env:USERPROFILE/Arduino/libraries/ESPAsyncWebServer"
}
if (-not (Test-Path -Path "$env:USERPROFILE/Arduino/libraries/AsyncTCP")) {
git clone --depth=1 https://github.com/ESP32Async/AsyncTCP "$env:USERPROFILE/Arduino/libraries/AsyncTCP"
}
- name: Save Arduino Core & Libraries Cache
if: always() && steps.cache-all.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/.arduino15/packages
~/.arduino15/cache
~/Arduino/libraries
key: ${{ runner.os }}-arduino-full-esp32-v1-${{ hashFiles('**/library.properties', '**/platform.txt') }}
- name: Compile Sketch (Linux)
shell: bash
if: runner.os == 'Linux'
run: arduino-cli compile --fqbn esp32:esp32:esp32 --library ${{ github.workspace }} "${{ matrix.sketch }}"
- name: Compile Sketch (Windows)
shell: pwsh
if: runner.os == 'Windows'
run: arduino-cli compile --fqbn esp32:esp32:esp32 --library ${{ github.workspace }} "${{ matrix.sketch }}"
# ============================================================================
# Build Status Report
# ============================================================================
build-summary:
name: Build Summary
runs-on: ubuntu-latest
if: always()
needs:
- quality-check-linux
- quality-check-windows
- compile-all-sketches
steps:
- name: Create Build Summary
run: |
echo "# 🔧 DShotRMT Build Report" >> $GITHUB_STEP_SUMMARY
echo "| Check | Status | Details |" >> $GITHUB_STEP_SUMMARY
echo "|-------|--------|---------|" >> $GITHUB_STEP_SUMMARY
[[ "${{ needs.quality-check-linux.result }}" == "success" && "${{ needs.quality-check-windows.result }}" == "success" ]] \
&& echo "| 📋 Quality Check | ✅ Passed | Arduino Lint completed successfully |" >> $GITHUB_STEP_SUMMARY \
|| echo "| 📋 Quality Check | ❌ Failed | Check Arduino Lint report |" >> $GITHUB_STEP_SUMMARY
[[ "${{ needs.compile-all-sketches.result }}" == "success" ]] \
&& echo "| 🔨 Compilation | ✅ Passed | All examples compiled successfully |" >> $GITHUB_STEP_SUMMARY \
|| echo "| 🔨 Compilation | ❌ Failed | Compilation errors detected |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
[[ "${{ needs.quality-check-linux.result }}" == "success" && "${{ needs.quality-check-windows.result }}" == "success" && "${{ needs.compile-all-sketches.result }}" == "success" ]] \
&& echo "## 🎉 All Checks Passed!" >> $GITHUB_STEP_SUMMARY \
&& echo "Your DShotRMT library is ready for deployment." >> $GITHUB_STEP_SUMMARY \
|| echo "## ⚠️ Action Required" >> $GITHUB_STEP_SUMMARY \
&& echo "Please review the failed checks and address any issues." >> $GITHUB_STEP_SUMMARY