-
Notifications
You must be signed in to change notification settings - Fork 0
273 lines (248 loc) · 9.74 KB
/
dotnet.yml
File metadata and controls
273 lines (248 loc) · 9.74 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
name: .NET CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-test:
name: Build & Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore ProbotSharp.sln
- name: Build
run: dotnet build ProbotSharp.sln --configuration Release --no-restore
- name: Test with Coverage
run: dotnet test ProbotSharp.sln --configuration Debug --settings coverlet.runsettings --collect:"XPlat Code Coverage"
- name: Publish Coverage Report
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "tests/**/TestResults/**/coverage.cobertura.xml"
fail_ci_if_error: false
verify-links:
name: Verify Markdown Links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: pip install requests
- name: Verify local links in Markdown files
run: python3 scripts/verify-local-links.py
- name: Verify GitHub links in Markdown files
run: python3 scripts/verify-github-links.py
verify-markdown-code:
name: Verify Markdown C# Code Blocks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore ProbotSharp.sln
- name: Build
run: dotnet build ProbotSharp.sln --configuration Release --no-restore
- name: Verify C# code blocks in Markdown files
run: bash scripts/verify-markdown-code.sh
test-examples:
name: Docker E2E Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Test all examples
run: ./scripts/testing/test-all-examples.sh
timeout-minutes: 30
- name: Upload build logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: example-build-logs
path: /tmp/*_build.log
retention-days: 7
if-no-files-found: ignore
performance-trace:
name: Performance Trace
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install dotnet-trace
run: dotnet tool install --global dotnet-trace
- name: Add dotnet tools to PATH
run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
- name: Restore Dependencies
run: dotnet restore ProbotSharp.sln
- name: Restore HelloWorldBot
run: dotnet restore examples/HelloWorldBot/HelloWorldBot.csproj
- name: Build HelloWorldBot
run: dotnet build examples/HelloWorldBot/HelloWorldBot.csproj -c Release --no-restore
- name: Create dummy GitHub App private key
run: |
cat > /tmp/trace-dummy-key.pem <<'EOF'
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA0Z6Wh6dULwk3p0c2EhjRz1EOwN+R0EQJfzH3AwiBvT7nPzUG
----END RSA PRIVATE KEY-----
EOF
- name: Run HelloWorldBot in background
env:
PROBOTSHARP__GITHUB__APPID: "123456"
PROBOTSHARP__WEBHOOK_SECRET: "test-secret-for-tracing"
PROBOTSHARP__GITHUB__PRIVATEKEYPATH: "/tmp/trace-dummy-key.pem"
TMPDIR: /tmp
DOTNET_DiagnosticPorts: ""
run: |
dotnet run --project examples/HelloWorldBot/HelloWorldBot.csproj -c Release > /tmp/app.log 2>&1 &
echo $! > app.pid
echo "Started HelloWorldBot with PID $(cat app.pid)"
- name: Wait for app to initialize
run: sleep 15
- name: Send webhook workload in background
env:
WEBHOOK_SECRET: "test-secret-for-tracing"
run: |
# Start sending webhooks in background while trace runs
for i in {1..20}; do
# Send issues.opened webhook
PAYLOAD=$(cat fixtures/issues-opened.json)
SIGNATURE=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | sed 's/^.* //')
curl -X POST http://localhost:5000/api/github/webhooks \
-H "Content-Type: application/json" \
-H "X-GitHub-Event: issues" \
-H "X-GitHub-Delivery: $(uuidgen)" \
-H "X-Hub-Signature-256: sha256=$SIGNATURE" \
-d "$PAYLOAD" &
# Send pull_request.opened webhook
PAYLOAD=$(cat fixtures/pull-request-opened.json)
SIGNATURE=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | sed 's/^.* //')
curl -X POST http://localhost:5000/api/github/webhooks \
-H "Content-Type: application/json" \
-H "X-GitHub-Event: pull_request" \
-H "X-GitHub-Delivery: $(uuidgen)" \
-H "X-Hub-Signature-256: sha256=$SIGNATURE" \
-d "$PAYLOAD" &
sleep 0.5
done &
echo "Webhook workload started in background"
- name: Check if process is running
run: |
PID=$(cat app.pid)
echo "Checking if PID $PID is running..."
ps -p $PID || (echo "Process not running!" && cat /tmp/app.log && exit 1)
echo "Process is alive and running"
echo "--- Checking dotnet-trace can see the process ---"
dotnet-trace ps || true
echo "--- Listing diagnostic sockets in /tmp ---"
ls -la /tmp/dotnet-diagnostic-* || echo "No diagnostic sockets found"
echo "--- App output so far ---"
cat /tmp/app.log
- name: Collect performance trace
env:
TMPDIR: /tmp
run: |
echo "Collecting trace from HelloWorldBot process..."
echo "TMPDIR is set to: $TMPDIR"
dotnet-trace collect --name HelloWorldBot --profile cpu-sampling --duration 00:00:30 -o trace.nettrace || (echo "Trace collection failed!" && exit 1)
- name: Convert trace to Speedscope format
run: dotnet-trace convert trace.nettrace --format Speedscope
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Restore baseline from cache
id: restore-baseline
uses: actions/cache/restore@v4
with:
path: perf-baseline.json
key: perf-baseline-main-${{ github.sha }}
restore-keys: |
perf-baseline-main-
- name: Analyze trace and compare to baseline
run: |
if [ -f perf-baseline.json ]; then
echo "Comparing to baseline from main branch"
python3 scripts/analyze-trace.py trace.speedscope.json \
--output perf-metrics.json \
--markdown perf-summary.md \
--baseline perf-baseline.json
else
echo "No baseline found, generating initial metrics"
python3 scripts/analyze-trace.py trace.speedscope.json \
--output perf-metrics.json \
--markdown perf-summary.md
fi
- name: Save to performance history
run: |
mkdir -p perf-history
TIMESTAMP=$(date -u +%Y%m%d-%H%M%S)
COMMIT_SHORT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
cp perf-metrics.json "perf-history/${TIMESTAMP}-${COMMIT_SHORT}.json"
# Keep only last 100 entries
ls -t perf-history/*.json 2>/dev/null | tail -n +101 | xargs -r rm || true
echo "Saved metrics to perf-history/${TIMESTAMP}-${COMMIT_SHORT}.json"
- name: Display performance report
run: |
echo "## Performance Trace Analysis" >> $GITHUB_STEP_SUMMARY
cat perf-summary.md >> $GITHUB_STEP_SUMMARY
- name: Post performance report to PR
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ github.token }}
run: |
# Create comment body with performance summary
COMMENT_BODY="## 📊 Performance Trace Report
$(cat perf-summary.md)
---
[View full trace](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | [Download flamegraph](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
# Post comment to PR
gh pr comment ${{ github.event.pull_request.number }} \
--body "$COMMENT_BODY"
- name: Update baseline cache
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@v4
with:
path: perf-metrics.json
key: perf-baseline-main-${{ github.sha }}
- name: Upload flamegraph artifact
uses: actions/upload-artifact@v4
with:
name: flamegraph
path: trace.speedscope.json
retention-days: 7
- name: Upload performance metrics
uses: actions/upload-artifact@v4
with:
name: performance-metrics
path: |
perf-metrics.json
perf-summary.md
perf-history/
retention-days: 30
all-tests-passed:
name: All Tests Passed
runs-on: ubuntu-latest
needs: [build-test, verify-links, verify-markdown-code, test-examples, performance-trace]
steps:
- run: echo "✅ All tests passed successfully!"
k8s-validation:
name: K8s Validation Status
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- run: echo "ℹ️ Kubernetes validation runs separately in validate-kubernetes workflow"