Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Benchmark Results with n8n #1162

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading