Skip to content

Added new unit tests #13

Added new unit tests

Added new unit tests #13

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, develop, developv2 ]
pull_request:
branches: [ main, develop, developv2 ]
env:
DOTNET_VERSION: '8.0.x'
jobs:
build-and-test:
name: Build, Test & Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for better analysis
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: |
dotnet restore src/FileWatcher.csproj
dotnet restore tests/FileWatcher.Tests.csproj
- name: Build
run: |
dotnet build src/FileWatcher.csproj --no-restore --configuration Release
dotnet build tests/FileWatcher.Tests.csproj --no-restore --configuration Release
- name: Run Tests with Coverage
run: dotnet test tests/FileWatcher.Tests.csproj --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage --logger "trx;LogFileName=test-results.trx"
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: '**/test-results.trx'
retention-days: 30
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: coverage/**/coverage.cobertura.xml
retention-days: 30
- name: Code Coverage Summary
if: always()
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage/**/coverage.cobertura.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '22 30'
- name: Add Coverage PR Comment
if: github.event_name == 'pull_request' && always()
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
path: code-coverage-results.md
- name: Test Report
if: always()
uses: dorny/test-reporter@v1
with:
name: Test Results
path: '**/test-results.trx'
reporter: dotnet-trx
fail-on-error: true
analyze:
name: Code Quality Analysis
runs-on: ubuntu-latest
needs: build-and-test
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/developv2')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: |
dotnet restore src/FileWatcher.csproj
dotnet restore tests/FileWatcher.Tests.csproj
- name: Build
run: |
dotnet build src/FileWatcher.csproj --no-restore --configuration Release
dotnet build tests/FileWatcher.Tests.csproj --no-restore --configuration Release
- name: Run Code Analysis
run: dotnet format src/FileWatcher.csproj --verify-no-changes --verbosity diagnostic
continue-on-error: true