name: Quality Check

on:
  pull_request:
  push:
    branches: [ main, master, dev, develop ]
  workflow_dispatch:

env:
  DOTNET_VERSION: '10.0.x'
  Solution_Name: LanMountainDesktop.sln

jobs:
  analyze:
    runs-on: windows-latest
    permissions:
      contents: read
      pull-requests: write
      checks: write
    
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          submodules: recursive
          ref: ${{ github.event.pull_request.head.sha }}

      - name: Setup .NET
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: ${{ env.DOTNET_VERSION }}

      - name: Restore
        run: dotnet restore ${{ env.Solution_Name }}

      - name: Build
        run: dotnet build ${{ env.Solution_Name }} -c Release --no-restore -v minimal

      - name: Check formatting
        run: dotnet format --verify-no-changes --verbosity diagnostic || true
        continue-on-error: true
