Skip to content

Merge branch 'master' of https://github.com/cotestatnt/async-esp-fs-w… #3

Merge branch 'master' of https://github.com/cotestatnt/async-esp-fs-w…

Merge branch 'master' of https://github.com/cotestatnt/async-esp-fs-w… #3

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: (ESP8266) Build with PlatformIO
on:
workflow_dispatch:
push:
branches:
- master
- release/*
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
platformio-esp8266:
name: ESP8266 (pio) (board=${{ matrix.board }}, shard=${{ matrix.shard }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
board:
- d1_mini
shard: [1, 2, 3, 4]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache PlatformIO
uses: actions/cache@v4
with:
key: ${{ runner.os }}-pio
path: |
~/.cache/pip
~/.platformio
- name: Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install PIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Build Examples
run: |
set -uo pipefail
total_shards=4
shard="${{ matrix.shard }}"
# Examples not intended for ESP8266 / this job
EXCLUDE_EXAMPLES=(
esp32-cam
binaryWebSocket
csvLoggerSD
localRFID
mysqlRFID
mqtt_webserver
)
report_file="build-report-esp8266-pio-${{ matrix.board }}-shard${{ matrix.shard }}.txt"
: > "$report_file"
failures=0
total=0
index=0
for dir in examples/*; do
if [[ ! -d "$dir" ]]; then
continue
fi
example="$(basename "$dir")"
if [[ " ${EXCLUDE_EXAMPLES[*]} " == *" ${example} "* ]]; then
echo "Skipping: ${example}"
printf '%-25s : SKIP\n' "${example}" >> "$report_file"
continue
fi
# Split examples across shards for faster CI.
index=$((index + 1))
example_shard=$(( (index - 1) % total_shards + 1 ))
if [[ "$example_shard" != "$shard" ]]; then
continue
fi
total=$((total + 1))
echo "============================================================="
echo "Building examples/${example} (board=${{ matrix.board }}, shard=${shard})..."
echo "============================================================="
echo "::group::pio run - examples/${example}"
set +e
# Use a per-example build directory to avoid cross-example artefacts.
PLATFORMIO_BUILD_DIR=".pio/build-${{ matrix.board }}-${example}" \
PLATFORMIO_SRC_DIR="examples/${example}" PIO_BOARD="${{ matrix.board }}" \
pio run -e ci-esp8266
rc=$?
set -e
echo "::endgroup::"
if [[ $rc -eq 0 ]]; then
printf '%-25s : OK\n' "${example}" >> "$report_file"
else
failures=$((failures + 1))
printf '%-25s : FAIL (exit=%s)\n' "${example}" "$rc" >> "$report_file"
fi
done
echo ""
echo "==================== Build report (esp8266/pio, board=${{ matrix.board }}, shard=${{ matrix.shard }}) ===================="
cat "$report_file"
echo "==============================================================================================="
echo "Total attempted: ${total} | Failures: ${failures}"
# Do not fail the job here: the final report job will decide.
- name: Upload build report
if: always()
uses: actions/upload-artifact@v4
with:
name: pio-esp8266-report-${{ matrix.board }}-shard${{ matrix.shard }}
path: build-report-esp8266-pio-${{ matrix.board }}-shard${{ matrix.shard }}.txt
report:
name: ESP8266 (pio) - Final report
runs-on: ubuntu-latest
needs: platformio-esp8266
if: always()
steps:
- name: Download all reports
uses: actions/download-artifact@v4
with:
pattern: pio-esp8266-report-*
merge-multiple: true
path: reports
- name: Print final report and set status
run: |
set -uo pipefail
echo "==================== Final build report (ESP8266/pio) ===================="
failures=0
files=0
shopt -s nullglob
for f in reports/*.txt; do
files=$((files + 1))
echo "--- ${f} ---"
cat "$f"
if grep -q " : FAIL" "$f"; then
failures=$((failures + 1))
fi
done
if [[ $files -eq 0 ]]; then
echo "No report files found (artifact download failed?)"
exit 1
fi
echo "==========================================================================="
if [[ $failures -gt 0 ]]; then
echo "One or more shards reported FAIL."
exit 1
fi