diff --git a/.github/workflows/readme-progress.yml b/.github/workflows/readme-progress.yml index 70a1583e..21abb654 100644 --- a/.github/workflows/readme-progress.yml +++ b/.github/workflows/readme-progress.yml @@ -2,8 +2,8 @@ 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. -# README progress is written inside each landing commit by the orchestrator, so this job never commits; -# it only rebuilds and publishes the current numbers to the job summary. +# it never commits to main: it rebuilds, publishes the numbers to the job summary, and force-pushes +# the README badge JSON as a single commit on the orphan progress-data branch. on: push: branches: [main] @@ -17,7 +17,7 @@ concurrency: cancel-in-progress: true permissions: - contents: read + contents: write jobs: progress: @@ -55,3 +55,17 @@ jobs: python3 tools/update_readme_progress.py build/43U/report.json README.md "$GITHUB_SHA" sed -n '/progress:start/,/progress:end/p' README.md >> "$GITHUB_STEP_SUMMARY" git checkout -- README.md + + - name: Publish badges + if: github.ref == 'refs/heads/main' + run: | + out="$RUNNER_TEMP/progress-data" + rm -rf "$out" + python3 tools/progress_badges.py build/43U/report.json "$out" + cd "$out" + git init -q -b progress-data + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add . + git commit -q -m "progress for $GITHUB_SHA" + git push -q -f "https://x-access-token:${{ github.token }}@github.com/$GITHUB_REPOSITORY.git" HEAD:refs/heads/progress-data diff --git a/README.md b/README.md index 50ad0451..076a5ffe 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,23 @@ -[Build Status]: https://github.com/coah80/wii-ipl/actions/workflows/build.yml/badge.svg -[actions]: https://github.com/coah80/wii-ipl/actions/workflows/build.yml +[Build Status]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml/badge.svg?branch=main +[actions]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml [Discord Badge]: https://img.shields.io/discord/727908905392275526?color=%237289DA&logo=discord&logoColor=%23FFFFFF [discord]: https://discord.gg/hKx3FJJgrV - + -[V43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U - - - -[DecompBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=code&label=Decompiled&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic -[LinkBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=complete_code&label=Linked&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic -[FuncBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=functions&label=Functions&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic +[progress]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml +[DecompiledBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fdecompiled.json +[MatchedBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fmatched.json +[LinkedBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Flinked.json +[DataBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fdata.json +[FunctionsBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Ffunctions.json +[UnitsBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Funits.json @@ -43,28 +43,17 @@ Live decomp status [![Build status]][actions] -Open the latest successful [Build workflow run][actions] and check its summary for the current objdiff metrics. It includes perfect-match/decompiled, fuzzy-match, fully linked, data, function, unit, and category breakdowns. The run also publishes the 43U report artifact and generated decomp-status report. +Every push to `main` rebuilds 4.3U, checks the DOL hash, and refreshes the progress badges below. Open the latest [README progress run][actions] for the full objdiff summary. Supported versions: - `43U` - Version **4.3U** (USA) Progress ======== - -| Decompiled | Matched | Linked | Data | -|:---:|:---:|:---:|:---:| -| 99.59% | 91.16% | 74.57% | 99.56% | - -units 964/1027 complete, functions 12378/12563 matched. +[![DecompiledBadge]][progress] [![MatchedBadge]][progress] [![LinkedBadge]][progress] [![DataBadge]][progress] +[![FunctionsBadge]][progress] [![UnitsBadge]][progress] decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data - - -| Version | Progress | -|-----------------------|------------------------------------------------------------------------------| -| [Wii Menu 4.3U][V43U] | [![FuncBadgeV43U]][V43U] [![DecompBadgeV43U]][V43U] [![LinkBadgeV43U]][V43U] | - -> You can see the full progress and its history by clicking on one of the versions in the table. Dependencies ============ diff --git a/tools/progress_badges.py b/tools/progress_badges.py new file mode 100644 index 00000000..9eba9cfe --- /dev/null +++ b/tools/progress_badges.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +"""Write shields.io endpoint JSON files from an objdiff report. + +usage: progress_badges.py + +The README badges read these files from the progress-data branch, so the +numbers update without committing to main. +""" +import json +import os +import sys + +COLOR = "33b8ff" +DONE_COLOR = "brightgreen" + + +def badge(label, message, done): + return { + "schemaVersion": 1, + "label": label, + "message": message, + "color": DONE_COLOR if done else COLOR, + "labelColor": "7c7c7c", + "style": "plastic", + } + + +def percent(measures, key): + value = float(measures.get(key) or 0.0) + return f"{value:.2f}%", value >= 100.0 + + +def count(measures, done_key, total_key): + done = int(measures.get(done_key) or 0) + total = int(measures.get(total_key) or 0) + return f"{done:,} / {total:,}", total > 0 and done == total + + +def main(): + if len(sys.argv) != 3: + raise SystemExit(__doc__) + report_path, out_dir = sys.argv[1], sys.argv[2] + measures = json.load(open(report_path))["measures"] + + badges = { + "decompiled": ("Decompiled", percent(measures, "fuzzy_match_percent")), + "matched": ("Matched", percent(measures, "matched_code_percent")), + "linked": ("Linked", percent(measures, "complete_code_percent")), + "data": ("Data", percent(measures, "matched_data_percent")), + "functions": ("Functions", count(measures, "matched_functions", "total_functions")), + "units": ("Units", count(measures, "complete_units", "total_units")), + } + + os.makedirs(out_dir, exist_ok=True) + for name, (label, (message, done)) in badges.items(): + with open(os.path.join(out_dir, f"{name}.json"), "w", encoding="utf-8") as f: + json.dump(badge(label, message, done), f) + f.write("\n") + print(f"{label}: {message}") + + +if __name__ == "__main__": + main()