feat(ci): Add automated performance tracing to CI pipeline #66
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: 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" | |
| 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: 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 "--- App output so far ---" | |
| cat /tmp/app.log | |
| - name: Collect performance trace | |
| run: | | |
| PID=$(cat app.pid) | |
| echo "Collecting trace from PID $PID..." | |
| dotnet-trace collect --pid $PID --duration 00:00:30 -o trace.nettrace || (echo "Trace collection failed! App logs:" && cat /tmp/app.log && ps aux | grep -i dotnet && exit 1) | |
| - name: Convert trace to Speedscope format | |
| run: dotnet-trace convert trace.nettrace --format Speedscope | |
| - name: Upload flamegraph artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: flamegraph | |
| path: trace.speedscope.json | |
| retention-days: 7 | |
| 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" |