Skip to content

Update dotnet.yml

Update dotnet.yml #106

Workflow file for this run

# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Build and Run Tests
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
AUDIT_NET_AZUREDOCDBAUTHKEY: ${{ secrets.AUDIT_NET_AZUREDOCDBAUTHKEY }}
AUDIT_NET_AZUREDOCDBURL: ${{ secrets.AUDIT_NET_AZUREDOCDBURL }}
AUDIT_NET_AZURETABLECNNSTRING: ${{ secrets.AUDIT_NET_AZURETABLECNNSTRING }}
AUDIT_NET_AZUREBLOBSERVICEURL: ${{ secrets.AUDIT_NET_AZUREBLOBSERVICEURL }}
AUDIT_NET_AZUREBLOBACCOUNTNAME: ${{ secrets.AUDIT_NET_AZUREBLOBACCOUNTNAME }}
AUDIT_NET_AZUREBLOBACCOUNTKEY: ${{ secrets.AUDIT_NET_AZUREBLOBACCOUNTKEY }}
jobs:
build_and_test:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
2.1.x
3.1.x
6.0.x
7.0.x
8.0.x
- name: Setup NuGet
uses: NuGet/[email protected]
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
with:
nuget-version: '6.x'
- name: Install SQL Server
uses: Particular/[email protected]
with:
connection-string-env-var: SQL_SERVER_CONNECTION_STRING
catalog: Audit
extra-params: "Encrypt=False;"
- name: Extra SQL
shell: pwsh
run: |
echo "Execute SqlScript.sql"
sqlcmd -i ".\src\Audit.NET.SqlServer\SqlScript.sql" -d "master" -I
echo "Execute Demo.sql"
sqlcmd -i ".\test\Audit.EntityFramework.Core.UnitTest\Demo.sql" -d "master" -I
- name: Dotnet Restore
run: dotnet restore
- name: Dotnet Build Audit.NET.sln
run: dotnet build .\Audit.NET.sln --no-restore --configuration release
- name: Install Required Tools
run: |
dotnet new tool-manifest
dotnet tool install dotnet-reportgenerator-globaltool
dotnet tool install dotnet-coverage
- name: Run unit tests (no integration)
run: |
dotnet coverage collect dotnet test -m:1 --filter=TestCategory!=Integration --output ${{ github.workspace }}/Tests/Coverage.UnitTest.cobertura.xml --output-format cobertura
- name: Run integration tests (SqlServer)
run: |
dotnet coverage collect dotnet test -m:1 --filter=TestCategory=SqlServer --output ${{ github.workspace }}/Tests/Coverage.SqlServer.cobertura.xml --output-format cobertura
- name: Generate Code Coverage Report
run: |
dotnet reportgenerator -reports:${{ github.workspace }}/Tests/Coverage.*.cobertura.xml -targetdir:"${{ github.workspace }}/Tests/coveragereport" -reporttypes:"MarkdownSummary;Html" "-assemblyfilters:-*UnitTest;-*Integration;+Audit.*"
- name: Upload Code Coverage Report
uses: actions/upload-artifact@v2
with:
name: coveragereport
path: ${{ github.workspace }}/Tests/coveragereport