Skip to content

Commit

Permalink
adjsut workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Drazzz committed Jul 29, 2024
1 parent 9c96d29 commit a0705fd
Showing 1 changed file with 68 additions and 11 deletions.
79 changes: 68 additions & 11 deletions .github/workflows/build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
steps:
- name: 👨‍💻 Check-out code
uses: actions/checkout@v4

with:
fetch-depth: 0

- name: Install azd
uses: Azure/setup-azd@v1.0.0

Expand All @@ -38,16 +40,71 @@ jobs:

- name: 🛠️ Build code
run: dotnet build --configuration Release --no-restore --warnaserror

- name: 🫣 Testing code
run: |
echo "## ❔ Test results" >> $GITHUB_STEP_SUMMARY
dotnet test --configuration Release -v minimal --no-build --logger GitHubActions '/p:CollectCoverage=true;CoverletOutputFormat="json,lcov,cobertura";MergeWith=${{github.workspace}}/coverage.json;CoverletOutput=${{github.workspace}}/coverage' src/Aspire.Playground.AppHost.UnitTests -- RunConfiguration.CollectSourceInformation=true
run: dotnet test --configuration Release --verbosity normal --logger trx --collect:"XPlat Code Coverage"
- name: 📝 Code Coverage report
run: |
dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.1.23
reportgenerator -reports:${{github.workspace}}/coverage/coverage.cobertura.xml -targetdir:${{github.workspace}}/report -reporttypes:MarkdownSummaryGithub "-filefilters:-*.g.cs;-*.gen.cs" -verbosity:Warning
sed -i 's/# Summary/## 📝 Code Coverage/g' ${{github.workspace}}/report/SummaryGithub.md
sed -i 's/## Coverage/### Code Coverage details/g' ${{github.workspace}}/report/SummaryGithub.md
cat ${{github.workspace}}/report/*.md >> $GITHUB_STEP_SUMMARY
- name: 📝 Combine Coverage Reports # This is because one report is produced per project, and we want one result for all of them.
uses: danielpalme/ReportGenerator-GitHub-Action@5.3.8
with:
reports: "**/*.cobertura.xml" # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
targetdir: "${{ github.workspace }}" # REQUIRED # The directory where the generated report should be saved.
reporttypes: "Cobertura" # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, Html_Dark, Html_Light, Html_BlueRed, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlInline_AzurePipelines_Light, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MarkdownSummaryGithub, MarkdownDeltaSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, TextDeltaSummary, Xml, XmlSummary
verbosity: "Info" # The verbosity level of the log messages. Values: Verbose, Info, Warning, Error, Off
title: "Code Coverage" # Optional title.
tag: "${{ github.run_number }}_${{ github.run_id }}" # Optional tag or build version.
customSettings: "" # Optional custom settings (separated by semicolon). See: https://github.com/danielpalme/ReportGenerator/wiki/Settings.
toolpath: "reportgeneratortool" # Default directory for installing the dotnet tool.
- name: Upload Combined Coverage XML
uses: actions/upload-artifact@v4
with:
name: coverage
path: ${{ github.workspace }}/Cobertura.xml
retention-days: 5
- name: Publish Code Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: "Cobertura.xml"
badge: true
fail_below_min: false # just informative for now
format: markdown
hide_branch_rate: false
hide_complexity: false
indicators: true
output: both
thresholds: "10 30"

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md

- name: Upload Test Result Files
uses: actions/upload-artifact@v4
with:
name: test-results
path: ${{ github.workspace }}/**/TestResults/**/*
retention-days: 5

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2.16.1
if: always()
with:
# NOTE: using trx_files instead of files due to https://github.com/EnricoMi/publish-unit-test-result-action/issues/424
trx_files: "${{ github.workspace }}/**/*.trx"

# - name: 🫣 Testing code
# run: |
# echo "## ❔ Test results" >> $GITHUB_STEP_SUMMARY
# dotnet test --configuration Release -v minimal --no-build --logger GitHubActions '/p:CollectCoverage=true;CoverletOutputFormat="json,lcov,cobertura";MergeWith=${{github.workspace}}/coverage.json;CoverletOutput=${{github.workspace}}/coverage' src/Aspire.Playground.AppHost.UnitTests -- RunConfiguration.CollectSourceInformation=true
#
# - name: 📝 Code Coverage report
# run: |
# dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.1.23
# reportgenerator -reports:${{github.workspace}}/coverage.cobertura.xml -targetdir:${{github.workspace}}/report -reporttypes:MarkdownSummaryGithub "-filefilters:-*.g.cs;-*.gen.cs" -verbosity:Warning
# sed -i 's/# Summary/## 📝 Code Coverage/g' ${{github.workspace}}/report/SummaryGithub.md
# sed -i 's/## Coverage/### Code Coverage details/g' ${{github.workspace}}/report/SummaryGithub.md
# cat ${{github.workspace}}/report/*.md >> $GITHUB_STEP_SUMMARY

0 comments on commit a0705fd

Please sign in to comment.