Skip to content

Commit 216ee47

Browse files
committed
ci: add stryker.net to build
1 parent 1ff8961 commit 216ee47

File tree

4 files changed

+275
-119
lines changed

4 files changed

+275
-119
lines changed

.github/workflows/ci.yml

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: ci
4+
on:
5+
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
6+
push:
7+
branches:
8+
- 'main' # Run the workflow when pushing to the main branch
9+
pull_request:
10+
branches:
11+
- '*' # Run the workflow for all pull requests
12+
release:
13+
types:
14+
- published # Run the workflow when a new GitHub release is published
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
18+
cancel-in-progress: true
19+
20+
env:
21+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
22+
DOTNET_NOLOGO: true
23+
NuGetDirectory: ${{ github.workspace}}/nuget
24+
TestResultsDirectory: ${{ github.workspace}}/TestResults
25+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
26+
27+
jobs:
28+
create-nuget:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v3
32+
with:
33+
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
34+
35+
# Install the .NET SDK indicated in the global.json file
36+
- name: Setup .NET
37+
uses: actions/setup-dotnet@v3
38+
with:
39+
dotnet-version: |
40+
3.1.x
41+
6.0.x
42+
8.0.x
43+
44+
# Create the NuGet package in the folder from the environment variable NuGetDirectory
45+
- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
46+
47+
# Publish the NuGet package as an artifact, so they can be used in the following jobs
48+
- uses: actions/upload-artifact@v3
49+
with:
50+
name: nuget
51+
if-no-files-found: error
52+
retention-days: 7
53+
path: ${{ env.NuGetDirectory }}/*.nupkg
54+
55+
validate-nuget:
56+
runs-on: ubuntu-latest
57+
needs: [ create-nuget ]
58+
steps:
59+
- name: Setup .NET
60+
uses: actions/setup-dotnet@v3
61+
62+
- uses: actions/download-artifact@v3
63+
with:
64+
name: nuget
65+
path: ${{ env.NuGetDirectory }}
66+
67+
- name: Install nuget validator
68+
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
69+
70+
# Validate metadata and content of the NuGet package
71+
# https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab
72+
# If some rules are not applicable, you can disable them
73+
# using the --excluded-rules or --excluded-rule-ids option
74+
- name: Validate package
75+
shell: pwsh
76+
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg") --excluded-rules IconMustBeSet
77+
78+
run-test:
79+
runs-on: ubuntu-latest
80+
timeout-minutes: 30
81+
strategy:
82+
matrix:
83+
framework: [ netcoreapp3.1, net6.0, net8.0 ]
84+
fail-fast: false
85+
env:
86+
TestResultsDirectory: ${{ github.workspace }}/TestResults
87+
permissions:
88+
checks: write
89+
steps:
90+
- uses: actions/checkout@v3
91+
92+
- name: Setup .NET
93+
uses: actions/setup-dotnet@v3
94+
with:
95+
dotnet-version: |
96+
3.1.x
97+
6.0.x
98+
8.0.x
99+
100+
- name: Run tests
101+
run: dotnet test --configuration Release --framework ${{ matrix.framework }} --logger trx --results-directory "${{ env.TestResultsDirectory }}" --collect:"XPlat Code Coverage" --blame-hang --blame-hang-timeout 5min
102+
103+
- uses: actions/upload-artifact@v3
104+
if: always()
105+
with:
106+
name: test-results-${{ matrix.framework }}
107+
if-no-files-found: error
108+
retention-days: 3
109+
path: ${{ env.TestResultsDirectory }}/**/*
110+
111+
- name: Test Report
112+
uses: dorny/test-reporter@v1
113+
if: github.actor != 'dependabot[bot]' && (success() || failure()) && github.repository_owner == 'egil'
114+
with:
115+
name: test-results-${{ matrix.framework }}
116+
path: ${{ env.TestResultsDirectory }}/**/*.trx
117+
path-replace-backslashes: 'true'
118+
reporter: dotnet-trx
119+
120+
run-stryker:
121+
runs-on: ubuntu-latest
122+
if: github.event_name != 'release'
123+
env:
124+
StrykerDirectory: ${{ github.workspace }}/Stryker
125+
permissions:
126+
statuses: write
127+
steps:
128+
- uses: actions/checkout@v3
129+
130+
- name: Setup .NET
131+
uses: actions/setup-dotnet@v3
132+
with:
133+
dotnet-version: |
134+
3.1.x
135+
6.0.x
136+
8.0.x
137+
138+
- name: Install Stryker.NET
139+
run: dotnet tool install -g dotnet-stryker
140+
141+
- name: Run Stryker.NET
142+
id: stryker
143+
run: |
144+
cd test/TimeProviderExtensions.Tests
145+
dotnet stryker --config-file "../../stryker-config.json" --dashboard-api-key "${{ secrets.STRYKER_DASHBOARD_API_KEY }}" --version ${{ env.BRANCH_NAME }} --output ${{ env.StrykerDirectory }}
146+
147+
- run: |
148+
cat ${{ env.StrykerDirectory }}/reports/mutation-report.md >> $GITHUB_STEP_SUMMARY
149+
echo "" >> $GITHUB_STEP_SUMMARY
150+
echo "View the [full report](https://dashboard.stryker-mutator.io/reports/github.com/egil/TimeProviderExtensions/${{ env.BRANCH_NAME }})." >> $GITHUB_STEP_SUMMARY
151+
152+
- name: Stryker Report
153+
if: github.actor != 'dependabot[bot]' && (success() || failure()) && github.repository_owner == 'egil'
154+
uses: Sibz/github-status-action@v1
155+
with:
156+
authToken: ${{secrets.GITHUB_TOKEN}}
157+
context: stryker-report"
158+
description: "See report"
159+
state: ${{ steps.stryker.conclusion }}
160+
sha: ${{ github.event.pull_request.head.sha || github.sha }}
161+
target_url: https://dashboard.stryker-mutator.io/reports/github.com/egil/TimeProviderExtensions/${{ env.BRANCH_NAME }}
162+
163+
- uses: actions/upload-artifact@v3
164+
if: steps.stryker.conclusion == 'success' || steps.stryker.conclusion == 'failure'
165+
with:
166+
name: stryker-reports
167+
if-no-files-found: error
168+
retention-days: 3
169+
path: ${{ env.StrykerDirectory }}/**/*
170+
171+
dependency-review:
172+
runs-on: ubuntu-latest
173+
permissions:
174+
contents: read
175+
if: github.event_name == 'pull_request' && github.repository_owner == 'egil'
176+
steps:
177+
- name: 'Checkout Repository'
178+
uses: actions/checkout@v3
179+
- name: 'Dependency Review'
180+
uses: actions/dependency-review-action@v3
181+
182+
infer-sharp:
183+
runs-on: ubuntu-latest
184+
if: github.event_name != 'release'
185+
permissions:
186+
security-events: write
187+
steps:
188+
- uses: actions/checkout@v3
189+
with:
190+
fetch-depth: 0
191+
192+
- name: Setup .NET
193+
uses: actions/setup-dotnet@v3
194+
with:
195+
dotnet-version: |
196+
3.1.x
197+
6.0.x
198+
8.0.x
199+
200+
- run: dotnet build --configuration Release
201+
202+
- name: Run Infer#
203+
uses: microsoft/[email protected]
204+
id: runinfersharp
205+
with:
206+
binary-path: ./src/TimeProviderExtensions/bin/Release/net8.0
207+
github-sarif: true
208+
209+
- name: Create step summary
210+
run: |
211+
echo # Infer# report >> $GITHUB_STEP_SUMMARY
212+
echo ``` >> $GITHUB_STEP_SUMMARY
213+
cat infer-out/report.txt >> $GITHUB_STEP_SUMMARY
214+
echo ``` >> $GITHUB_STEP_SUMMARY
215+
216+
- name: Upload Infer# report as an artifact
217+
uses: actions/upload-artifact@v2
218+
with:
219+
name: infer-sharp-report
220+
path: infer-out/report.txt
221+
222+
- name: Upload SARIF output to GitHub Security Center
223+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
224+
uses: github/codeql-action/upload-sarif@v2
225+
with:
226+
sarif_file: infer-out/report.sarif
227+
228+
deploy:
229+
# Publish only when creating a GitHub Release
230+
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
231+
# You can update this logic if you want to manage releases differently
232+
if: github.event_name == 'release'
233+
runs-on: ubuntu-latest
234+
needs: [ validate-nuget, run-test ]
235+
steps:
236+
- uses: actions/download-artifact@v3
237+
with:
238+
name: nuget
239+
path: ${{ env.NuGetDirectory }}
240+
241+
- name: Setup .NET Core
242+
uses: actions/setup-dotnet@v3
243+
244+
- name: Publish NuGet package
245+
shell: pwsh
246+
run: |
247+
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
248+
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
249+
}

.github/workflows/publish.yml

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

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/egil/TimeProviderExtensions?include_prereleases&logo=github&style=flat-square)](https://github.com/egil/TimeProviderExtensions/releases)
22
[![Nuget](https://img.shields.io/nuget/dt/TimeProviderExtensions?logo=nuget&style=flat-square)](https://www.nuget.org/packages/TimeProviderExtensions/)
33
[![Issues Open](https://img.shields.io/github/issues/egil/TimeProviderExtensions.svg?style=flat-square&logo=github)](https://github.com/egil/TimeProviderExtensions/issues)
4+
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fegil%2FTimeProviderExtensions%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/egil/TimeProviderExtensions/main)
45

56
# TimeProvider Extensions
67

0 commit comments

Comments
 (0)