From f4b71e3f11719fe1e690f62c693484fcee903c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20G=C3=B3rniak?= Date: Sun, 12 Apr 2026 23:42:14 +0200 Subject: [PATCH 1/2] Add native job summary for test results and code coverage --- .github/scripts/generate-test-summary.ps1 | 55 +++++++++++++++++++++++ .github/workflows/release-pipeline.yml | 6 +++ 2 files changed, 61 insertions(+) create mode 100644 .github/scripts/generate-test-summary.ps1 diff --git a/.github/scripts/generate-test-summary.ps1 b/.github/scripts/generate-test-summary.ps1 new file mode 100644 index 0000000..6dc07cd --- /dev/null +++ b/.github/scripts/generate-test-summary.ps1 @@ -0,0 +1,55 @@ +# A simple script that prints a summary of the tests + +param ( + [string]$WorkspacePath = $env:GITHUB_WORKSPACE, + [string]$SummaryPath = $env:GITHUB_STEP_SUMMARY +) + +# If the script is running locally (outside of GitHub Actions), print to the console +if ([string]::IsNullOrEmpty($SummaryPath)) { + $SummaryPath = ".\local-summary-test.md" + Write-Host "Uruchomienie lokalne. Wynik zostanie zapisany do $SummaryPath" +} + +# Retrieving data from a TRX file (test results) +$trxFile = Get-ChildItem -Path "$WorkspacePath/TestResults" -Filter *.trx -Recurse | Select-Object -First 1 +$total = 0; $passed = 0; $failed = 0 + +if ($trxFile) { + [xml]$trx = Get-Content $trxFile.FullName + $counters = $trx.GetElementsByTagName("Counters")[0] + if ($counters) { + $total = $counters.GetAttribute("total") + $passed = $counters.GetAttribute("passed") + $failed = $counters.GetAttribute("failed") + } +} + +# Retrieving data from a Cobertura file (code coverage) +$covFile = Get-ChildItem -Path "$WorkspacePath/TestResults" -Filter coverage.cobertura.xml -Recurse | Select-Object -First 1 +$coverageText = "Brak danych" + +if ($covFile) { + [xml]$cov = Get-Content $covFile.FullName + $lineRateStr = $cov.DocumentElement.GetAttribute("line-rate") + if (![string]::IsNullOrWhiteSpace($lineRateStr)) { + $lineRate = [double]::Parse($lineRateStr, [System.Globalization.CultureInfo]::InvariantCulture) + $percent = [math]::Round($lineRate * 100, 2) + $coverageText = "$percent %" + } +} + + +$markdown = @" +## 📊 Podsumowanie testów + +| Metryka | Wynik | +|---|---| +| **Pokrycie kodu** | **$coverageText** | +| **Wszystkie testy** | $total | +| Zaliczone ✅ | $passed | +| Nieudane ❌ | $failed | +"@ + +# Write to the file specified by the GitHub environment variable +$markdown | Out-File -FilePath $SummaryPath -Append -Encoding utf8 diff --git a/.github/workflows/release-pipeline.yml b/.github/workflows/release-pipeline.yml index 5aad07c..9f2bf0d 100644 --- a/.github/workflows/release-pipeline.yml +++ b/.github/workflows/release-pipeline.yml @@ -83,6 +83,12 @@ jobs: ${{ github.workspace }}/TestResults/*.trx ${{ github.workspace }}/TestResults/*.xml retention-days: 14 + + # Natywne generowanie podsumowania za pomocą skryptu + # Generating a summary natively using an script + - name: Generate github tests summary + if: always() + run: pwsh ./.github/scripts/generate-test-summary.ps1 # ---------------------------------------------------------------- # ETAP 2: Publikacja i weryfikacja (AOT & JIT) From b8e1dae6a8a0e32c6cd449e39e90ac371cd43195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20G=C3=B3rniak?= Date: Sun, 12 Apr 2026 23:46:09 +0200 Subject: [PATCH 2/2] Add trigger automatically CI/CD on push on dev branch --- .github/workflows/release-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-pipeline.yml b/.github/workflows/release-pipeline.yml index 9f2bf0d..022a9a0 100644 --- a/.github/workflows/release-pipeline.yml +++ b/.github/workflows/release-pipeline.yml @@ -4,7 +4,7 @@ on: # Uruchom automatycznie przy wrzuceniu kodu na gałąź main # Trigger automatically on push to the main branch push: - branches: [ "master" ] + branches: [ "master" , "dev"] paths-ignore: #- "**.md" - "**/Dockerfile"