Skip to content

Commit d696f19

Browse files
committed
Compatibility: Fail the build if the Github API fails to get progress
1 parent ece5713 commit d696f19

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

src/app/compatibility/page.tsx

+27-26
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ export default async function Downloads() {
1818
});
1919
const avm1ApiDone = await getAVM1Progress();
2020
const report = await fetchReport();
21-
const summary = report ? report.summary : undefined;
22-
const maxPoints = summary ? summary.max_points : NaN;
23-
const implPoints = summary ? summary.impl_points : NaN;
24-
const stubPenalty = summary ? summary.stub_penalty : NaN;
21+
if (!report) {
22+
return;
23+
}
24+
const summary = report.summary;
25+
const maxPoints = summary.max_points;
26+
const implPoints = summary.impl_points;
27+
const stubPenalty = summary.stub_penalty;
2528
const avm2ApiDone = Math.round((implPoints - stubPenalty) / maxPoints * 100);
2629
const avm2ApiStubbed = Math.round(stubPenalty / maxPoints * 100);
2730

@@ -92,28 +95,26 @@ export default async function Downloads() {
9295
</Text>
9396
</AvmBlock>
9497

95-
{!Number.isNaN(avm2ApiDone) && !Number.isNaN(avm2ApiStubbed) && (
96-
<AvmBlock
97-
name="AVM 2: ActionScript 3"
98-
language={{ done: 75 }}
99-
api={{ done: avm2ApiDone, stubbed: avm2ApiStubbed }}
100-
info_link="/compatibility/avm2"
101-
>
102-
<Text>
103-
AVM 2 was introduced with Flash Player 9 (June 2006), to replace
104-
the earlier AVM 1. After the release of Flash Professional CC
105-
(2013), authors are required to use ActionScript 3 - making any
106-
movie made after that date very likely to fall under this
107-
category.
108-
</Text>
109-
<Text>
110-
Ruffle now has decent support for AVM 2, and it&apos;s our
111-
experience that most games will work well enough to be played.
112-
We&apos;re still rapidly improving in this area though, so bug
113-
reports about any broken content are always welcome!
114-
</Text>
115-
</AvmBlock>
116-
)}
98+
<AvmBlock
99+
name="AVM 2: ActionScript 3"
100+
language={{ done: 75 }}
101+
api={{ done: avm2ApiDone, stubbed: avm2ApiStubbed }}
102+
info_link="/compatibility/avm2"
103+
>
104+
<Text>
105+
AVM 2 was introduced with Flash Player 9 (June 2006), to replace
106+
the earlier AVM 1. After the release of Flash Professional CC
107+
(2013), authors are required to use ActionScript 3 - making any
108+
movie made after that date very likely to fall under this
109+
category.
110+
</Text>
111+
<Text>
112+
Ruffle now has decent support for AVM 2, and it&apos;s our
113+
experience that most games will work well enough to be played.
114+
We&apos;re still rapidly improving in this area though, so bug
115+
reports about any broken content are always welcome!
116+
</Text>
117+
</AvmBlock>
117118
</Flex>
118119

119120
<Stack w="100%" align="center">

src/app/downloads/github.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ function createGithubAuth() {
2121
}
2222
}
2323

24+
function throwBuildError() {
25+
throw new Error("Build failed");
26+
}
27+
2428
export async function getLatestReleases(): Promise<GithubRelease[]> {
2529
const octokit = new Octokit({ authStrategy: createGithubAuth });
2630
try {
@@ -70,6 +74,7 @@ export async function fetchReport(): Promise<AVM2Report | undefined> {
7074
const releases = await getLatestReleases();
7175
const latest = releases.find(release => release.avm2_report_asset_id !== undefined);
7276
if (!latest?.avm2_report_asset_id) {
77+
throwBuildError();
7378
return;
7479
}
7580
const octokit = new Octokit({ authStrategy: createGithubAuth });
@@ -112,6 +117,6 @@ export async function getAVM1Progress(): Promise<number> {
112117
totalItems += topLevelRoot.querySelectorAll("input.task-list-item-checkbox").length;
113118
completedItems += topLevelRoot.querySelectorAll("input.task-list-item-checkbox:checked").length;
114119
}
115-
if (totalItems < 3348) return 75;
120+
if (totalItems < 3348) throwBuildError();
116121
return Math.round(completedItems/totalItems*100);
117122
}

0 commit comments

Comments
 (0)