mirror of
https://github.com/ivuorinen/hiha-arvio.git
synced 2026-03-11 18:00:09 +00:00
76 lines
2.6 KiB
YAML
76 lines
2.6 KiB
YAML
name: Test
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
|
|
jobs:
|
|
test:
|
|
name: Run Tests
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
checks: write
|
|
actions: write
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
|
|
with:
|
|
dotnet-version: '9.0.x'
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore tests/HihaArvio.Tests/HihaArvio.Tests.csproj /p:TargetFrameworks=net9.0
|
|
|
|
- name: Build test project
|
|
run: dotnet build tests/HihaArvio.Tests/HihaArvio.Tests.csproj --configuration Release --no-restore /p:TargetFrameworks=net9.0
|
|
|
|
- name: Run tests with coverage
|
|
run: dotnet test tests/HihaArvio.Tests/HihaArvio.Tests.csproj --configuration Release --no-build --verbosity normal /p:TargetFrameworks=net9.0 --collect:"XPlat Code Coverage" --logger "trx;LogFileName=test-results.trx"
|
|
|
|
- name: Install ReportGenerator
|
|
run: dotnet tool install --global dotnet-reportgenerator-globaltool
|
|
|
|
- name: Generate coverage report
|
|
run: reportgenerator -reports:**/coverage.cobertura.xml -targetdir:coverage -reporttypes:"Html;Cobertura;TextSummary"
|
|
|
|
- name: Display coverage summary
|
|
run: |
|
|
# Extract and display line coverage percentage
|
|
COVERAGE=$(grep -oP 'Line coverage: \K[\d.]+' coverage/Summary.txt | head -1)
|
|
echo "📊 Code coverage for net9.0 target: ${COVERAGE}%"
|
|
echo ""
|
|
echo "Note: Multi-target MAUI projects cannot achieve full coverage on Linux runners."
|
|
echo "Platform-specific code (iOS/macOS) is excluded when building net9.0 only."
|
|
echo "Full coverage measurement requires macOS runners with all target frameworks."
|
|
|
|
- name: Upload coverage report
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
|
if: always()
|
|
with:
|
|
name: coverage-report
|
|
path: coverage/
|
|
retention-days: 30
|
|
|
|
- name: Publish test results
|
|
uses: dorny/test-reporter@3d76b34a4535afbd0600d347b09a6ee5deb3ed7f # v2.6.0
|
|
if: always()
|
|
with:
|
|
name: Test Results
|
|
path: '**/test-results.trx'
|
|
reporter: dotnet-trx
|
|
fail-on-error: true
|
|
|
|
- name: Upload test results
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
|
if: always()
|
|
with:
|
|
name: test-results
|
|
path: '**/test-results.trx'
|
|
retention-days: 30
|