-
Notifications
You must be signed in to change notification settings - Fork 0
fix(ci): publish scheduled benchmark via unprotected data branch #8
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,23 @@ | ||
| name: Benchmark | ||
|
|
||
| # The benchmark is deterministic and reproducible. This workflow re-verifies it | ||
| # weekly (and on demand), refreshes the published artifact, and commits the | ||
| # result back to the repo, where /api/benchmark-latest and /api/stats serve it. | ||
| # It is reproducibility verification, not synthetic daily activity. | ||
| # weekly (and on demand), refreshes the published artifact, and publishes the | ||
| # result to the unprotected `telemetry` data branch. The default branch is | ||
| # ruleset-protected and the default GITHUB_TOKEN cannot push to it, so the | ||
| # git-as-database loop lives on `telemetry`. The live stdlib endpoints | ||
| # (/api/stats, /api/benchmark-latest) read the freshest artifact from that | ||
| # branch at request time, falling back to the copy committed on main. | ||
| # | ||
| # History accumulates: the runner appends to the prior history, so we seed it | ||
| # from the telemetry branch before each run. | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 6 * * 1" # Mondays 06:00 UTC | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| contents: write # push the data files to the telemetry branch | ||
|
|
||
| jobs: | ||
| benchmark: | ||
|
|
@@ -28,6 +34,14 @@ jobs: | |
| - name: Install package | ||
| run: pip install -e . | ||
|
|
||
| - name: Seed accumulated history from telemetry branch | ||
| run: | | ||
| if git ls-remote --exit-code --heads origin telemetry >/dev/null 2>&1; then | ||
| git fetch origin telemetry --depth=1 | ||
| git show origin/telemetry:api/_benchmark_history.json \ | ||
| > api/_benchmark_history.json 2>/dev/null || true | ||
| fi | ||
|
|
||
| - name: Run benchmark | ||
| run: python -m evalops_workbench.benchmark_runner | ||
|
|
||
|
|
@@ -51,17 +65,34 @@ jobs: | |
| print(f"artifact valid; {artifact['metrics']['n_cases']} cases; age {age:.0f}s") | ||
| PY | ||
|
|
||
| - name: Commit results if changed | ||
| - name: Publish artifacts to telemetry branch | ||
| run: | | ||
| git config user.name "eleventh-bot" | ||
| git config user.email "noreply@eleventh.dev" | ||
| git add api/_benchmark_latest.json api/_benchmark_history.json \ | ||
| examples/benchmark-v1/results examples/benchmark-v1/pinned-baseline.json | ||
| if git diff --cached --quiet; then | ||
| echo "No benchmark changes to commit." | ||
| stage="$(mktemp -d)" | ||
| mkdir -p "$stage/api" "$stage/examples" | ||
| cp api/_benchmark_latest.json api/_benchmark_history.json "$stage/api/" | ||
| cp -R examples/benchmark "$stage/examples/" 2>/dev/null || true | ||
|
|
||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| if git ls-remote --exit-code --heads origin telemetry >/dev/null 2>&1; then | ||
| git fetch origin telemetry --depth=1 | ||
| git worktree add -B telemetry .telemetry origin/telemetry | ||
| else | ||
| git worktree add --orphan -b telemetry .telemetry | ||
| fi | ||
|
|
||
| mkdir -p .telemetry/api .telemetry/examples | ||
| cp "$stage/api/"* .telemetry/api/ | ||
| rm -rf .telemetry/examples/benchmark | ||
| cp -R "$stage/examples/benchmark" .telemetry/examples/ 2>/dev/null || true | ||
|
|
||
| git -C .telemetry add api examples | ||
| if git -C .telemetry diff --cached --quiet; then | ||
| echo "No benchmark changes to publish." | ||
| else | ||
| git commit -m "chore(benchmark): scheduled run [skip ci]" | ||
| git push | ||
| git -C .telemetry commit -m "telemetry: scheduled benchmark $(date -u +%Y-%m-%d)" | ||
| git -C .telemetry push origin telemetry | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The workflow still allows Useful? React with 👍 / 👎. |
||
| fi | ||
|
|
||
| - name: Live endpoint check (soft) | ||
|
|
@@ -73,5 +104,5 @@ jobs: | |
| echo "GET $url" | ||
| curl -s --max-time 30 -A "Mozilla/5.0 ci" "$url" \ | ||
| | python -c "import sys, json; d = json.load(sys.stdin); print(' ', {k: d.get(k) for k in ('system', 'mode', 'status', 'schema_version', 'benchmark_type')})" \ | ||
| || echo " (endpoint not reachable yet; redeploy may be in flight)" | ||
| || echo " (endpoint not reachable yet)" | ||
| done | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On every run after the first, telemetry contains archive files that are not present in the protected main checkout. This deletes the telemetry branch's whole benchmark directory and then replaces it with
$stage/examples/benchmark, which was copied from main plus only the current run, so previous telemetry-onlyarchive/*.jsonfiles disappear and older run URLs stop resolving. Copy the existing archive forward or replace only the latest report/current run file.Useful? React with 👍 / 👎.