name: Pull Request
on:
  workflow_dispatch:
  pull_request:
    branches:
      - main
    paths-ignore:
      - '.github/**'
      - '.gitignore'
      - '**/*/LICENSE.md'
      - '**/*/README.md'
      - '**/*/Dockerfile'
jobs:
  run_tests:
    name: Run tests
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Setup .NET
        uses: actions/setup-dotnet@v5
        with:
          dotnet-version: 10.0.x
      - name: Setup Node.js
        uses: actions/setup-node@v6
        with:
          node-version: lts/*
      - name: Install report generator
        run: dotnet tool install --global dotnet-reportgenerator-globaltool
      - name: Restore dependencies
        run: dotnet restore
      - name: Build solution
        run: dotnet build --no-restore
      - name: Test solution
        run: dotnet test
      - name: Upload server test coverage
        uses: actions/upload-artifact@v4
        with:
          name: server-test-coverage
          path: tests/GroundsForSupport.Server.Tests/TestResults/
      - name: Upload client test coverage
        uses: actions/upload-artifact@v4
        with:
          name: client-test-coverage
          path: src/GroundsForSupport.Client/coverage/
  lint_and_format:
    name: Lint and Format
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Setup .NET
        uses: actions/setup-dotnet@v5
        with:
          dotnet-version: 10.0.x
      - name: Setup Node.js
        uses: actions/setup-node@v6
        with:
          node-version: lts/*
      - name: Restore dependencies
        run: dotnet restore
      - name: Build solution
        run: dotnet build --no-restore
      - name: Format dotnet solution
        run: dotnet format
      - name: Lint and format client
        working-directory: src/GroundsForSupport.Client/
        run: npm run lint && npm run format
