-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (133 loc) · 4.27 KB
/
build.yml
File metadata and controls
159 lines (133 loc) · 4.27 KB
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
name: Build & Test Suite
on:
push:
branches: [ master, development ]
paths:
- 'SecurityHelperLibrary/**'
- 'SecurityHelperLibrary.Tests/**'
- 'SecurityHelperLibrary.Sample/**'
- '*.csproj'
- '.github/workflows/build.yml'
pull_request:
branches: [ master, development ]
paths:
- 'SecurityHelperLibrary/**'
- 'SecurityHelperLibrary.Tests/**'
- 'SecurityHelperLibrary.Sample/**'
- '*.csproj'
jobs:
build:
name: Build & Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['8.0.x']
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore dependencies
run: dotnet restore
- name: Build Release
run: dotnet build -c Release --no-restore /p:TreatWarningsAsErrors=true
- name: Run Unit Tests
run: |
mkdir -p TestResults
dotnet test SecurityHelperLibrary.Tests/SecurityHelperLibrary.Tests.csproj \
-c Release \
--no-restore \
-f ${{ matrix.dotnet-version == '6.0.x' && 'net6.0' || 'net8.0' }} \
--results-directory TestResults \
--logger "console;verbosity=normal" \
--logger "trx;LogFileName=unit-test-results.trx" \
--filter "Category!=Pentest" \
/p:CollectCoverage=true \
/p:CoverageFormat=opencover
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
with:
file: ./SecurityHelperLibrary.Tests/coverage.opencover.xml
flags: unittests
name: net-${{ matrix.dotnet-version }}
fail_ci_if_error: false
- name: Upload Test Results
uses: actions/upload-artifact@v7
if: always()
with:
name: unit-test-results-${{ matrix.dotnet-version }}
path: "TestResults/unit-test-results.trx"
quality:
name: Code Quality Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Check for compiler warnings
run: |
dotnet build -c Release --no-restore /p:TreatWarningsAsErrors=true
- name: Run StyleCop analyzers
run: |
dotnet build -c Release --no-restore
- name: Verify CHANGELOG.md updated
if: github.event_name == 'pull_request'
run: |
if git diff origin/${{ github.base_ref }}... | grep -q "^+.*## \["; then
echo "✓ CHANGELOG.md appears to be updated"
else
echo "⚠ CHANGELOG.md may need updating"
exit 0
fi
package:
name: Package & Version Check
runs-on: windows-latest
defaults:
run:
shell: bash
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
- name: Build target frameworks
run: |
dotnet build SecurityHelperLibrary/SecurityHelperLibrary.csproj -c Release -f net481
dotnet build SecurityHelperLibrary/SecurityHelperLibrary.csproj -c Release -f net8.0
- name: Pack NuGet Package
run: |
dotnet pack SecurityHelperLibrary/SecurityHelperLibrary.csproj \
-c Release \
--no-build \
-o ./nupkg
- name: Upload NuGet Package
uses: actions/upload-artifact@v7
with:
name: nuget-package
path: ./nupkg/
build-summary:
name: Build Summary
runs-on: ubuntu-latest
if: always()
needs: [build, quality]
steps:
- name: Check Build Status
run: |
echo "## Build Results 🔨" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Build**: ${{ needs.build.result }}" >> $GITHUB_STEP_SUMMARY
echo "- **Quality**: ${{ needs.quality.result }}" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.build.result }}" != "success" ] || [ "${{ needs.quality.result }}" != "success" ]; then
exit 1
fi