hrntsm/STBDotNet

View on GitHub
.github/workflows/dotnet-core.yml

Summary

Maintainability
Test Coverage
name: .NET Core

on:
  pull_request:
    branches: [ main, develop ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '6.0.x'
        include-prerelease: true
    - name: Install dependencies
      run: dotnet restore
    - name: Build
      run: dotnet build --configuration Release --no-restore
    - name: Upload
      uses: actions/upload-artifact@v2
      with:
        name: STBDotNet
        path: STBDotNet/bin/Release/
  
  coverage:
    runs-on: windows-2022
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
    
      - name: Setup .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '6.0.x'
          include-prerelease: true
          
      - name: Setup MSBuild.exe
        uses: microsoft/setup-msbuild@v1.1
        with: 
          vs-prerelease: true

      - name: Setup NuGet
        uses: NuGet/setup-nuget@v1

      - name: Restore the application
        run: msbuild STBDotNet.sln /t:Restore /p:Configuration=Debug

      - name: Build the application
        run: msbuild STBDotNet.sln /p:Configuration=Debug
        
      - name: Run OpenCover
        shell: powershell
        run: |
          $opencover = (Resolve-Path "~\.nuget\packages\OpenCover\4.7.922\tools\OpenCover.Console.exe").ToString()
          regsvr32 x86\OpenCover.Profiler.dll
          regsvr32 x64\OpenCover.Profiler.dll
          & $opencover -target:"c:\Program Files\dotnet\dotnet.exe" `
          -targetargs:"test -f netcoreapp2.1 -c Debug STBDotNetTests/STBDotNetTests.csproj"`
          -mergeoutput `
          -hideskipped:File `
          -output:opencoverCoverage.xml `
          -oldStyle `
          -searchdirs:STBDotNetTests/bin/Debug/netcoreapp2.1 `
          -register:user
           
      - name: Upload coverage result
        shell: powershell
        run: |
          $env:Path = "C:\Python37;C:\Python37\Scripts;$env:Path"
          python -m pip install --upgrade pip
          pip install codecov
          &{codecov -f "opencoverCoverage.xml"}