Skip to content

Commit

Permalink
Enhance Benchmark Results with n8n (#1162)
Browse files Browse the repository at this point in the history
Improves visibility of performance metrics by storing benchmark results
from main branch and forwarding PR comparisons to n8n. Added automated
unit conversion, categorized result tables, and performance difference
highlighting to facilitate data-driven development decisions.
  • Loading branch information
chacha912 authored Feb 20, 2025
1 parent 900dc45 commit 30911b2
Showing 1 changed file with 50 additions and 13 deletions.
63 changes: 50 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,62 @@ jobs:
run: docker compose -f build/docker/docker-compose.yml up --build -d

- name: Bench
run: make bench
id: curr-bench
run: |
make bench
content=$(cat output.txt | jq -R -s .)
echo "BENCH_RESULT=$content" >> $GITHUB_OUTPUT
- name: Download previous benchmark data
- name: Set up cache
uses: actions/cache@v3
with:
path: ./cache
key: ${{ runner.os }}-benchmark

- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
with:
name: Go Benchmark
tool: "go"
output-file-path: output.txt
external-data-json-path: ./cache/benchmark-data.json
fail-on-alert: false
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-always: true
- name: Read previous benchmark result
if: github.event_name == 'pull_request'
id: prev-bench
run: |
echo "PREV_BENCH_RESULT=null" >> $GITHUB_OUTPUT
echo "PREV_COMMIT=null" >> $GITHUB_OUTPUT
if [ -f "./cache/bench_result.txt" ]; then
content=$(cat ./cache/bench_result.txt | jq -R -s .)
echo "PREV_BENCH_RESULT=$content" >> $GITHUB_OUTPUT
if [ -f "./cache/commit_hash.txt" ]; then
prev_commit=$(cat ./cache/commit_hash.txt)
echo "PREV_COMMIT=$prev_commit" >> $GITHUB_OUTPUT
fi
fi
- name: Trigger n8n webhook
if: github.event_name == 'pull_request'
run: |
curr_bench=$(cat output.txt | jq -R -s .)
response=$(curl -f -X POST ${{ secrets.N8N_WEBHOOK_URL }} \
-H "Content-Type: application/json" \
-d '{
"repo": "${{ github.repository }}",
"pr_number": "${{ github.event.pull_request.number }}",
"commit_id": "${{ github.sha }}",
"prev_commit_id": "${{ steps.prev-bench.outputs.PREV_COMMIT }}",
"bench_result": ${{ steps.curr-bench.outputs.BENCH_RESULT }},
"prev_bench_result": ${{ steps.prev-bench.outputs.PREV_BENCH_RESULT }}
}' || echo "CURL_ERROR")
if [ "$response" = "CURL_ERROR" ]; then
echo "::error::Failed to trigger n8n webhook"
exit 1
fi
- name: Store benchmark result to cache
if: github.ref == 'refs/heads/main'
run: |
mkdir -p ./cache
cp output.txt ./cache/bench_result.txt
echo "${{ github.sha }}" > ./cache/commit_hash.txt
complex-test:
name: complex-test
Expand Down

0 comments on commit 30911b2

Please sign in to comment.