Skip to content

Commit 39640b4

Browse files
authored
feat(gb-test-runner): publish ROM reports from JSON status (#257)
1 parent af81773 commit 39640b4

20 files changed

Lines changed: 1099 additions & 270 deletions

File tree

.github/workflows/rom-reports-pages.yml

Lines changed: 56 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,27 @@ jobs:
3232
id: reports
3333
run: |
3434
set -euo pipefail
35-
reports_json='["gb-emulator-shootout","rtc3test","gbmicrotest","little-things-gb","magen","mealybug-tearoom-tests","mooneye","samesuite"]'
35+
reports_path="crates/gb-test-runner/data/rom-reports-pages.json"
36+
jq -e 'type == "array" and all(.[]; (.name | type == "string") and ((has("boot_roms") | not) or (.boot_roms | type == "boolean")))' "${reports_path}" >/dev/null
37+
reports_json="$(jq -c . "${reports_path}")"
3638
echo "reports_json=${reports_json}" >> "${GITHUB_OUTPUT}"
3739
38-
- name: Build ROM report runner
39-
run: cargo build --release -p gb-test-runner --bin report
40+
- name: Build ROM report runners
41+
run: cargo build --release -p gb-test-runner --bin report --bin fetch
4042

41-
- name: Upload ROM report runner
43+
- name: Upload ROM report runners
4244
uses: actions/upload-artifact@v7
4345
with:
44-
name: rom-report-runner
45-
path: target/release/report
46+
name: rom-report-runners
47+
path: |
48+
target/release/report
49+
target/release/fetch
4650
if-no-files-found: error
4751
retention-days: 1
4852

4953
render-report:
5054
needs: build-runner
51-
name: render ${{ matrix.report }}
55+
name: render ${{ matrix.report.name }}
5256
runs-on: ubuntu-latest
5357

5458
strategy:
@@ -60,13 +64,13 @@ jobs:
6064
- name: Checkout
6165
uses: actions/checkout@v6
6266

63-
- name: Download ROM report runner
67+
- name: Download ROM report runners
6468
uses: actions/download-artifact@v8
6569
with:
66-
name: rom-report-runner
70+
name: rom-report-runners
6771
path: .bin
6872

69-
- name: Generate ${{ matrix.report }} HTML report
73+
- name: Generate ${{ matrix.report.name }} HTML report
7074
run: |
7175
set -euo pipefail
7276
@@ -76,23 +80,44 @@ jobs:
7680
exit 1
7781
fi
7882
chmod +x "${report_runner}"
79-
"${report_runner}" "${{ matrix.report }}" --html
83+
report_args=("${{ matrix.report.name }}" "--html")
8084
81-
report_html="test/${{ matrix.report }}/test-report.html"
85+
if [[ "${{ matrix.report.boot_roms == true }}" == "true" ]]; then
86+
fetch_runner="$(find .bin -type f -name fetch -print -quit)"
87+
if [[ -z "${fetch_runner}" ]]; then
88+
echo "missing downloaded ROM fetch runner" >&2
89+
exit 1
90+
fi
91+
chmod +x "${fetch_runner}"
92+
BOOT_ROM_DIR="${RUNNER_TEMP}/boot-rom"
93+
"${fetch_runner}" --boot-rom "${BOOT_ROM_DIR}"
94+
report_args+=("--boot-rom-dir" "${BOOT_ROM_DIR}")
95+
fi
96+
97+
"${report_runner}" "${report_args[@]}"
98+
99+
status_dir="test/${{ matrix.report.name }}/.status"
100+
report_html="${status_dir}/index.html"
82101
if [[ ! -f "${report_html}" ]]; then
83102
echo "missing generated report HTML: ${report_html}" >&2
84103
exit 1
85104
fi
105+
report_summary="${status_dir}/summary.json"
106+
if [[ ! -f "${report_summary}" ]]; then
107+
echo "missing generated report summary: ${report_summary}" >&2
108+
exit 1
109+
fi
86110
87-
report_site_dir="page/reports/${{ matrix.report }}"
88-
mkdir -p "${report_site_dir}"
89-
cp "${report_html}" "${report_site_dir}/index.html"
111+
artifact_root="status-artifact/test/${{ matrix.report.name }}"
112+
mkdir -p "${artifact_root}"
113+
cp -a "${status_dir}" "${artifact_root}/.status"
90114
91-
- name: Upload ${{ matrix.report }} page
115+
- name: Upload ${{ matrix.report.name }} status
92116
uses: actions/upload-artifact@v7
93117
with:
94-
name: rom-report-page-${{ matrix.report }}
95-
path: page
118+
name: rom-report-status-${{ matrix.report.name }}
119+
path: status-artifact
120+
include-hidden-files: true
96121
if-no-files-found: error
97122
retention-days: 1
98123

@@ -103,53 +128,26 @@ jobs:
103128
runs-on: ubuntu-latest
104129

105130
steps:
106-
- name: Download report pages
131+
- name: Checkout
132+
uses: actions/checkout@v6
133+
134+
- name: Setup Rust
135+
uses: actions-rust-lang/setup-rust-toolchain@v1
136+
137+
- name: Cache Rust artifacts
138+
uses: Swatinem/rust-cache@v2
139+
140+
- name: Download report status
107141
uses: actions/download-artifact@v8
108142
with:
109-
pattern: rom-report-page-*
110-
path: _site
143+
pattern: rom-report-status-*
144+
path: .
111145
merge-multiple: true
112146

113147
- name: Generate site index
114-
env:
115-
REPORTS_JSON: ${{ needs.build-runner.outputs.reports_json }}
116148
run: |
117149
set -euo pipefail
118-
119-
generated_at="$(date -u +'%Y-%m-%d %H:%M:%S UTC')"
120-
short_sha="${GITHUB_SHA::12}"
121-
122-
cat > _site/index.html <<HTML
123-
<!doctype html>
124-
<html lang="en">
125-
<head>
126-
<meta charset="utf-8">
127-
<meta name="viewport" content="width=device-width, initial-scale=1">
128-
<title>gb-cycle ROM reports</title>
129-
<style>body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 2rem; color: #111; } a { color: #0645ad; } .meta { color: #555; }</style>
130-
</head>
131-
<body>
132-
<h1>gb-cycle ROM reports</h1>
133-
<p class="meta">Generated at ${generated_at} from commit <code>${short_sha}</code>.</p>
134-
<ul>
135-
HTML
136-
137-
while IFS= read -r report; do
138-
report_html="_site/reports/${report}/index.html"
139-
if [[ ! -f "${report_html}" ]]; then
140-
echo "missing downloaded report page: ${report_html}" >&2
141-
exit 1
142-
fi
143-
cat >> _site/index.html <<HTML
144-
<li><a href="reports/${report}/">${report}</a></li>
145-
HTML
146-
done < <(jq -r '.[]' <<<"${REPORTS_JSON}")
147-
148-
cat >> _site/index.html <<HTML
149-
</ul>
150-
</body>
151-
</html>
152-
HTML
150+
cargo rom-report --index _site
153151
154152
- name: Configure Pages
155153
uses: actions/configure-pages@v6

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/gb-test-runner/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ rust-version = "1.96"
66
license = "MIT OR Apache-2.0"
77

88
[dependencies]
9+
askama = "0.16.0"
910
gb-core = { version = "0.2.1", path = "../gb-core" }
1011
png = "0.18"
1112
rayon = "1.10"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{ "name": "gb-emulator-shootout" },
3+
{ "name": "blargg" },
4+
{ "name": "mooneye" },
5+
{ "name": "wilbertpol" },
6+
{ "name": "gbmicrotest", "boot_roms": true },
7+
{ "name": "mealybug-tearoom-tests" },
8+
{ "name": "samesuite" },
9+
{ "name": "rtc3test" },
10+
{ "name": "nitro2k01", "boot_roms": true },
11+
{ "name": "little-things-gb" },
12+
{ "name": "magen" }
13+
]

crates/gb-test-runner/src/fetch/test/materialization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn materializes_selected_family_from_local_git_source() {
103103
);
104104
let store_root = workspace_root.join("test/sample-report");
105105
fs::create_dir_all(store_root.join(".status")).expect("status dir should be creatable");
106-
fs::write(store_root.join(".status/family-a.toml"), b"status")
106+
fs::write(store_root.join(".status/family-a.json"), b"status")
107107
.expect("status should be writable");
108108
fs::create_dir_all(store_root.join("family-a")).expect("family root should be creatable");
109109
fs::write(store_root.join("family-a/stale.gb"), b"stale")
@@ -122,7 +122,7 @@ fn materializes_selected_family_from_local_git_source() {
122122
"selected family root should be replaced"
123123
);
124124
assert_eq!(
125-
fs::read(store_root.join(".status/family-a.toml")).expect("status should be preserved"),
125+
fs::read(store_root.join(".status/family-a.json")).expect("status should be preserved"),
126126
b"status"
127127
);
128128
let output = String::from_utf8(output).expect("output should be utf-8");

0 commit comments

Comments
 (0)