name: Build & Test

on:
  push:
    branches: [ master ]
    paths:
      - '**.cs'
      - '**.csproj'
      - '**.sln'
      - '**.git**'
      - '**.yml'
      # no docs on which one of these is supposed to work, so
      # why not just do both
      - 'RobustToolbox'
      - 'RobustToolbox/**'
  pull_request:
    branches: [ master ]
    paths:
      - '**.cs'
      - '**.csproj'
      - '**.sln'
      - '**.git**'
      - '**.yml'
      - 'RobustToolbox'
      - 'RobustToolbox/**'

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]

    runs-on: ${{ matrix.os }}

    steps:
    - name: Checkout Master
      uses: actions/checkout@v2

    - name: Setup Submodule
      run: |
        git submodule update --init --recursive
    
    - name: Pull engine updates
      uses: space-wizards/submodule-dependency@v0.1.5
    
    - name: Update Engine Submodules
      run: |
        cd RobustToolbox/
        git submodule update --init --recursive
    
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 6.0.x
    
    - name: Install dependencies
      run: dotnet restore
    
    - name: Build Project
      run: dotnet build --configuration Release --no-restore /p:WarningsAsErrors=nullable /m
    
    - name: Run Content.Tests
      run: dotnet test --no-build Content.Tests/Content.Tests.csproj -v n
    
    - name: Run Content.IntegrationTests
      shell: pwsh
      run: |
        $env:DOTNET_gcServer=1
        dotnet test --no-build Content.IntegrationTests/Content.IntegrationTests.csproj -v n
