Skip to content

Windows' distribution of OpenSSH also changed its logging format (tes… #51

Windows' distribution of OpenSSH also changed its logging format (tes…

Windows' distribution of OpenSSH also changed its logging format (tes… #51

name: Build
on:
workflow_dispatch:
push:
branches: [ master ]
env:
PROJECT_NAME: Fail2Ban4Win
jobs:
build:
runs-on: windows-latest
steps:
- name: Set up MSBuild
uses: microsoft/setup-msbuild@v2
- name: Clone
uses: actions/checkout@v4
- name: Initialize test reporting
uses: testspace-com/setup-testspace@v1
with:
domain: ${{github.repository_owner}}
- name: Restore
run: msbuild -t:restore -p:RestoreLockedMode=true
- name: Build
run: msbuild ${{ env.PROJECT_NAME }} -p:Configuration=Release -t:build -m
# build again in Debug mode just for tests because Release tests would have duplicate dependencies as ILRepacked release code under test, causing error CS0433: The type 'LogLevel' exists in both 'Fail2Ban4Win, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' and 'NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c' [D:\a\Fail2Ban4Win\Fail2Ban4Win\Tests\Tests.csproj]
- name: Test
run: |
msbuild -p:Configuration=Debug -t:build -m
dotnet test --no-build --verbosity normal --configuration Debug --collect:"XPlat Code Coverage" --settings Tests\Tests.runsettings --logger "trx;LogFileName=TestResults.xml"
Out-File -InputObject "TEST_EXIT_CODE=$LASTEXITCODE" -FilePath $env:GITHUB_ENV -Append -Encoding UTF8
Copy-Item Tests/TestResults/*/coverage.info Tests/TestResults -ErrorAction Continue
exit 0
- name: Upload test report
run: testspace Tests/TestResults/TestResults.xml
- name: Upload coverage
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: Tests/TestResults/coverage.info
format: lcov
- name: Stop if tests failed
run: exit $env:TEST_EXIT_CODE
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}
path: |
${{ env.PROJECT_NAME }}\bin\Release\${{ env.PROJECT_NAME }}.exe*
${{ env.PROJECT_NAME }}\bin\Release\Install service.ps1
${{ env.PROJECT_NAME }}\bin\Release\configuration.json
if-no-files-found: error