name: Run Unit Tests

on:
  push:
    branches:
      - main
      - master
  pull_request:
  workflow_dispatch:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:

      - name: Clone Repo
        uses: actions/checkout@v4

      - name: Setup Build Environment
        uses: ./.github/actions/setup-build-environment

      - name: Verify ArduinoJson pin
        run: |
          python3 -B scripts/check_arduinojson_pin.py --self-test
          python3 -B scripts/check_arduinojson_pin.py

      - name: Run Unit Tests
        run: pio test -e native -e native_kiss_modem -vv

      - name: Upload Test Results
        # Upload test results even if the test step failed.
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: test-results
          path: .pio/build/native/
