Skip to content

Commit 280a60c

Browse files
authored
Merge pull request #25 from MaurUppi/feat/policy-smart
ci: simplify DNS/SCI PR summaries and scope policy smart SCI
2 parents 2d305a1 + 768f03e commit 280a60c

File tree

2 files changed

+121
-6
lines changed

2 files changed

+121
-6
lines changed

.github/workflows/dns-benchmark-compare.yml

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

.github/workflows/policy-smart-sci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ permissions:
1919
jobs:
2020
sci-1:
2121
name: SCI-1 Strategy Correctness
22+
if: github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'feat/policy-smart') || startsWith(github.head_ref, 'policy-smart')
2223
runs-on: ubuntu-22.04
2324
env:
2425
GOWORK: off
@@ -48,6 +49,7 @@ jobs:
4849
4950
sci-2:
5051
name: SCI-2 TCP Retry Semantics
52+
if: github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'feat/policy-smart') || startsWith(github.head_ref, 'policy-smart')
5153
runs-on: ubuntu-22.04
5254
env:
5355
GOWORK: off
@@ -89,6 +91,7 @@ jobs:
8991
9092
sci-3:
9193
name: SCI-3 Concurrency Race
94+
if: github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'feat/policy-smart') || startsWith(github.head_ref, 'policy-smart')
9295
runs-on: ubuntu-22.04
9396
env:
9497
GOWORK: off
@@ -134,8 +137,8 @@ jobs:
134137
fi
135138
136139
report:
137-
name: SCI PR Comment
138-
if: always() && github.event_name == 'pull_request'
140+
name: Update PR Comment
141+
if: always() && github.event_name == 'pull_request' && (startsWith(github.head_ref, 'feat/policy-smart') || startsWith(github.head_ref, 'policy-smart'))
139142
needs: [sci-1, sci-2, sci-3]
140143
runs-on: ubuntu-22.04
141144
permissions:
@@ -173,13 +176,15 @@ jobs:
173176
{ name: "SCI-3 Concurrency Race", result: process.env.SCI3_RESULT || "unknown" },
174177
];
175178
179+
const passCount = jobs.filter((j) => j.result === "success").length;
176180
const allSuccess = jobs.every((j) => j.result === "success");
177181
const summary = allSuccess ? "pass" : "not pass";
178182
const body = [
179183
marker,
180-
"## Policy Smart SCI",
184+
"## Policy Smart SCI Summary",
181185
"",
182-
`- Summary: **${summary}**`,
186+
`- Scope: \`${context.payload.pull_request.head.ref}\` -> \`${context.payload.pull_request.base.ref}\``,
187+
`- Overall: **${summary}** (${passCount}/${jobs.length} passed)`,
183188
`- Workflow run: ${process.env.RUN_URL}`,
184189
"",
185190
"### Job Status",

0 commit comments

Comments
 (0)