name: Examples

on: [push, pull_request]

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-18.04, windows-latest, macos-latest]
        python-version: [3.7]
        example:
          - "examples/arduino-blink"
          - "examples/arduino-external-libs"
          - "examples/arduino-internal-libs"
          - "examples/arduino-mbed-doom"
          - "examples/arduino-mbed-rpc"
          - "examples/arduino-mxchip-azureiot"
          - "examples/arduino-mxchip-filesystem"
          - "examples/arduino-mxchip-sensors"
          - "examples/arduino-mxchip-wifiscan"
          - "examples/cmsis-blink"
          - "examples/libopencm3-1bitsy"
          - "examples/libopencm3-blink"
          - "examples/libopencm3-usb-cdcacm"
          - "examples/mbed-rtos-blink-baremetal"
          - "examples/mbed-rtos-custom-target"
          - "examples/mbed-rtos-ethernet-tls"
          - "examples/mbed-rtos-events"
          - "examples/mbed-rtos-filesystem"
          - "examples/mbed-rtos-mesh-minimal"
          - "examples/mbed-rtos-serial"
          - "examples/mbed-rtos-usb-keyboard"
          - "examples/mbed-rtos-wifi"
          - "examples/mbed-legacy-examples/mbed-blink"
          - "examples/mbed-legacy-examples/mbed-custom-target"
          - "examples/mbed-legacy-examples/mbed-dsp"
          - "examples/mbed-legacy-examples/mbed-events"
          - "examples/mbed-legacy-examples/mbed-filesystem"
          - "examples/mbed-legacy-examples/mbed-rtos"
          - "examples/mbed-legacy-examples/mbed-rtos-ethernet-tls"
          - "examples/mbed-legacy-examples/mbed-rtos-mesh-minimal"
          - "examples/mbed-legacy-examples/mbed-serial"
          - "examples/spl-blink"
          - "examples/stm32cube-hal-blink"
          - "examples/stm32cube-hal-eeprom-emulation"
          - "examples/stm32cube-hal-extmem-boot"
          - "examples/stm32cube-hal-iap"
          - "examples/stm32cube-hal-lcd"
          - "examples/stm32cube-hal-usb-device-dfu"
          - "examples/stm32cube-hal-wifi-client"
          - "examples/stm32cube-ll-blink"
          - "examples/zephyr-blink"
          - "examples/zephyr-cpp-synchronization"
          - "examples/zephyr-drivers-can"
          - "examples/zephyr-net-civetweb"
          - "examples/zephyr-net-https-client"
          - "examples/zephyr-subsys-usb-hid-mouse"
          - "tests/arduino-blink-different-cores"
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: "recursive"
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v1
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -U https://github.com/platformio/platformio/archive/develop.zip
          platformio platform install file://.
      - name: Build examples
        run: |
          platformio run -d ${{ matrix.example }}
