name: PlatformIO CI

on:
  workflow_dispatch:
  pull_request:
  push:
    paths:
      - "examples/**"
      - "src/**"
      - "lib/**"
      - "platformio.ini"
      - ".github/workflows/platformio.yml"
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        example:
          - Arduino_GFXDemo
          - Arduino_GFX_PDQgraphicstest
          - GetBatteryVoltage
          - I2CScan
          - ImageScroll
          - MPR121TouchSensor
          - PCBClock
          - PokerS3
          - SerialExample
          - T-Display-S3-MIDI
          - TFT_Rainbow
          - factory
          - lv_demos
          - nes
          - ota
          - sd
          - tft
          - touch_test
          - usb_hid_pad

    steps:
      - uses: actions/checkout@v3
      - uses: actions/cache@v3
        with:
          path: |
            ~/.cache/pip
            ~/.platformio/.cache
          key: ${{ runner.os }}-pio
      - uses: actions/setup-python@v4
        with:
          python-version: "3.9"
      - name: Install PlatformIO Core
        run: pip install --upgrade platformio

      - name: Run PlatformIO
        run: |
          export PLATFORMIO_SRC_DIR="examples/${{ matrix.example }}"
          pio run -e  ${{ matrix.example }}
