-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (179 loc) · 7.9 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: "CI"
on:
workflow_dispatch:
pull_request:
branches: [main]
jobs:
test-macos:
name: Test (MacOS)
runs-on: macos-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
- name: Build solution
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
- name: Run tests
run: dotnet test --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory "TestResults"
- name: Upload test results (MacOS)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: Test results (MacOS)
path: TestResults
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: Code coverage (MacOS)
path: "**/coverage.cobertura.xml"
test-ubuntu:
name: Test (Ubuntu)
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
- name: Build solution
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
- name: Run tests
run: dotnet test --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory "TestResults"
- name: Upload test results (Ubuntu)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: Test results (Ubuntu)
path: TestResults
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: Code coverage (Ubuntu)
path: "**/coverage.cobertura.xml"
test-windows:
name: Test (Windows)
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
- name: Build solution
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
- name: Run tests
run: dotnet test --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory "TestResults"
- name: Upload test results (Windows)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: Test results (Windows)
path: TestResults
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: Code coverage (Windows)
path: "**/coverage.cobertura.xml"
test-net-framework:
name: Test (.NET Framework)
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup VSTest
uses: darenm/Setup-VSTest@v1
- name: Navigate to Workspace
run: cd $GITHUB_WORKSPACE
- name: Build solution
run: msbuild.exe Testably.Expectations.sln /p:NetFrameworkOnly=True /p:platform="Any CPU" /p:configuration="Release" -t:restore,build -p:RestorePackagesConfig=true
- name: Run tests
run: vstest.console.exe .\Build\Tests\Testably.Expectations.Tests\net48\Testably.Expectations.Tests.dll .\Build\Tests\Testably.Expectations.Internal.Tests\net48\Testably.Expectations.Internal.Tests.dll .\Build\Tests\TestFramework.NUnit3.Tests\net48\TestFramework.NUnit3.Tests.dll .\Build\Tests\TestFramework.NUnit4.Tests\net48\TestFramework.NUnit4.Tests.dll .\Build\Tests\TestFramework.XUnit2.Tests\net48\TestFramework.XUnit2.Tests.dll /Logger:trx /ResultsDirectory:TestResults /collect:"Code Coverage;Format=Cobertura"
- name: Upload test results (.NET Framework)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: Test results (.NET Framework)
path: TestResults
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: Code coverage (.NET Framework)
path: "**/*.cobertura.xml"
stryker:
name: Stryker mutation testing
runs-on: ubuntu-latest
timeout-minutes: 300
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
- name: Install .NET Stryker
shell: bash
run: |
dotnet tool install dotnet-stryker --tool-path ../tools --version 4.3.0
- name: Prepare Reports directory
shell: bash
run: |
mkdir Tests/StrykerOutput/Reports -p
- name: Analyze Testably.Expectations
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
shell: bash
run: |
cd Tests
../../tools/dotnet-stryker -f ../.github/stryker/Stryker.CI.Config.json -v "${GITHUB_HEAD_REF}" -r "Dashboard" -r "html" -r "cleartext" --since:main
mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Expectations-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.Expectations/issues/$prNumber/comments"
mutationBadge="[](https://dashboard.stryker-mutator.io/reports/github.com/Testably/Testably.Expectations/${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