-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (133 loc) · 4.57 KB
/
build.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
name: Build & Release
on:
push:
pull_request:
branches: [ main ]
workflow_dispatch:
env:
build-version-number: 0.2.${{ github.run_number }}
docker-image-name: ghcr.io/tonycknight/nomoretrolls:v0.2.${{ github.run_number }}
jobs:
sca:
uses: ./.github/workflows/sca.yml
check-style:
name: Check style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
- name: Restore packages
run: |
dotnet tool restore
dotnet restore
- name: Check Style
run: dotnet format --verify-no-changes
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
- name: Restore packages
run: |
dotnet tool restore
dotnet restore
- name: Unit tests
run: dotnet test -c Debug --logger "trx;LogFileName=test_results.trx" /p:CollectCoverage=true /p:CoverletOutput=./TestResults/coverage.info /p:CoverletOutputFormat=cobertura
- name: Consolidate coverage
run: dotnet reportgenerator -reports:'./tests/**/coverage.info' -reporttypes:'html' -targetdir:'./publish/codecoverage'
- name: Archive Test results
uses: actions/upload-artifact@v4
if: always()
with:
name: tests.results
path: |
./tests/**/TestResults/*
- name: Archive Code coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: codecoverage
path: ./publish/codecoverage/*.*
- name: Unit test results
uses: dorny/test-reporter@v1
if: always()
with:
name: unit test results
path: ${{ github.workspace }}/tests/nomoretrolls.tests/TestResults/test_results.trx
reporter: dotnet-trx
token: ${{ secrets.GITHUB_TOKEN }}
- name: Code coverage results
uses: 5monkeys/cobertura-action@master
if: always()
with:
path: ${{ github.workspace }}/tests/nomoretrolls.tests/TestResults/coverage.info
repo_token: ${{ secrets.GITHUB_TOKEN }}
minimum_coverage: 70
fail_below_threshold: false
show_line: true
show_branch: true
show_missing: true
show_class_names: true
link_missing_lines: true
report_name: code coverage results
stryker:
name: Mutation testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
- name: Restore packages
run: |
dotnet tool restore
dotnet restore
- name: Run Mutation testing
run: dotnet dotnet-stryker
- name: Archive Stryker results
uses: actions/upload-artifact@v4
if: always()
with:
name: stryker.results
path: |
./StrykerOutput/**/reports/*
codeql:
uses: ./.github/workflows/codeql-analysis.yml
build-docker-image:
name: Build Docker image
runs-on: ubuntu-latest
needs: [ check-style, unit-tests, sca, codeql, stryker ]
steps:
- uses: actions/checkout@v4
- name: Set Preview Docker image name
if: ${{ github.ref != 'refs/heads/main' }}
run: |
echo "docker-image-name=${{ env.docker-image-name }}-preview" >> $GITHUB_ENV
- name: Build docker image
run: docker build -t ${{ env.docker-image-name }} --build-arg BuildVersion=${{ env.build-version-number }} .
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR }}
- name: Push docker image
if: ${{ github.event_name != 'pull_request' }}
run: docker push ${{ env.docker-image-name }}
create-gh-release:
name: Create GH release
runs-on: ubuntu-latest
needs: [ build-docker-image ]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Create Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ env.build-version-number }}
prerelease: true
generateReleaseNotes: true