name: Tests
on:
  push:
    branches:
      - master
  # Run tests against the forked branch, but
  # do not allow access to secrets
  # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflows-in-forked-repositories
  pull_request:

env:
  SDK_VERSION: "9.0.x"

jobs:
  run-tests:
    strategy:
      matrix:
        os: ["ubuntu-latest", "macos-latest", "windows-latest"]
      fail-fast: false

    runs-on: "${{ matrix.os }}"
    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

      - uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
        with:
          dotnet-version: ${{ env.SDK_VERSION }}

      - name: Run DotNet CLI Tests
        run: >
          dotnet test Jellyfin.sln
          --configuration Release
          --collect:"XPlat Code Coverage"
          --settings tests/coverletArgs.runsettings
          --verbosity minimal

      - name: Merge code coverage results
        uses: danielpalme/ReportGenerator-GitHub-Action@1978db745da4a573ca4baa2d0f67175df51a148c # v5.4.16
        with:
          reports: "**/coverage.cobertura.xml"
          targetdir: "merged/"
          reporttypes: "Cobertura"

      # TODO - which action / tool to use to publish code coverage results?
      # - name: Publish code coverage results
