diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index bb343a563eb..62adc08cde4 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -6,31 +6,43 @@ "version": "5.0.0", "commands": [ "dotnet-cake" - ] + ], + "rollForward": false }, "docfx": { "version": "2.78.2", "commands": [ "docfx" - ] + ], + "rollForward": false + }, + "dotnet-stryker": { + "version": "4.5.1", + "commands": [ + "dotnet-stryker" + ], + "rollForward": false }, "markdownsnippets.tool": { "version": "27.0.2", "commands": [ "mdsnippets" - ] + ], + "rollForward": false }, "MartinCostello.WaitForNuGetPackage": { "version": "1.1.0", "commands": [ "dotnet-wait-for-package" - ] + ], + "rollForward": false }, "sign": { "version": "0.9.1-beta.24529.1", "commands": [ "sign" - ] + ], + "rollForward": false } } } \ No newline at end of file diff --git a/.github/workflows/actions-lint.yml b/.github/workflows/actions-lint.yml index ddbe1fab250..faff71418b5 100644 --- a/.github/workflows/actions-lint.yml +++ b/.github/workflows/actions-lint.yml @@ -31,6 +31,9 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + filter: 'tree:0' + show-progress: false - name: Add actionlint problem matcher run: echo "::add-matcher::.github/actionlint-matcher.json" diff --git a/.github/workflows/after-release.yml b/.github/workflows/after-release.yml index 631de949b63..2d3fac42f69 100644 --- a/.github/workflows/after-release.yml +++ b/.github/workflows/after-release.yml @@ -35,6 +35,8 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: + filter: 'tree:0' + show-progress: false token: ${{ steps.generate-application-token.outputs.token }} - name: Update Polly version diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d6348027557..e301bfe9572 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,6 +56,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 + show-progress: false - name: Setup .NET SDKs uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # v4.3.0 @@ -252,9 +253,11 @@ jobs: - name: Checkout vcsjones/AuthenticodeLint uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: + filter: 'tree:0' path: AuthenticodeLint ref: 90dd05293effe918b149c7f8323540b7730c06d2 repository: martincostello/AuthenticodeLint + show-progress: false submodules: recursive - name: Setup .NET SDK diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 11021cc9ec7..6fba9012cb7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,6 +34,9 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + filter: 'tree:0' + show-progress: false - name: Initialize CodeQL uses: github/codeql-action/init@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9 diff --git a/.github/workflows/dependabot-approve.yml b/.github/workflows/dependabot-approve.yml index 14d867d5aa6..17ef440b723 100644 --- a/.github/workflows/dependabot-approve.yml +++ b/.github/workflows/dependabot-approve.yml @@ -26,6 +26,9 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + filter: 'tree:0' + show-progress: false - name: Approve pull request and enable auto-merge shell: bash diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index bc0e62ffc08..72082648c50 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -2,7 +2,7 @@ name: dependency-review on: pull_request: - branches: + branches: - main - release/* - dotnet-vnext @@ -19,6 +19,9 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + filter: 'tree:0' + show-progress: false - name: Review dependencies uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0 diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 00a615ecc7d..01a476c954d 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -25,6 +25,9 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + filter: 'tree:0' + show-progress: false - name: Lint Markdown files uses: DavidAnson/markdownlint-cli2-action@05f32210e84442804257b2a6f20b273450ec8265 # v19.1.0 diff --git a/.github/workflows/mutation-tests.yml b/.github/workflows/mutation-tests.yml index 34363d21ae2..92eb8a7ece9 100644 --- a/.github/workflows/mutation-tests.yml +++ b/.github/workflows/mutation-tests.yml @@ -46,6 +46,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 + show-progress: false - name: Setup .NET SDKs uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # v4.3.0 @@ -57,11 +58,15 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # v4.3.0 + - name: Restore .NET tools + run: dotnet tool restore + - name: Run mutation tests for ${{ matrix.target }} shell: pwsh env: MUTATION_TARGET: 'MutationTests${{ matrix.target }}' SKIP_POLLY_ANALYZERS: 'true' + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} run: ./build.ps1 -Target ${env:MUTATION_TARGET} - name: Upload Mutation Report @@ -77,12 +82,18 @@ jobs: runs-on: ubuntu-latest env: MUTATIONS_SUCCESS: ${{ !contains(needs.*.result, 'failure') }} + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} steps: - run: | + if [ -z "${STRYKER_DASHBOARD_API_KEY}" ] + then + DASHBOARD_URL="https://dashboard.stryker-mutator.io/reports/github.com/${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}" + printf "# Mutations Dashboard\n\n[View report :notebook:](%s)\n" "${DASHBOARD_URL}" >> "${GITHUB_STEP_SUMMARY}" + fi if [ "$MUTATIONS_SUCCESS" == "true" ] then - echo 'Mutation tests successful ✅' + echo "Mutation tests successful ✅" else - echo 'One or more mutation test runs failed ❌' + echo "::error title=Mutation Tests::One or more mutation test runs failed ❌" exit 1 fi diff --git a/.github/workflows/nuget-packages-published.yml b/.github/workflows/nuget-packages-published.yml index ac0424b6416..858cbef9faa 100644 --- a/.github/workflows/nuget-packages-published.yml +++ b/.github/workflows/nuget-packages-published.yml @@ -40,6 +40,9 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + filter: 'tree:0' + show-progress: false - name: Setup .NET SDK uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # v4.3.0 diff --git a/.github/workflows/on-push-do-docs.yml b/.github/workflows/on-push-do-docs.yml index 5763acf767b..9948cc88346 100644 --- a/.github/workflows/on-push-do-docs.yml +++ b/.github/workflows/on-push-do-docs.yml @@ -27,6 +27,8 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: + filter: 'tree:0' + show-progress: false token: ${{ steps.generate-application-token.outputs.token }} - name: Setup .NET SDK @@ -37,14 +39,14 @@ jobs: shell: pwsh env: DOTNET_CLI_TELEMETRY_OPTOUT: true - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true run: | $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" - + dotnet tool restore dotnet mdsnippets - + $GitStatus = (git status --porcelain) if ([string]::IsNullOrEmpty($GitStatus)) { Write-Host "No changes to commit." @@ -57,18 +59,18 @@ jobs: $GitEmail = "138034000+polly-updater-bot[bot]@users.noreply.github.com" $GitUser = "polly-updater-bot[bot]" - + git config user.email $GitEmail | Out-Null git config user.name $GitUser | Out-Null git remote set-url "${{ github.server_url }}/${{ github.repository }}.git" | Out-Null git fetch origin | Out-Null git rev-parse --verify --quiet ("remotes/origin/" + $BranchName) | Out-Null - + if ($LASTEXITCODE -eq 0) { Write-Host "Branch $BranchName already exists." exit 0 } - + git checkout -b $BranchName git add . git commit -m "Update the code-snippets in the documentation" diff --git a/.github/workflows/ossf-scorecard.yml b/.github/workflows/ossf-scorecard.yml index f09338c27a1..d5e9861801a 100644 --- a/.github/workflows/ossf-scorecard.yml +++ b/.github/workflows/ossf-scorecard.yml @@ -23,7 +23,9 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: + filter: 'tree:0' persist-credentials: false + show-progress: false - name: Run analysis uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5acb9da22b3..b17936898fb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,6 +26,9 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + filter: 'tree:0' + show-progress: false - name: Create release uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 diff --git a/.github/workflows/updater-approve.yml b/.github/workflows/updater-approve.yml index 0d4aa5bdb8b..f4dcc808884 100644 --- a/.github/workflows/updater-approve.yml +++ b/.github/workflows/updater-approve.yml @@ -2,7 +2,7 @@ name: updater-approve on: pull_request: - branches: + branches: - main - release/* - dotnet-vnext @@ -99,6 +99,9 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + filter: 'tree:0' + show-progress: false - name: Approve pull request and enable auto-merge if: steps.check-dependencies.outputs.is-trusted-update == 'true' diff --git a/README.md b/README.md index 0dd3f78f337..05540873d68 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ We are a member of the [.NET Foundation](https://www.dotnetfoundation.org/about) **Keep up to date with new feature announcements, tips & tricks, and other news through [www.thepollyproject.org](https://www.thepollyproject.org)** -[![Build status](https://github.com/App-vNext/Polly/actions/workflows/build.yml/badge.svg?branch=main&event=push)](https://github.com/App-vNext/Polly/actions/workflows/build.yml?query=branch%3Amain+event%3Apush) [![Code coverage](https://codecov.io/gh/App-vNext/Polly/branch/main/graph/badge.svg)](https://codecov.io/gh/App-vNext/Polly) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/App-vNext/Polly/badge)](https://securityscorecards.dev/viewer/?uri=github.com/App-vNext/Polly) +[![Build status](https://github.com/App-vNext/Polly/actions/workflows/build.yml/badge.svg?branch=main&event=push)](https://github.com/App-vNext/Polly/actions/workflows/build.yml?query=branch%3Amain+event%3Apush) [![Code coverage](https://codecov.io/gh/App-vNext/Polly/branch/main/graph/badge.svg)](https://codecov.io/gh/App-vNext/Polly) [![Mutation score](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.amrom.workers.dev%2FApp-vNext%2FPolly%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/App-vNext/Polly/main) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/App-vNext/Polly/badge)](https://securityscorecards.dev/viewer/?uri=github.com/App-vNext/Polly) [![Polly logo](https://raw.github.com/App-vNext/Polly/main/Polly-Logo.png)](#) diff --git a/build.cake b/build.cake index 1adc3cf4b6d..9bfbbd3c4a8 100644 --- a/build.cake +++ b/build.cake @@ -5,13 +5,6 @@ var target = Argument("target", "Default"); var configuration = Argument("configuration", "Release"); -////////////////////////////////////////////////////////////////////// -// EXTERNAL NUGET TOOLS -////////////////////////////////////////////////////////////////////// - -#Tool "xunit.runner.console&version=2.9.3" -#Tool "dotnet-stryker&version=4.5.1" - ////////////////////////////////////////////////////////////////////// // EXTERNAL NUGET LIBRARIES ////////////////////////////////////////////////////////////////////// @@ -65,6 +58,12 @@ Teardown(_ => Task("__Clean") .Does(() => { + if (Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true") + { + // Nothing to clean in CI + return; + } + CleanDirectories( [ testResultsDir, @@ -289,18 +288,66 @@ string ToolsExePath(string exeFileName) { void RunMutationTests(FilePath target, FilePath testProject) { - var strykerPath = Context.Tools.Resolve("Stryker.CLI.dll"); var mutationScore = XmlPeek(target, "/Project/PropertyGroup/MutationScore/text()", new XmlPeekSettings { SuppressWarning = true }); var score = int.Parse(mutationScore); var targetFileName = target.GetFilename(); + var isGitHubActions = Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true"; + var dashboardUrl = string.Empty; + var moduleName = target.GetFilenameWithoutExtension().ToString(); + + if (isGitHubActions && + !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("STRYKER_DASHBOARD_API_KEY"))) + { + var projectName = $"github.com/{Environment.GetEnvironmentVariable("GITHUB_REPOSITORY")}"; + var version = Environment.GetEnvironmentVariable("GITHUB_REF_NAME"); + + dashboardUrl = $"https://dashboard.stryker-mutator.io/reports/{projectName}/{version}#mutant/{moduleName}"; + + var config = Newtonsoft.Json.Linq.JObject.Parse(System.IO.File.ReadAllText(strykerConfig.FullPath)); + + var reporters = config["stryker-config"].Value("reporters"); + reporters.Add("dashboard"); + + config["stryker-config"]["reporters"] = reporters; + config["stryker-config"]["project-info"] = new Newtonsoft.Json.Linq.JObject() + { + ["module"] = moduleName, + ["name"] = projectName, + ["version"] = version + }; + + System.IO.File.WriteAllText(strykerConfig.FullPath, config.ToString()); + + Information("Configured Stryker dashboard."); + Information($"Mutation report will be available at {dashboardUrl}"); + } Information($"Running mutation tests for '{targetFileName}'. Test Project: '{testProject}'"); - var args = $"{strykerPath} --project {targetFileName} --test-project {testProject.FullPath} --break-at {score} --config-file {strykerConfig} --output {strykerOutput}/{targetFileName}"; + var args = $"stryker --project {targetFileName} --test-project {testProject.FullPath} --break-at {score} --config-file {strykerConfig} --output {strykerOutput}/{targetFileName}"; var result = StartProcess("dotnet", args); if (result != 0) { throw new InvalidOperationException($"The mutation testing of '{targetFileName}' project failed."); } + + var stepSummary = Environment.GetEnvironmentVariable("GITHUB_STEP_SUMMARY"); + var markdownSummary = System.IO.Path.Combine( + strykerOutput.FullPath, + targetFileName.ToString(), + "reports", + "mutation-report.md"); + + if (!string.IsNullOrWhiteSpace(stepSummary) && System.IO.File.Exists(markdownSummary)) + { + var markdown = System.IO.File.ReadAllText(markdownSummary); + + if (!string.IsNullOrWhiteSpace(dashboardUrl)) + { + markdown += $"\n\n## Mutation Dashboard\n\n[View Mutation Report :notebook:]({dashboardUrl})"; + } + + System.IO.File.WriteAllText(stepSummary, markdown); + } } diff --git a/eng/stryker-config.json b/eng/stryker-config.json index fe485b07db4..053f7904ae7 100644 --- a/eng/stryker-config.json +++ b/eng/stryker-config.json @@ -1,6 +1,7 @@ { "stryker-config": { "reporters": [ + "dots", "json", "html", "markdown"