Update CI.yml #167
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
strategy: | |
matrix: | |
board: | |
- esp32:esp32:esp32:PartitionScheme=min_spiffs,DebugLevel=none | |
- esp32:esp32:esp32:PartitionScheme=min_spiffs,DebugLevel=verbose | |
runs-on: ubuntu-latest | |
name: ${{ matrix.board }} | |
env: | |
run-build: ${{ contains(matrix.board, 'esp32:esp32') || contains(github.event.head_commit.message, 'CI_BUILD_ALL') || contains(github.event.head_commit.message, 'Bump version to') || contains(github.event.head_commit.message, format('{0}', matrix.board)) }} | |
steps: | |
- name: Install arduino-cli | |
if: ${{ env.run-build == 'true' }} | |
run: | |
| | |
mkdir -p ~/.local/bin | |
echo "~/.local/bin" >> $GITHUB_PATH | |
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh | |
- name: Get platform name | |
if: ${{ env.run-build == 'true' }} | |
uses: jungwinter/split@v2 | |
id: split | |
with: | |
msg: ${{ matrix.board }} | |
separator: ':' | |
- name: Prepare platform-specific settings | |
if: ${{ env.run-build == 'true' }} | |
id: prep | |
run: | |
| | |
# common settings - no extra options, skip nothing, all warnings | |
echo "options=''" >> $GITHUB_OUTPUT | |
echo "skip-pattern=(Waveshare_7_5_3C|Waveshare_7_5_T7).ino" >> $GITHUB_OUTPUT | |
echo "warnings='all'" >> $GITHUB_OUTPUT | |
# platform-dependent settings - extra board options, board index URLs, skip patterns etc. | |
if [[ "${{ contains(matrix.board, 'esp32:esp32') }}" == "true" ]]; then | |
# ESP32 | |
#python -m pip install pyserial | |
echo "index-url=--additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" >> $GITHUB_OUTPUT | |
fi | |
- name: Install libraries | |
if: ${{ env.run-build == 'true' }} | |
run: | |
| | |
declare -a required_libs=( | |
"MQTT@2.5.2" | |
"GxEPD2@1.5.8" | |
"U8g2_for_Adafruit_GFX@1.8.0" | |
"cQueue@2.0" | |
"TheengsDecoder@1.7.8" | |
"ArduinoJson@7.2.1" | |
"pocketBME280@1.2.4" | |
"NimBLE-Arduino@1.4.3" | |
"Sensirion I2C SCD4x@0.4.0" | |
"Sensirion Core@0.7.1" | |
) | |
for i in "${required_libs[@]}" | |
do | |
arduino-cli lib install "$i" | |
done | |
- name: Install platform | |
if: ${{ env.run-build == 'true' }} | |
run: | |
| | |
arduino-cli core update-index ${{ format('{0}', steps.prep.outputs.index-url) }} | |
arduino-cli core install ${{ format('{0}:{1} {2}', steps.split.outputs._0, steps.split.outputs._1, steps.prep.outputs.index-url) }} | |
- name: Checkout repository | |
if: ${{ env.run-build == 'true' }} | |
uses: actions/checkout@v4 | |
- name: Build examples | |
if: ${{ env.run-build == 'true' }} | |
run: | |
| | |
for example in $(find $PWD/examples -name '*.ino' | sort); do | |
# check whether to skip this sketch | |
if [ ! -z '${{ steps.prep.outputs.skip-pattern }}' ] && [[ ${example} =~ ${{ steps.prep.outputs.skip-pattern }} ]]; then | |
# skip sketch | |
echo -e "\n\033[1;33mSkipped ${example##*/} (matched with ${{ steps.prep.outputs.skip-pattern }})\033[0m"; | |
else | |
# build sketch | |
echo -e "\n\033[1;33mBuilding ${example##*/} ... \033[0m"; | |
arduino-cli compile --libraries /home/runner/work/ESP32-e-Paper-Weather-Display --fqbn ${{ matrix.board }}${{ steps.prep.outputs.options }} ${example} --warnings=${{ steps.prep.outputs.warnings }} | |
if [ $? -ne 0 ]; then | |
echo -e "\033[1;31m${example##*/} build FAILED\033[0m\n"; | |
exit 1; | |
else | |
echo -e "\033[1;32m${example##*/} build PASSED\033[0m\n"; | |
fi | |
fi | |
done |