Skip to content

Commit

Permalink
refactor: combine ci-stryker and ci pipeline (#539)
Browse files Browse the repository at this point in the history
* Merge `ci-stryker.yml` and `ci.yml` into one pipeline to reduce the required maintenance effort.

* Adapt stryker comment

* Only search for comments which already contain the mutation badge
  • Loading branch information
vbreuss authored Mar 30, 2024
1 parent 8cefbb5 commit d47c86b
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 91 deletions.
90 changes: 0 additions & 90 deletions .github/workflows/ci-stryker.yml

This file was deleted.

83 changes: 83 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,86 @@ 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"
mutationBadge="[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgit.luolix.top%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 != *"$mutationBadge"* ]]
then
body="{\"body\":\"$dashboardLink\"}"
curl -X POST $commentsUrl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token $GITHUB_TOKEN" \
-d "$body"
fi
1 change: 0 additions & 1 deletion Testably.Abstractions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d47c86b

Please sign in to comment.