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
47 lines
1.2 KiB
Bash
Executable File
47 lines
1.2 KiB
Bash
Executable File
#!/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"
|
|
|