diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index d9333b7..e59248a 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -31,9 +31,51 @@ jobs: 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 + + - 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' @@ -45,7 +87,7 @@ jobs: reportgenerator -reports:test-result.cobertura.xml -targetdir:coverage-report -reporttypes:"Html;JsonSummary;MarkdownSummaryGithub;Badges" cat coverage-report/SummaryGithub.md >> $GITHUB_STEP_SUMMARY - - name: ReportGenerator + - name: ReportGenerator_CoverageReport if: matrix.platform.name == 'MacOS' uses: danielpalme/ReportGenerator-GitHub-Action@5.3.11 with: @@ -84,6 +126,8 @@ jobs: run: | echo "![Coverage](./coverage-report/badge_combined.svg)" > coverage-badge.md cat coverage-badge.md >> README.md + + publish_badge: runs-on: ubuntu-24.04 diff --git a/.gitignore b/.gitignore index 442c1e5..8f9a7e0 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,7 @@ /codeql* /*.dot /*snyk* + +# Mac OS +.DS_Store +.AppleDouble \ No newline at end of file