name: Build

on: [pull_request, push, repository_dispatch]

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        arduino-platform: ["metro_m0_tinyusb", "metro_m4_tinyusb", "cpb", "nrf52840"]

    runs-on: ubuntu-latest

    steps:
    - name: Setup Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.x'
    - name: Checkout code
      uses: actions/checkout@v2  
    - name: Checkout adafruit/ci-arduino
      uses: actions/checkout@v2
      with:
         repository: adafruit/ci-arduino
         path: ci

    - name: pre-install
      run: bash ci/actions_install.sh

    - name: test platforms
      run: python3 ci/build_platform.py ${{ matrix.arduino-platform }}

  clang_and_doxy:
    runs-on: ubuntu-latest
    needs: build
    steps:
    - name: Setup Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.x'  
    - name: Checkout code
      uses: actions/checkout@v2
    - name: Checkout adafruit/ci-arduino
      uses: actions/checkout@v2
      with:
         repository: adafruit/ci-arduino
         path: ci

    - name: pre-install
      run: bash ci/actions_install.sh

    - name: clang
      run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r . 

    - name: doxygen
      env:
        GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
        PRETTYNAME : "Adafruit TinyUSB Library"
      run: bash ci/doxy_gen_and_deploy.sh
