Repository navigation
294 lines (255 loc) · 10.8 KB
/
Copy pathci.yml
File metadata and controls
294 lines (255 loc) · 10.8 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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: CI
on:
pull_request:
branches: [develop, main]
# Least privilege: the token can only read; a job that needs more asks for it itself.
permissions:
contents: read
jobs:
unit-tests:
name: Unit Tests - ${{ matrix.framework }}
runs-on: ubuntu-24.04
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
framework: [net8.0, net10.0]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: |
8.0.x
10.0.x
- name: Cache NuGet packages
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'Directory.Build.props') }}
restore-keys: nuget-${{ runner.os }}-
- name: Restore
run: dotnet restore
# One project at a time, only the projects that target this runtime (the samples and their tests are net10.0 only).
# Coverage is collected on the net8.0 leg only; the net10.0 leg exists to catch a runtime behaviour change.
- name: Test
env:
FRAMEWORK: ${{ matrix.framework }}
FILTER: Category!=Integration&Category!=Reliability&Category!=Stress&FullyQualifiedName!~Reliability&FullyQualifiedName!~Integration&FullyQualifiedName!~Stress
run: |
COLLECT=()
if [ "$FRAMEWORK" = "net8.0" ]; then COLLECT=(--collect:"XPlat Code Coverage" --results-directory ./coverage/); fi
STATUS=0
for dir in tests/*/; do
name=$(basename "$dir")
[ -f "${dir}${name}.csproj" ] || continue
# The filter excludes these projects entirely: do not build them.
case "$name" in *IntegrationTests|*ReliabilityTests|*StressTests) continue ;; esac
# Only the projects that target this runtime (the samples and their tests are net10.0 only).
[ "$FRAMEWORK" = "net8.0" ] && [ "$name" = "NexJob.Samples.Tests" ] && continue
# By project, not by dll: the coverage collector is resolved from the project's restored packages.
# Builds only this project and its references, for this framework only.
dotnet test "${dir}${name}.csproj" --no-restore --configuration Release --framework "$FRAMEWORK" --filter "$FILTER" "${COLLECT[@]}" --blame-hang --blame-hang-timeout 10m || STATUS=1
done
exit $STATUS
- name: Debug Coverage Files
if: matrix.framework == 'net8.0'
run: |
echo "Listing all XML files in ./coverage:"
find ./coverage -name "*.xml"
- name: Install ReportGenerator
if: matrix.framework == 'net8.0'
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Generate Coverage Report
if: matrix.framework == 'net8.0'
run: |
reportgenerator \
-reports:"./coverage/**/*.xml" \
-targetdir:"./coverage-report" \
-reporttypes:TextSummary \
-title:NexJob-Coverage \
-assemblyfilters:"+NexJob;+NexJob.Dashboard;+NexJob.Dashboard.Standalone;+NexJob.Kafka;+NexJob.RabbitMQ;+NexJob.Trigger.*" \
-classfilters:"-Eventbus.V1.*"
- name: Check Coverage Threshold
if: matrix.framework == 'net8.0'
run: |
COVERAGE=$(grep "Line coverage" ./coverage-report/Summary.txt | awk '{print $3}' | sed 's/%//')
echo "Current Line Coverage: $COVERAGE%"
if (( $(echo "$COVERAGE < 80.0" | bc -l) )); then
echo "Error: Line coverage ($COVERAGE%) is below 80%"
exit 1
fi
- name: Upload unit test artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
name: unit-test-artifacts-${{ matrix.framework }}
path: |
**/TestResults/**/*.trx
./coverage-report/**
integration-tests:
name: Integration Tests - ${{ matrix.name }} - ${{ matrix.framework }}
runs-on: ubuntu-24.04
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
framework: [net8.0, net10.0]
name: [InMemory-EndToEnd, Reliability-InMemory, Redis, Postgres, Mongo, SqlServer, RabbitMQ, Kafka, Sqs, Salesforce, GooglePubSub]
include:
- name: InMemory-EndToEnd
project: tests/NexJob.IntegrationTests
filter: '(FullyQualifiedName~InMemoryStorageProviderTests)|(FullyQualifiedName~JobExecutionEndToEndTests)|(FullyQualifiedName~InMemoryShutdownRequeueEndToEndTests)|(FullyQualifiedName~InMemoryFilterOutcomeEndToEndTests)'
- name: Reliability-InMemory
project: tests/NexJob.ReliabilityTests
filter: 'Category=Reliability.InMemory'
- name: Redis
project: tests/NexJob.IntegrationTests
filter: 'FullyQualifiedName~Redis'
- name: Postgres
project: tests/NexJob.IntegrationTests
filter: 'FullyQualifiedName~Postgres'
- name: Mongo
project: tests/NexJob.IntegrationTests
filter: 'FullyQualifiedName~Mongo'
- name: SqlServer
project: tests/NexJob.IntegrationTests
filter: 'FullyQualifiedName~SqlServer'
- name: RabbitMQ
project: tests/NexJob.RabbitMQ.IntegrationTests
filter: ''
- name: Kafka
project: tests/NexJob.Kafka.IntegrationTests
filter: ''
- name: Sqs
project: tests/NexJob.Trigger.AwsSqs.IntegrationTests
filter: ''
- name: Salesforce
project: tests/NexJob.Trigger.Salesforce.IntegrationTests
filter: ''
- name: GooglePubSub
project: tests/NexJob.Trigger.GooglePubSub.IntegrationTests
filter: ''
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: |
8.0.x
10.0.x
- name: Cache NuGet packages
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'Directory.Build.props') }}
restore-keys: nuget-${{ runner.os }}-
- name: Restore
run: dotnet restore ${{ matrix.project }}
- name: Run integration tests
run: |
if [ -n "${{ matrix.filter }}" ]; then
dotnet test ${{ matrix.project }} \
--no-restore \
--configuration Release \
--framework ${{ matrix.framework }} \
--verbosity normal \
--filter "${{ matrix.filter }}" \
--logger "trx;LogFileName=${{ matrix.name }}-${{ matrix.framework }}.trx" \
--blame-hang \
--blame-hang-timeout 5m
else
dotnet test ${{ matrix.project }} \
--no-restore \
--configuration Release \
--framework ${{ matrix.framework }} \
--verbosity normal \
--logger "trx;LogFileName=${{ matrix.name }}-${{ matrix.framework }}.trx" \
--blame-hang \
--blame-hang-timeout 5m
fi
- name: Upload integration test artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
name: integration-${{ matrix.name }}-${{ matrix.framework }}-artifacts
path: |
${{ matrix.project }}/TestResults/**/*.trx
${{ matrix.project }}/TestResults/**/*
format-check:
name: Format Check
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: |
8.0.x
10.0.x
- name: Cache NuGet packages
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'Directory.Build.props') }}
restore-keys: nuget-${{ runner.os }}-
- name: Restore
run: dotnet restore
- name: Check formatting
run: dotnet format --verify-no-changes --severity warn --no-restore
docs-truth:
name: Docs Truth
runs-on: ubuntu-24.04
timeout-minutes: 10
# Reports the drift between the code and the wiki. It does not block the pull request yet: it becomes
# blocking (--strict, no continue-on-error) when the baseline stays at zero.
continue-on-error: true
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: |
8.0.x
10.0.x
- name: Compare the code with the wiki
run: |
dotnet run --project tools/DocsTruth -c Release -- --report docs-truth-report.md --strict || STATUS=$?
cat docs-truth-report.md >> "$GITHUB_STEP_SUMMARY"
exit "${STATUS:-0}"
security-scan:
name: Security Scan
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: |
8.0.x
10.0.x
- name: Cache NuGet packages
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'Directory.Build.props') }}
restore-keys: nuget-${{ runner.os }}-
- name: Restore
run: dotnet restore
- name: Check for vulnerabilities
run: |
dotnet list package --vulnerable --include-transitive 2>&1 | tee vulnerable.txt
if grep -q "has the following vulnerable packages" vulnerable.txt; then
echo "Vulnerable packages found!"
cat vulnerable.txt
exit 1
fi
echo "No vulnerable packages found"
- name: Upload security scan output
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
name: security-scan-output
path: vulnerable.txt