name: "Run unit tests"
on:
  workflow_dispatch:
  push:
  pull_request:

jobs:
  unit-test:
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: recursive
      - name: install-deps
        run: |
          sudo apt update
          sudo apt install -y git pkg-config build-essential meson libsdl2-dev libreadline-dev dfu-util cmake libusb-1.0-0 libusb-1.0-0-dev libcodec2-dev codec2
      - name: setup meson
        run: |
          cd ${{github.workspace}}
          meson setup build
      - name: M17 Viterbi Unit Test
        run: meson test -C build "M17 Viterbi Unit Test"
      - name: M17 Golay Unit Test
        run: meson test -C build "M17 Golay Unit Test"
      - name: M17 RRC Test
        run: meson test -C build "M17 RRC Test"
      - name: Codeplug Test
        run: meson test -C build "Codeplug Test"
      # The following tests are disabled because they appear to be flakey when run in CI
      # - name: Sine Test
      #   run: meson test -C build "Sine Test"
      # - name: Linux InputStream Test
      #   run: meson test -C build "Linux InputStream Test"
