feat(workflows): add benchmarking PR result posting
Some checks failed
CI / test-backend (push) Successful in 6s
CI / lint (push) Failing after 5m2s
CI / build-frontend (push) Successful in 9m38s
CI / test-lang (push) Successful in 9m35s
Benchmarks / benchmark (pull_request) Successful in 13m19s
CI / test-backend (pull_request) Successful in 5s
Tests / test (pull_request) Failing after 7m8s
CI / lint (pull_request) Failing after 1m16s
Build and Publish Docker Image / build (pull_request) Has been skipped
CI / build-frontend (pull_request) Successful in 9m39s
Build Test / Build and Test (pull_request) Successful in 6m2s
CI / test-lang (pull_request) Successful in 9m36s
OSV-Scanner PR Scan / scan-pr (pull_request) Successful in 7s
Benchmarks / benchmark (push) Successful in 12m57s
Build Test / Build and Test (push) Successful in 21m35s
Tests / test (push) Failing after 8m7s
Build and Publish Docker Image / build-dev (pull_request) Successful in 12m24s

This commit is contained in:
2026-01-03 19:54:26 -06:00
parent 7668ee5619
commit f60431789d
2 changed files with 60 additions and 2 deletions

View File

@@ -37,7 +37,19 @@ jobs:
run: task install
- name: Run Benchmarks
run: task bench
id: bench
run: |
set -o pipefail
task bench 2>&1 | tee bench_results.txt
- name: Run Integrity Tests
run: task test-integrity
id: integrity
run: |
set -o pipefail
task test-integrity 2>&1 | tee -a bench_results.txt
- name: Post Results to PR
if: always() && github.event_name == 'pull_request'
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: bash scripts/post_bench_results.sh

46
scripts/post_bench_results.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
set -e
# Required environment variables:
# GITEA_TOKEN
# GITHUB_REPOSITORY
# GITHUB_EVENT_PATH
if [ -z "$GITEA_TOKEN" ]; then
echo "GITEA_TOKEN is not set. Skipping PR comment."
exit 0
fi
if [ ! -f "bench_results.txt" ]; then
echo "bench_results.txt not found. Nothing to post."
exit 0
fi
# Extract PR number from the event JSON
PR_NUMBER=$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH")
if [ "$PR_NUMBER" == "null" ]; then
echo "Not a pull request. Skipping."
exit 0
fi
# Filter out progress lines to keep the comment clean
grep -v "Progress:" bench_results.txt > bench_filtered.txt || true
# Construct the message
HEADER="### Benchmark and Integrity Results (automated report)"
RESULTS=$(cat bench_filtered.txt)
# Use jq to construct the JSON payload safely
JSON_PAYLOAD=$(jq -n \
--arg results "$RESULTS" \
--arg header "$HEADER" \
'{body: ($header + "\n\n```text\n" + $results + "\n```"), event: "COMMENT"}')
# Post to Gitea
curl -f -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" \
"https://git.quad4.io/api/v1/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/reviews"