diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index 8de3437fd..fcd19110d 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -128,7 +128,7 @@ jobs: shell: bash - name: Set Xcode version - if: runner.os == 'macOS' + if: ${{ runner.os == 'macOS' }} run: | echo Installed Xcode Versions: ls -al /Applications | grep Xcode @@ -203,14 +203,21 @@ jobs: cd ${{ env.PathToCommunityToolkitUnitTestCsproj }} dotnet run -c Release --results-directory "${{ runner.temp }}" --coverage --coverage-output "${{ runner.temp }}/ut.cobertura.xml" --coverage-output-format cobertura --report-xunit - - name: Publish Test Results - if: runner.os == 'Windows' && (${{ success() || failure() }}) - uses: actions/upload-artifact@v4 - with: - name: Test Results ${{ github.run_number }} ${{ runner.os }} - path: | - ${{ runner.temp }}/*.xunit - ${{ runner.temp }}/*cobertura.xml + - name: Create code coverage report + if: ${{ runner.os == 'Windows' && (success() || failure()) }} + run: | + dotnet tool install -g dotnet-reportgenerator-globaltool + reportgenerator -reports:'${{ runner.temp }}\*cobertura.xml' -targetdir:CodeCoverage -reporttypes:'MarkdownSummaryGithub' + cat CodeCoverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: Leave a code coverage report comment in PR + if: ${{ runner.os == 'Windows' && (success() || failure()) && github.event_name == 'pull_request' }} + run: gh pr comment ${{ github.event.number }} --body-file CodeCoverage/SummaryGithub.md + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.number }} + shell: bash - name: Pack CommunityToolkit.Maui.Core NuGet run: dotnet pack -c Release ${{ env.PathToCommunityToolkitCoreCsproj }} -p:PackageVersion=${{ env.NugetPackageVersion }} @@ -228,7 +235,7 @@ jobs: run: dotnet pack -c Release ${{ env.PathToCommunityToolkitMapsCsproj }} -p:PackageVersion=${{ env.NugetPackageVersionMaps }} - name: Copy NuGet Packages to Staging Directory - if: runner.os == 'Windows' && !startsWith(github.ref, 'refs/tags/') + if: ${{ runner.os == 'Windows' }} && !startsWith(github.ref, 'refs/tags/') run: | mkdir -p ${{ github.workspace }}/nuget Get-ChildItem -Path "./src" -Recurse | Where-Object { $_.Extension -match "nupkg" } | Copy-Item -Destination "${{ github.workspace }}/nuget" @@ -236,7 +243,7 @@ jobs: - name: Upload Package List uses: actions/upload-artifact@v4 - if: runner.os == 'Windows' + if: ${{ runner.os == 'Windows' }} with: name: nuget-list if-no-files-found: error @@ -244,7 +251,7 @@ jobs: ${{ github.workspace }}/.github/workflows/SignClientFileList.txt - name: Publish Packages - if: runner.os == 'Windows' + if: ${{ runner.os == 'Windows' }} uses: actions/upload-artifact@v4 with: name: packages