Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 2 additions & 86 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,19 @@ jobs:
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:
Expand All @@ -57,7 +54,7 @@ jobs:
restore-keys: ${{ runner.os }}-sonar-scanner

- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' && matrix.platform.name == 'MacOS'
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: pwsh
run: |
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
Expand All @@ -66,7 +63,6 @@ jobs:
run: dotnet new globaljson --sdk-version ${{ steps.setup-dotnet.outputs.dotnet-version }} --force

- name: build and analyze
if: matrix.platform.name == 'MacOS'
shell: pwsh
run: |
dotnet tool install --global dotnet-coverage
Expand All @@ -75,84 +71,4 @@ jobs:
dotnet build --no-incremental
dotnet-coverage collect 'dotnet test --no-build --results-directory "test-results" --collect:"Code Coverage"' -f xml -o 'coverage.xml'
dotnet-coverage merge --output coverage.xml --output-format xml "test-results/**/*.coverage"
./.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"
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# CodeLineCounter

[![.NET](https://github.com/magic5644/CodeLineCounter/actions/workflows/dotnet.yml/badge.svg)](https://github.com/magic5644/CodeLineCounter/actions/workflows/dotnet.yml)
[![Coverage](https://magic5644.github.io/magic5644/coverage-report/badge_combined.svg/badge_combined.svg)]([./coverage-report/index.html](https://github.com/magic5644/CodeLineCounter/actions/workflows/dotnet.yml))
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=magic5644_codeLineCounter&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=magic5644_codeLineCounter)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=magic5644_codeLineCounter&metric=coverage)](https://sonarcloud.io/summary/new_code?id=magic5644_codeLineCounter)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=magic5644_codeLineCounter&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=magic5644_codeLineCounter)

<div align="center"><img src="./assets/codelinecounter-logo.svg" alt="CodeLineCounter logo" width="200" height="200" center="true"></div>

Expand Down
Loading