# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: Build (pioarduino)

on:
  push:
    branches:
      - main
      - dev
      - release/*
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  platformio-rpi:
    name: PIO RPI
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        board:
          - rpipicow
          - rpipico2w

    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: |
          for i in `ls examples`; do
            echo "============================================================="
            echo "Building examples/$i..."
            echo "============================================================="
            PLATFORMIO_SRC_DIR=examples/$i PIO_BOARD=${{ matrix.board }} pio run -e ci-raspberrypi
          done