Skip to content

feat: update coverlet packages to version 6.0.3 in project files #208

feat: update coverlet packages to version 6.0.3 in project files

feat: update coverlet packages to version 6.0.3 in project files #208

Workflow file for this run

# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET
on: [push, pull_request]
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
jobs:
build:
name: ${{ matrix.platform.name }} ${{ matrix.dotnet.name }}
runs-on: ${{ matrix.platform.os }}
#runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- { name: Linux, os: ubuntu-24.04 }
- { name: Windows, os: windows-2022 }
- { name: macOS, os: macos-15 }
dotnet:
- { name: .NET 9, version: "9.0.x" }
steps:
- uses: actions/checkout@v4
- id: setup-dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet.version }}
- name: Setup Java
if: matrix.platform.name == 'MacOS'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
- name: Cache SonarCloud packages
if: matrix.platform.name == 'MacOS'
uses: actions/cache@v4
with:
path: ~/sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
if: matrix.platform.name == 'MacOS'
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: ./.sonar/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' && matrix.platform.name == 'MacOS'
shell: pwsh
run: |
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
- name: Enforce SDK Version
run: dotnet new globaljson --sdk-version ${{ steps.setup-dotnet.outputs.dotnet-version }} --force
- name: build and analyze
if: matrix.platform.name == 'MacOS'
run: |
dotnet restore
dotnet tool update --global dotnet-coverage
./.sonar/scanner/dotnet-sonarscanner begin /k:"magic5644_codeLineCounter" /o:"magic5644" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.scanner.scanAll=false
dotnet build --no-incremental
dotnet-coverage collect 'dotnet test --no-build' -f xml -o 'coverage.xml'
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: Build Release
run: dotnet build -c Release
- name: Test
if: matrix.platform.name == 'MacOS'
run: |
dotnet test --results-directory "test-results" --collect:"Code Coverage"
dotnet tool update --global dotnet-coverage
dotnet-coverage merge --output test-result.cobertura.xml --output-format cobertura "test-results/**/*.coverage"
dotnet tool install --global dotnet-reportgenerator-globaltool
reportgenerator -reports:test-result.cobertura.xml -targetdir:coverage-report -reporttypes:"Html;JsonSummary;MarkdownSummaryGithub;Badges"
cat coverage-report/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
- name: ReportGenerator_CoverageReport
if: matrix.platform.name == 'MacOS'
uses: danielpalme/ReportGenerator-GitHub-Action@5.3.11
with:
reports: "test-result.cobertura.xml"
targetdir: "coverage-report"
reporttypes: "Html;JsonSummary;MarkdownSummaryGithub;Badges"
- name: Upload coverage report artifact
uses: actions/upload-artifact@v4
if: matrix.platform.name == 'MacOS'
with:
name: coverage-report
path: coverage-report
- name: Upload coverage badge artifact
uses: actions/upload-artifact@v4
if: matrix.platform.name == 'MacOS'
with:
name: coverage-badge.svg
path: coverage-report/badge_combined.svg
- name: Add comment to PR
if: github.event_name == 'pull_request' && matrix.platform.name == 'MacOS'
run: gh pr comment $PR_NUMBER --body-file coverage-report/SummaryGithub.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
- name: Publish coverage in build summary # Only applicable if 'MarkdownSummaryGithub' or one of the other Markdown report types is generated
if: matrix.platform.name == 'MacOS'
run: cat coverage-report/SummaryGithub.md >> $GITHUB_STEP_SUMMARY # Adjust path and filename if necessary
shell: bash
- name: Generate Coverage Badge
if: matrix.platform.name == 'MacOS'
run: |
echo "![Coverage](./coverage-report/badge_combined.svg)" > coverage-badge.md
cat coverage-badge.md >> README.md
publish_badge:
runs-on: ubuntu-24.04
needs: build
steps:
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
repository: "magic5644/magic5644"
ref: gh-pages
- name: download badge
uses: actions/download-artifact@v4
with:
name: coverage-badge.svg
path: coverage-report/badge_combined.svg
- name: Deploy Badges
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update badges [skip ci]"
branch: gh-pages
skip_fetch: true
skip_checkout: true
file_pattern: "*.svg"