-
Notifications
You must be signed in to change notification settings - Fork 1.5k
368 lines (318 loc) · 11.9 KB
/
Copy pathpackages.yml
File metadata and controls
368 lines (318 loc) · 11.9 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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
name: Packages
on:
workflow_dispatch:
push:
branches:
- 'main'
- 'bug/*'
- 'perf/*'
- 'patch/*'
- 'feat/*'
- 'enh/*'
- 'rc/*'
- 'develop/*'
- 'release/*'
- 'codex/*'
release:
types: [prereleased, published]
env:
base_version: '3.8.0'
feedz_feed_source: 'https://f.feedz.io/elsa-workflows/elsa-3/nuget/index.json'
nuget_feed_source: 'https://api.nuget.org/v3/index.json'
jobs:
test_unit_integration:
name: Test unit/integration with coverage
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.1xx
- name: Show .NET info
run: |
dotnet --info
dotnet --list-sdks
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props', '**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore solution
run: dotnet restore Elsa.sln --ignore-failed-sources
- name: Prepare coverage directory
run: |
rm -rf artifacts/coverage
mkdir -p artifacts/coverage
- name: Run tests with coverage
run: |
set -euo pipefail
dotnet --info
if ! dotnet --version | grep -q '^10\.'; then
echo "Expected .NET SDK 10.x but got $(dotnet --version)" >&2
exit 1
fi
# Discover unit and integration test projects. Component tests run in their own job.
mapfile -t projects < <(
find test/unit test/integration \
-type f -name '*.csproj' -print0 2>/dev/null \
| xargs -0 -n1 \
| sort
)
if [ ${#projects[@]} -eq 0 ]; then
echo "No test projects were found in test/unit or test/integration." >&2
exit 1
fi
for project in "${projects[@]}"; do
echo "Building test project ${project}"
dotnet build "$project" --configuration Release --framework net10.0
echo "Running tests with coverage for ${project}"
dotnet test "$project" \
--configuration Release \
--framework net10.0 \
--no-build \
--logger "GitHubActions;report-warnings=false" \
/p:CollectCoverage=true
done
- name: Dump docker logs on failure
if: failure()
run: |
echo "=== Docker containers ==="
docker ps -a || true
echo "=== Docker logs ==="
for container in $(docker ps -aq); do
echo "--- Logs for container $container ---"
docker logs "$container" 2>&1 | tail -100 || true
done
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: unit-integration-coverage-reports
path: artifacts/coverage
test_component:
name: Test component with coverage
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.1xx
- name: Show .NET info
run: |
dotnet --info
dotnet --list-sdks
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props', '**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore solution
run: dotnet restore Elsa.sln --ignore-failed-sources
- name: Prepare test artifact directories
run: |
rm -rf artifacts/coverage artifacts/test-results
mkdir -p artifacts/coverage artifacts/test-results/component
- name: Run component tests with coverage and hang diagnostics
run: |
set -euo pipefail
dotnet --info
if ! dotnet --version | grep -q '^10\.'; then
echo "Expected .NET SDK 10.x but got $(dotnet --version)" >&2
exit 1
fi
mapfile -t projects < <(
find test/component \
-type f -name '*.csproj' -print0 2>/dev/null \
| xargs -0 -n1 \
| sort
)
if [ ${#projects[@]} -eq 0 ]; then
echo "No test projects were found in test/component." >&2
exit 1
fi
for project in "${projects[@]}"; do
echo "Building component test project ${project}"
dotnet build "$project" --configuration Release --framework net10.0
echo "Running component tests with coverage and hang diagnostics for ${project}"
dotnet test "$project" \
--configuration Release \
--framework net10.0 \
--no-build \
--logger "GitHubActions;report-warnings=false" \
--logger "trx" \
--results-directory artifacts/test-results/component \
--verbosity detailed \
--blame-hang \
--blame-hang-timeout 2m \
--blame-hang-dump-type mini \
/p:CollectCoverage=true
done
- name: Dump docker logs on failure
if: failure()
run: |
echo "=== Docker containers ==="
docker ps -a || true
echo "=== Docker logs ==="
for container in $(docker ps -aq); do
echo "--- Logs for container $container ---"
docker logs "$container" 2>&1 | tail -100 || true
done
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: component-coverage-reports
path: artifacts/coverage
- name: Upload component test diagnostics
if: always()
uses: actions/upload-artifact@v4
with:
name: component-test-diagnostics
path: artifacts/test-results
coverage_report:
name: Generate coverage report
needs:
- test_unit_integration
- test_component
runs-on: ubuntu-latest
timeout-minutes: 10
if: always() && !cancelled() && needs.test_unit_integration.result == 'success' && needs.test_component.result == 'success'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.1xx
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
pattern: '*-coverage-reports'
path: artifacts/coverage
merge-multiple: true
- name: Install ReportGenerator
run: dotnet tool install -g dotnet-reportgenerator-globaltool
- name: Generate HTML coverage report
run: |
reportgenerator \
"-reports:./artifacts/coverage/**/coverage.cobertura.xml" \
"-targetdir:./artifacts/coverage-report" \
"-reporttypes:Html;Cobertura;TextSummary" \
"-verbosity:Info"
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: artifacts/coverage
- name: Upload Pages artifact
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')
uses: actions/upload-pages-artifact@v3
with:
path: './artifacts/coverage-report'
build:
name: Build packages
needs:
- test_unit_integration
- test_component
runs-on: ubuntu-latest
timeout-minutes: 30
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Extract branch name
run: |
BRANCH_NAME=${{ github.ref }} # e.g., refs/heads/main
BRANCH_NAME=${BRANCH_NAME#refs/heads/} # remove the refs/heads/ prefix
# Extract the last part after the last slash of the branch name, if any, e.g., feature/issue-123 -> issue-123 and use it as the version prefix.
PACKAGE_PREFIX=$(echo $BRANCH_NAME | rev | cut -d/ -f1 | rev | tr '_' '-')
# If the branch name is main, use the preview version. Otherwise, use the branch name as the version prefix.
if [[ "${BRANCH_NAME}" == "main" || "${BRANCH_NAME}" =~ ^develop/ || "${BRANCH_NAME}" =~ ^release/ ]]; then
PACKAGE_PREFIX="preview"
fi
echo "Ref: ${{ github.ref }}"
echo "Branch name: ${BRANCH_NAME}"
echo "Package prefix: ${PACKAGE_PREFIX}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
echo "PACKAGE_PREFIX=${PACKAGE_PREFIX}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Verify commit exists in branch
run: |
if [[ "${{ github.ref }}" == refs/tags/* && "${{ github.event_name }}" == "release" && ("${{ github.event.action }}" == "published" || "${{ github.event.action }}" == "prereleased") ]]; then
git fetch --no-tags --prune origin +refs/heads/*:refs/remotes/origin/*
git branch --remote --contains | grep -E 'origin/(main|release/)'
else
git fetch --no-tags --prune origin +refs/heads/*:refs/remotes/origin/*
git branch --remote --contains | grep origin/${BRANCH_NAME}
fi
- name: Set VERSION variable
run: |
if [[ "${{ github.ref }}" == refs/tags/* && "${{ github.event_name }}" == "release" && ("${{ github.event.action }}" == "published" || "${{ github.event.action }}" == "prereleased") ]]; then
TAG_NAME=${{ github.ref }} # e.g., refs/tags/3.0.0
TAG_NAME=${TAG_NAME#refs/tags/} # remove the refs/tags/ prefix
echo "VERSION=${TAG_NAME}" >> $GITHUB_ENV
else
echo "VERSION=${{env.base_version}}-preview.${{github.run_number}}" >> $GITHUB_ENV
fi
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.x
- name: Compile+Pack
run: ./build.sh Compile+Pack --version ${VERSION} --analyseCode true
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: elsa-nuget-packages
path: packages/*nupkg
if: ${{ github.event_name == 'release' || github.event_name == 'push'}}
publish_preview_feedz:
name: Publish to feedz.io
needs: build
runs-on: ubuntu-latest
timeout-minutes: 20
if: ${{ github.event_name == 'release' || github.event_name == 'push'}}
steps:
- name: Download Packages
uses: actions/download-artifact@v4.1.7
with:
name: elsa-nuget-packages
- name: Publish to feedz.io
run: dotnet nuget push *.nupkg -k ${{ secrets.FEEDZ_API_KEY }} -s ${{ env.feedz_feed_source }} --skip-duplicate
publish_nuget:
name: Publish release to nuget.org
needs: build
runs-on: ubuntu-latest
timeout-minutes: 20
if: ${{ github.event.action == 'published' }}
steps:
- name: Download Packages
uses: actions/download-artifact@v4.1.7
with:
name: elsa-nuget-packages
- name: Publish to nuget.org
run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_API_KEY }} -s ${{ env.nuget_feed_source }} --skip-duplicate
deploy_coverage:
name: Deploy coverage to GitHub Pages
needs: coverage_report
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop/3.6.1' || github.ref == 'refs/heads/release/3.6.1'
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4