@@ -105,6 +105,16 @@ jobs:
105105 BENCH_TIME="${{ github.event.inputs.bench_time }}"
106106 fi
107107
108+ {
109+ echo "BASE_REF=$BASE_REF"
110+ echo "HEAD_REF=$HEAD_REF"
111+ echo "BASE_STRATEGY=$BASE_STRATEGY"
112+ echo "SUITE_PROFILE=$SUITE_PROFILE"
113+ echo "SUITE_LIST=$SUITE_LIST"
114+ echo "BENCH_COUNT=$BENCH_COUNT"
115+ echo "BENCH_TIME=$BENCH_TIME"
116+ } > bench-artifacts/meta.env
117+
108118 set +e
109119 DNS_BENCH_PROFILE="$SUITE_PROFILE" \
110120 DNS_BENCH_SUITES="$SUITE_LIST" \
@@ -148,14 +158,114 @@ jobs:
148158 path : bench-artifacts
149159 if-no-files-found : warn
150160
161+ - name : Build PR Summary
162+ if : always() && github.event_name == 'pull_request'
163+ shell : bash
164+ run : |
165+ set -euo pipefail
166+
167+ PR_SUMMARY="bench-artifacts/pr-summary.md"
168+ META_FILE="bench-artifacts/meta.env"
169+ if [[ ! -f "$META_FILE" ]]; then
170+ exit 0
171+ fi
172+
173+ # shellcheck disable=SC1090
174+ source "$META_FILE"
175+
176+ total=0
177+ passed=0
178+ failed=0
179+ suite_lines=""
180+ suite_delta_lines=""
181+
182+ extract_time_geomean_line() {
183+ local file="$1"
184+ [[ -f "$file" ]] || return 1
185+ awk '
186+ $1=="geomean" {print; exit}
187+ ' "$file"
188+ }
189+
190+ suite_delta_summary() {
191+ local suite="$1"
192+ local benchstat_file="bench-artifacts/$suite/benchstat_common.txt"
193+ local geomean_line old_v new_v delta_v
194+ geomean_line="$(extract_time_geomean_line "$benchstat_file" || true)"
195+ if [[ -z "$geomean_line" ]]; then
196+ echo "- \`$suite\`: n/a (no common benchmark delta)"
197+ return 0
198+ fi
199+
200+ old_v="$(awk '{print $2}' <<<"$geomean_line")"
201+ new_v="$(awk '{print $3}' <<<"$geomean_line")"
202+ delta_v="$(grep -Eo '([+-][0-9]+(\.[0-9]+)?%|[+-]?Inf%)' <<<"$geomean_line" | head -n1 || true)"
203+ [[ -z "$old_v" ]] && old_v="n/a"
204+ [[ -z "$new_v" ]] && new_v="n/a"
205+ [[ -z "$delta_v" ]] && delta_v="n/a"
206+
207+ echo "- \`$suite\`: \`$old_v -> $new_v\` (Δ \`$delta_v\`)"
208+ }
209+
210+ while IFS= read -r status_file; do
211+ suite="$(basename "$(dirname "$status_file")")"
212+ status="$(cat "$status_file" 2>/dev/null || echo 1)"
213+ total=$((total + 1))
214+ if [[ "$status" == "0" ]]; then
215+ passed=$((passed + 1))
216+ suite_lines+="- ✅ \`$suite\`: pass"$'\n'
217+ else
218+ failed=$((failed + 1))
219+ suite_lines+="- ❌ \`$suite\`: failed"$'\n'
220+ fi
221+ suite_delta_lines+="$(suite_delta_summary "$suite")"$'\n'
222+ done < <(find bench-artifacts -mindepth 2 -maxdepth 2 -name status.txt | sort)
223+
224+ overall="pass"
225+ if [[ "$failed" -gt 0 || "$total" -eq 0 ]]; then
226+ overall="not pass"
227+ fi
228+
229+ {
230+ echo "## DNS Benchmark Compare Summary"
231+ echo
232+ echo "- Before (base): \`$BASE_REF\`"
233+ echo "- After (head): \`$HEAD_REF\`"
234+ echo "- Base strategy: \`$BASE_STRATEGY\`"
235+ if [[ -n "$SUITE_LIST" ]]; then
236+ echo "- Suite selection: \`$SUITE_LIST\`"
237+ else
238+ echo "- Suite profile: \`$SUITE_PROFILE\`"
239+ fi
240+ echo "- Overall: **$overall** ($passed/$total passed)"
241+ echo "- Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
242+ echo "- Full report artifact: \`dns-benchmark-compare-${{ github.run_id }}\`"
243+ echo
244+ echo "### Suite Status"
245+ echo
246+ if [[ "$total" -eq 0 ]]; then
247+ echo "- No suite status generated (benchmark setup failed early)."
248+ else
249+ printf "%s" "$suite_lines"
250+ fi
251+ echo
252+ echo "### Suite Delta (time/op geomean)"
253+ echo
254+ if [[ "$total" -eq 0 ]]; then
255+ echo "- No suite delta generated."
256+ else
257+ printf "%s" "$suite_delta_lines"
258+ fi
259+ } > "$PR_SUMMARY"
260+
151261 - name : Update PR Comment
152- if : always() && github.event_name == 'pull_request' && hashFiles('bench-artifacts/report .md') != ''
262+ if : always() && github.event_name == 'pull_request' && hashFiles('bench-artifacts/pr-summary .md') != ''
153263 uses : actions/github-script@v7
154264 with :
155265 script : |
156266 const fs = require("fs");
157267 const marker = "<!-- dae-dns-benchmark-compare -->";
158- const report = fs.readFileSync("bench-artifacts/report .md", "utf8");
268+ const report = fs.readFileSync("bench-artifacts/pr-summary .md", "utf8");
159269 const body = `${marker}\n${report}`;
160270 const { owner, repo } = context.repo;
161271 const issue_number = context.issue.number;
0 commit comments