Skip to content

Commit d47c86b

Browse files
authored
refactor: combine ci-stryker and ci pipeline (#539)
* 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
1 parent 8cefbb5 commit d47c86b

File tree

3 files changed

+83
-91
lines changed

3 files changed

+83
-91
lines changed

.github/workflows/ci-stryker.yml

Lines changed: 0 additions & 90 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,86 @@ jobs:
176176
with:
177177
command: dotnet test Examples --no-build
178178
attempt_limit: 2
179+
180+
stryker:
181+
name: Mutation testing
182+
runs-on: ubuntu-latest
183+
timeout-minutes: 300
184+
steps:
185+
- name: Checkout sources
186+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
187+
with:
188+
fetch-depth: 0
189+
- name: Setup .NET
190+
uses: actions/setup-dotnet@v4
191+
with:
192+
dotnet-version: |
193+
6.0.x
194+
7.0.x
195+
8.0.x
196+
- name: Install .NET Stryker
197+
shell: bash
198+
run: |
199+
dotnet tool install dotnet-stryker --tool-path ../tools
200+
- name: Prepare Reports directory
201+
shell: bash
202+
run: |
203+
mkdir Tests/StrykerOutput/Reports -p
204+
- name: Analyze Testably.Abstractions
205+
env:
206+
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
207+
shell: bash
208+
run: |
209+
cd Tests
210+
../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main
211+
mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions-report.html
212+
- name: Analyze Testably.Abstractions.AccessControl
213+
env:
214+
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
215+
shell: bash
216+
run: |
217+
cd Tests
218+
../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.AccessControl.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main
219+
mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions.AccessControl-report.html
220+
- name: Analyze Testably.Abstractions.Compression
221+
env:
222+
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
223+
shell: bash
224+
run: |
225+
cd Tests
226+
../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Compression.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main
227+
mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions.Compression-report.html
228+
- name: Analyze Testably.Abstractions.Testing
229+
env:
230+
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
231+
shell: bash
232+
run: |
233+
cd Tests
234+
../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Testing.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main
235+
mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions.Testing-report.html
236+
- name: Upload Stryker reports
237+
uses: actions/upload-artifact@v3
238+
with:
239+
name: Stryker
240+
path: Tests/StrykerOutput/Reports/*
241+
- name: Add comment to pull request
242+
env:
243+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
244+
shell: bash
245+
run: |
246+
prNumber="${{ github.event.number }}"
247+
commentsUrl="https://api.github.com/repos/Testably/Testably.Abstractions/issues/$prNumber/comments"
248+
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})"
249+
dashboardLink="[Stryker.NET](https://stryker-mutator.io/docs/stryker-net/introduction/) mutation tested the changes in the pull request: \n$mutationBadge"
250+
echo "Search for comment in PR#$prNumber containing $mutationBadge..."
251+
result=$(curl -X GET $commentsUrl \
252+
-H "Content-Type: application/json" \
253+
-H "Authorization: token $GITHUB_TOKEN")
254+
if [[ $result != *"$mutationBadge"* ]]
255+
then
256+
body="{\"body\":\"$dashboardLink\"}"
257+
curl -X POST $commentsUrl \
258+
-H "Accept: application/vnd.github+json" \
259+
-H "Authorization: token $GITHUB_TOKEN" \
260+
-d "$body"
261+
fi

Testably.Abstractions.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ EndProject
5959
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{8FD8E33B-2072-48CA-8164-DE2AA5DCB8FD}"
6060
ProjectSection(SolutionItems) = preProject
6161
.github\workflows\build.yml = .github\workflows\build.yml
62-
.github\workflows\ci-stryker.yml = .github\workflows\ci-stryker.yml
6362
.github\workflows\ci.yml = .github\workflows\ci.yml
6463
.github\workflows\pr.yml = .github\workflows\pr.yml
6564
.github\workflows\test-report.yml = .github\workflows\test-report.yml

0 commit comments

Comments
 (0)