Feature/test reports

This commit is contained in:
2025-07-06 13:57:38 +02:00
parent e6726037b6
commit 31b0b3970a
2 changed files with 122 additions and 133 deletions

View File

@@ -8,6 +8,8 @@ stages:
build:
stage: build
only:
- pushes
script:
- dotnet restore
- dotnet build --configuration Release --no-restore
@@ -18,10 +20,31 @@ build:
test:
stage: test
only:
- pushes
script:
- dotnet test --verbosity normal
dependencies:
- build
- dotnet test HopFrame.sln --logger "trx;LogFilePrefix=testresults" --collect:"XPlat Code Coverage" --results-directory TestResults
- dotnet tool install --global trx2junit
- dotnet tool install --global dotnet-reportgenerator-globaltool
- export PATH="$PATH:/root/.dotnet/tools"
- for file in TestResults/*.trx; do trx2junit "$file"; done
- reportgenerator -reports:"TestResults/**/coverage.cobertura.xml" -targetdir:"coveragereport" -reporttypes:"Cobertura;HtmlInline"
- echo total_coverage=$(grep -o 'line-rate="[0-9.]*"' coveragereport/Cobertura.xml | head -n1 | sed -E 's/line-rate="([0-9.]+)"/\1/' | awk '{printf "%.2f", $1 * 100}')
- tar -cvf coveragereport.tar coveragereport/
artifacts:
when: always
expire_in: 1 week
paths:
- TestResults/*.xml
- TestResults/**/*.coverage.cobertura.xml
- coveragereport.tar
reports:
junit:
- TestResults/*.xml
coverage_report:
coverage_format: cobertura
path: coveragereport/Cobertura.xml
coverage: '/total_coverage=(\d+(\.\d+)?)/'
publish:
stage: publish