name: Arduino Library CI

on: 
  push:
    paths-ignore:
      - '**/**.md'
      - '/keywords.txt'
      - '/library.json'
      - '/library.properties'
      - '/ui'
      - '/docs'
  pull_request:
    paths-ignore:
      - '**/**.md'
      - '/keywords.txt'
      - '/library.json'
      - '/library.properties'
      - '/ui'
      - '/docs'

jobs:
  Async_CI:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-python@v1
        with:
          python-version: '3.x'
      
      - uses: actions/checkout@v2

      - uses: actions/checkout@v2
        with:
           repository: adafruit/ci-arduino
           path: ci

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

      - name: Set configuration
        run: arduino-cli config set library.enable_unsafe_install true 

      - name: Install test dependencies
        run: arduino-cli lib install --git-url https://github.com/me-no-dev/ESPAsyncWebServer --git-url https://github.com/me-no-dev/ESPAsyncTCP --git-url https://github.com/me-no-dev/AsyncTCP
      
      - name: Skip SyncDemo Example
        run: |
          cd examples
          cd Demo
          touch .esp32.test.skip
          touch .esp8266.test.skip

      - name: Configure ElegantOTA to Async Mode
        run: |
          cd src
          sed -i 's/ELEGANTOTA_USE_ASYNC_WEBSERVER 0/ELEGANTOTA_USE_ASYNC_WEBSERVER 1/' ElegantOTA.h
      
      - name: Test Async Demo
        continue-on-error: true
        run: python3 ci/build_platform.py esp8266 esp32

  Sync_CI:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-python@v1
        with:
          python-version: '3.x'
      
      - uses: actions/checkout@v2

      - uses: actions/checkout@v2
        with:
           repository: adafruit/ci-arduino
           path: ci

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

      - name: Skip AsyncDemo Example
        run: |
          cd examples
          cd AsyncDemo
          touch .esp32.test.skip
          touch .esp8266.test.skip

      - name: Test Sync Demo
        run: python3 ci/build_platform.py esp8266 esp32 picow_rp2040
