name: Test project on commit and pull requests

on: [push, pull_request]

jobs:
  build:

    runs-on: ${{ matrix.os }}
    strategy:
      matrix:        
        os: [windows-latest, ubuntu-latest, macos-latest]

    steps:      
  
      - name: net48 on windows
        if: runner.os == 'Windows'
        run: choco install netfx-4.8 --ignore-checksums
  
      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '6.x'

      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '8.x'      

      - uses: actions/checkout@v4

      - name: Install dependencies
        run: dotnet restore

      - name: Build
        # https://github.com/dotnet/core/issues/7840  failed to build with 0 errors
        run: dotnet build --configuration Debug --no-restore --disable-build-servers

      - name: Test net48
        if: runner.os == 'Windows'
        run: dotnet test ./tests/SharpGLTF.Ext.3DTiles.Tests/SharpGLTF.Ext.3DTiles.Tests.csproj --framework net48 --no-build

      - name: Test net6
        run: dotnet test ./tests/SharpGLTF.Ext.3DTiles.Tests/SharpGLTF.Ext.3DTiles.Tests.csproj --framework net6 --no-build

      - name: Test net8
        run: dotnet test ./tests/SharpGLTF.Ext.3DTiles.Tests/SharpGLTF.Ext.3DTiles.Tests.csproj --framework net8 --no-build
