From 10f5141e4831e43a268368e310be3a27efef8582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 30 Mar 2024 08:27:35 +0100 Subject: [PATCH 1/3] Merge `ci-stryker.yml` and `ci.yml` into one pipeline to reduce the required maintenance effort. --- .github/workflows/ci-stryker.yml | 90 -------------------------------- .github/workflows/ci.yml | 82 +++++++++++++++++++++++++++++ Testably.Abstractions.sln | 1 - 3 files changed, 82 insertions(+), 91 deletions(-) delete mode 100644 .github/workflows/ci-stryker.yml diff --git a/.github/workflows/ci-stryker.yml b/.github/workflows/ci-stryker.yml deleted file mode 100644 index c9b91af02..000000000 --- a/.github/workflows/ci-stryker.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: "CI (Stryker)" - -on: - workflow_dispatch: - pull_request: - branches: [main] - -jobs: - stryker: - name: Mutation testing - runs-on: ubuntu-latest - timeout-minutes: 300 - steps: - - name: Checkout sources - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 7.0.x - 8.0.x - - name: Install .NET Stryker - shell: bash - run: | - dotnet tool install dotnet-stryker --tool-path ../tools - - name: Prepare Reports directory - shell: bash - run: | - mkdir Tests/StrykerOutput/Reports -p - - name: Analyze Testably.Abstractions - env: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - shell: bash - run: | - cd Tests - ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main - mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions-report.html - - name: Analyze Testably.Abstractions.AccessControl - env: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - shell: bash - run: | - cd Tests - ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.AccessControl.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main - mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions.AccessControl-report.html - - name: Analyze Testably.Abstractions.Compression - env: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - shell: bash - run: | - cd Tests - ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Compression.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main - mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions.Compression-report.html - - name: Analyze Testably.Abstractions.Testing - env: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - shell: bash - run: | - cd Tests - ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Testing.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main - mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions.Testing-report.html - - name: Upload Stryker reports - uses: actions/upload-artifact@v3 - with: - name: Stryker - path: Tests/StrykerOutput/Reports/* - - name: Add comment to pull request - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - shell: bash - run: | - prNumber="${{ github.event.number }}" - commentsUrl="https://api.github.com/repos/Testably/Testably.Abstractions/issues/$prNumber/comments" - dashboardLink="[Stryker.NET](https://stryker-mutator.io/docs/stryker-net/introduction/) was executed on the changes in the pull request: \n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FTestably%2FTestably.Abstractions%2F${GITHUB_HEAD_REF})](https://dashboard.stryker-mutator.io/reports/github.com/Testably/Testably.Abstractions/${GITHUB_HEAD_REF})" - echo "Search for comment in PR#$prNumber containing $dashboardLink..." - result=$(curl -X GET $commentsUrl \ - -H "Content-Type: application/json" \ - -H "Authorization: token $GITHUB_TOKEN") - if [[ $result != *"$dashboardLink"* ]] - then - body="{\"body\":\"$dashboardLink\"}" - curl -X POST $commentsUrl \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: token $GITHUB_TOKEN" \ - -d "$body" - fi - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c4ef1fd3..7cdb67686 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -176,3 +176,85 @@ jobs: with: command: dotnet test Examples --no-build attempt_limit: 2 + + stryker: + name: Mutation testing + runs-on: ubuntu-latest + timeout-minutes: 300 + steps: + - name: Checkout sources + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + with: + fetch-depth: 0 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 6.0.x + 7.0.x + 8.0.x + - name: Install .NET Stryker + shell: bash + run: | + dotnet tool install dotnet-stryker --tool-path ../tools + - name: Prepare Reports directory + shell: bash + run: | + mkdir Tests/StrykerOutput/Reports -p + - name: Analyze Testably.Abstractions + env: + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + shell: bash + run: | + cd Tests + ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main + mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions-report.html + - name: Analyze Testably.Abstractions.AccessControl + env: + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + shell: bash + run: | + cd Tests + ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.AccessControl.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main + mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions.AccessControl-report.html + - name: Analyze Testably.Abstractions.Compression + env: + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + shell: bash + run: | + cd Tests + ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Compression.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main + mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions.Compression-report.html + - name: Analyze Testably.Abstractions.Testing + env: + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + shell: bash + run: | + cd Tests + ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Testing.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main + mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions.Testing-report.html + - name: Upload Stryker reports + uses: actions/upload-artifact@v3 + with: + name: Stryker + path: Tests/StrykerOutput/Reports/* + - name: Add comment to pull request + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + prNumber="${{ github.event.number }}" + commentsUrl="https://api.github.com/repos/Testably/Testably.Abstractions/issues/$prNumber/comments" + dashboardLink="[Stryker.NET](https://stryker-mutator.io/docs/stryker-net/introduction/) was executed on the changes in the pull request: \n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FTestably%2FTestably.Abstractions%2F${GITHUB_HEAD_REF})](https://dashboard.stryker-mutator.io/reports/github.com/Testably/Testably.Abstractions/${GITHUB_HEAD_REF})" + echo "Search for comment in PR#$prNumber containing $dashboardLink..." + result=$(curl -X GET $commentsUrl \ + -H "Content-Type: application/json" \ + -H "Authorization: token $GITHUB_TOKEN") + if [[ $result != *"$dashboardLink"* ]] + then + body="{\"body\":\"$dashboardLink\"}" + curl -X POST $commentsUrl \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: token $GITHUB_TOKEN" \ + -d "$body" + fi diff --git a/Testably.Abstractions.sln b/Testably.Abstractions.sln index 2a482f6b3..a0331bbcb 100644 --- a/Testably.Abstractions.sln +++ b/Testably.Abstractions.sln @@ -59,7 +59,6 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{8FD8E33B-2072-48CA-8164-DE2AA5DCB8FD}" ProjectSection(SolutionItems) = preProject .github\workflows\build.yml = .github\workflows\build.yml - .github\workflows\ci-stryker.yml = .github\workflows\ci-stryker.yml .github\workflows\ci.yml = .github\workflows\ci.yml .github\workflows\pr.yml = .github\workflows\pr.yml .github\workflows\test-report.yml = .github\workflows\test-report.yml From 84f10106a8952f57948364fda03c53fe3a10a9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 30 Mar 2024 08:34:27 +0100 Subject: [PATCH 2/3] Adapt stryker comment --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cdb67686..b039e17ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -245,7 +245,7 @@ jobs: run: | prNumber="${{ github.event.number }}" commentsUrl="https://api.github.com/repos/Testably/Testably.Abstractions/issues/$prNumber/comments" - dashboardLink="[Stryker.NET](https://stryker-mutator.io/docs/stryker-net/introduction/) was executed on the changes in the pull request: \n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FTestably%2FTestably.Abstractions%2F${GITHUB_HEAD_REF})](https://dashboard.stryker-mutator.io/reports/github.com/Testably/Testably.Abstractions/${GITHUB_HEAD_REF})" + dashboardLink="[Stryker.NET](https://stryker-mutator.io/docs/stryker-net/introduction/) mutation tested the changes in the pull request: \n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FTestably%2FTestably.Abstractions%2F${GITHUB_HEAD_REF})](https://dashboard.stryker-mutator.io/reports/github.com/Testably/Testably.Abstractions/${GITHUB_HEAD_REF})" echo "Search for comment in PR#$prNumber containing $dashboardLink..." result=$(curl -X GET $commentsUrl \ -H "Content-Type: application/json" \ From b586ece33563adb2d28584bb7f4bec1821fd8cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 30 Mar 2024 08:37:02 +0100 Subject: [PATCH 3/3] Only search for comments which already contain the mutation badge --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b039e17ee..308fc1fcd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -245,12 +245,13 @@ jobs: run: | prNumber="${{ github.event.number }}" commentsUrl="https://api.github.com/repos/Testably/Testably.Abstractions/issues/$prNumber/comments" - dashboardLink="[Stryker.NET](https://stryker-mutator.io/docs/stryker-net/introduction/) mutation tested the changes in the pull request: \n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FTestably%2FTestably.Abstractions%2F${GITHUB_HEAD_REF})](https://dashboard.stryker-mutator.io/reports/github.com/Testably/Testably.Abstractions/${GITHUB_HEAD_REF})" - echo "Search for comment in PR#$prNumber containing $dashboardLink..." + mutationBadge="[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FTestably%2FTestably.Abstractions%2F${GITHUB_HEAD_REF})](https://dashboard.stryker-mutator.io/reports/github.com/Testably/Testably.Abstractions/${GITHUB_HEAD_REF})" + dashboardLink="[Stryker.NET](https://stryker-mutator.io/docs/stryker-net/introduction/) mutation tested the changes in the pull request: \n$mutationBadge" + echo "Search for comment in PR#$prNumber containing $mutationBadge..." result=$(curl -X GET $commentsUrl \ -H "Content-Type: application/json" \ -H "Authorization: token $GITHUB_TOKEN") - if [[ $result != *"$dashboardLink"* ]] + if [[ $result != *"$mutationBadge"* ]] then body="{\"body\":\"$dashboardLink\"}" curl -X POST $commentsUrl \