ci: keep README progress numbers updated from the self-hosted runner #293
62
.github/workflows/readme-progress.yml
vendored
Normal file
62
.github/workflows/readme-progress.yml
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
name: README progress
|
||||
|
||||
# runs on the self-hosted runner on cole's server so it doesn't use hosted minutes.
|
||||
# only push/schedule/manual triggers, never pull_request, so fork PRs can't reach this machine.
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths-ignore: [README.md]
|
||||
schedule:
|
||||
- cron: "*/30 * * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: readme-progress
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
progress:
|
||||
runs-on: [self-hosted, wii-ipl-local]
|
||||
timeout-minutes: 60
|
||||
env:
|
||||
ORIG_APP: /mnt/drive2/projects/wiichannels/wii-ipl/orig/43U/00000008.app
|
||||
TOOL_CACHE: /mnt/drive2/projects/wiichannels/wii-ipl/build
|
||||
NINJA: /home/cole/projects/tests/.venv/bin/ninja
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: main
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
mkdir -p build orig/43U
|
||||
cp "$ORIG_APP" orig/43U/00000008.app
|
||||
[ -d build/compilers ] || cp -a "$TOOL_CACHE/compilers" build/
|
||||
[ -d build/tools ] || cp -a "$TOOL_CACHE/tools" build/
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
python3 configure.py --version 43U
|
||||
"$NINJA"
|
||||
"$NINJA" build/43U/ok
|
||||
|
||||
- name: Report
|
||||
run: build/tools/objdiff-cli report generate -p . -o build/43U/report.json -f json
|
||||
|
||||
- name: Update README
|
||||
run: python3 tools/update_readme_progress.py build/43U/report.json README.md "$GITHUB_SHA"
|
||||
|
||||
- name: Commit
|
||||
run: |
|
||||
if git diff --quiet README.md; then exit 0; fi
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add README.md
|
||||
git commit -m "docs: update progress [skip ci]"
|
||||
git pull --rebase origin main || { git rebase --abort; echo "main moved, next run will update"; exit 0; }
|
||||
git push origin HEAD:main
|
||||
10
README.md
10
README.md
@@ -50,6 +50,16 @@ Supported versions:
|
||||
|
||||
Progress
|
||||
========
|
||||
<!-- progress:start -->
|
||||
| Decompiled | Matched | Linked | Data |
|
||||
|:---:|:---:|:---:|:---:|
|
||||
| 80.98% | 72.11% | 56.76% | 86.16% |
|
||||
|
||||
units 748/1027 complete, functions 10570/12563 matched. updated 2026-09-29 22:58 UTC from `test` by the self-hosted progress job
|
||||
|
||||
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
|
||||
<!-- progress:end -->
|
||||
|
||||
| Version | Progress |
|
||||
|-----------------------|------------------------------------------------------------------------------|
|
||||
| [Wii Menu 4.3U][V43U] | [![FuncBadgeV43U]][V43U] [![DecompBadgeV43U]][V43U] [![LinkBadgeV43U]][V43U] |
|
||||
|
||||
59
tools/update_readme_progress.py
Normal file
59
tools/update_readme_progress.py
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Rewrite the progress block in README.md from an objdiff report.
|
||||
|
||||
usage: update_readme_progress.py <report.json> <README.md> [commit]
|
||||
"""
|
||||
import datetime
|
||||
import json
|
||||
import sys
|
||||
|
||||
START = "<!-- progress:start -->"
|
||||
END = "<!-- progress:end -->"
|
||||
|
||||
|
||||
def pct(measures, key):
|
||||
return float(measures.get(key) or 0.0)
|
||||
|
||||
|
||||
def main():
|
||||
report_path, readme_path = sys.argv[1], sys.argv[2]
|
||||
commit = sys.argv[3][:8] if len(sys.argv) > 3 else ""
|
||||
m = json.load(open(report_path))["measures"]
|
||||
|
||||
stamp = datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
|
||||
block = "\n".join([
|
||||
START,
|
||||
"| Decompiled | Matched | Linked | Data |",
|
||||
"|:---:|:---:|:---:|:---:|",
|
||||
f"| {pct(m, 'fuzzy_match_percent'):.2f}% | {pct(m, 'matched_code_percent'):.2f}% "
|
||||
f"| {pct(m, 'complete_code_percent'):.2f}% | {pct(m, 'matched_data_percent'):.2f}% |",
|
||||
"",
|
||||
f"units {m.get('complete_units')}/{m.get('total_units')} complete, "
|
||||
f"functions {m.get('matched_functions')}/{m.get('total_functions')} matched. "
|
||||
f"updated {stamp}" + (f" from `{commit}`" if commit else "") + " by the self-hosted progress job",
|
||||
"",
|
||||
"decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, "
|
||||
"linked = code actually linked into the DOL, data = byte-exact data",
|
||||
END,
|
||||
])
|
||||
|
||||
text = open(readme_path, encoding="utf-8").read()
|
||||
if START in text and END in text:
|
||||
head, rest = text.split(START, 1)
|
||||
_, tail = rest.split(END, 1)
|
||||
new = head + block + tail
|
||||
else:
|
||||
anchor = "Progress\n========\n"
|
||||
if anchor not in text:
|
||||
raise SystemExit("no progress anchor in README")
|
||||
new = text.replace(anchor, anchor + block + "\n\n", 1)
|
||||
|
||||
if new != text:
|
||||
open(readme_path, "w", encoding="utf-8").write(new)
|
||||
print("README progress updated")
|
||||
else:
|
||||
print("README progress unchanged")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user