Skip to content

Commit d129fb8

Browse files
feat(ci): Add automated performance tracing to CI pipeline (#12)
* feat(ci): Add automated performance tracing to CI pipeline Integrates dotnet-trace into the CI workflow to automatically generate performance flamegraphs using HelloWorldBot as the test application. This enables continuous performance monitoring and helps identify regressions early in the development cycle. The performance-trace job: - Builds and runs HelloWorldBot - Collects 30-second performance trace using dotnet-trace - Converts to Speedscope format for visualization - Uploads flamegraph as workflow artifact (7-day retention) - Added as required check in all-tests-passed job
1 parent e7b8851 commit d129fb8

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

.github/workflows/dotnet.yml

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,75 @@ jobs:
9191
retention-days: 7
9292
if-no-files-found: ignore
9393

94+
performance-trace:
95+
name: Performance Trace
96+
runs-on: ubuntu-latest
97+
steps:
98+
- uses: actions/checkout@v4
99+
- name: Setup .NET
100+
uses: actions/setup-dotnet@v4
101+
with:
102+
dotnet-version: 8.0.x
103+
- name: Install dotnet-trace
104+
run: dotnet tool install --global dotnet-trace
105+
- name: Restore Dependencies
106+
run: dotnet restore ProbotSharp.sln
107+
- name: Restore HelloWorldBot
108+
run: dotnet restore examples/HelloWorldBot/HelloWorldBot.csproj
109+
- name: Build HelloWorldBot
110+
run: dotnet build examples/HelloWorldBot/HelloWorldBot.csproj -c Release --no-restore
111+
- name: Create dummy GitHub App private key
112+
run: |
113+
cat > /tmp/trace-dummy-key.pem <<'EOF'
114+
-----BEGIN RSA PRIVATE KEY-----
115+
MIIEowIBAAKCAQEA0Z6Wh6dULwk3p0c2EhjRz1EOwN+R0EQJfzH3AwiBvT7nPzUG
116+
----END RSA PRIVATE KEY-----
117+
EOF
118+
- name: Run HelloWorldBot in background
119+
env:
120+
PROBOTSHARP__GITHUB__APPID: "123456"
121+
PROBOTSHARP__WEBHOOK_SECRET: "test-secret-for-tracing"
122+
PROBOTSHARP__GITHUB__PRIVATEKEYPATH: "/tmp/trace-dummy-key.pem"
123+
TMPDIR: /tmp
124+
DOTNET_DiagnosticPorts: ""
125+
run: |
126+
dotnet run --project examples/HelloWorldBot/HelloWorldBot.csproj -c Release > /tmp/app.log 2>&1 &
127+
echo $! > app.pid
128+
echo "Started HelloWorldBot with PID $(cat app.pid)"
129+
- name: Wait for app to initialize
130+
run: sleep 15
131+
- name: Check if process is running
132+
run: |
133+
PID=$(cat app.pid)
134+
echo "Checking if PID $PID is running..."
135+
ps -p $PID || (echo "Process not running!" && cat /tmp/app.log && exit 1)
136+
echo "Process is alive and running"
137+
echo "--- Checking dotnet-trace can see the process ---"
138+
dotnet-trace ps || true
139+
echo "--- Listing diagnostic sockets in /tmp ---"
140+
ls -la /tmp/dotnet-diagnostic-* || echo "No diagnostic sockets found"
141+
echo "--- App output so far ---"
142+
cat /tmp/app.log
143+
- name: Collect performance trace
144+
env:
145+
TMPDIR: /tmp
146+
run: |
147+
echo "Collecting trace from HelloWorldBot process..."
148+
echo "TMPDIR is set to: $TMPDIR"
149+
dotnet-trace collect --name HelloWorldBot --providers Microsoft-Windows-DotNETRuntime --duration 00:00:30 -o trace.nettrace || (echo "Trace collection failed!" && exit 1)
150+
- name: Convert trace to Speedscope format
151+
run: dotnet-trace convert trace.nettrace --format Speedscope
152+
- name: Upload flamegraph artifact
153+
uses: actions/upload-artifact@v4
154+
with:
155+
name: flamegraph
156+
path: trace.speedscope.json
157+
retention-days: 7
158+
94159
all-tests-passed:
95160
name: All Tests Passed
96161
runs-on: ubuntu-latest
97-
needs: [build-test, verify-links, verify-markdown-code, test-examples]
162+
needs: [build-test, verify-links, verify-markdown-code, test-examples, performance-trace]
98163
steps:
99164
- run: echo "✅ All tests passed successfully!"
100165

0 commit comments

Comments
 (0)