Skip to content

Commit

Permalink
Compatibility: Fail the build if the Github API fails to get progress
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhjacobs committed Feb 16, 2024
1 parent ece5713 commit d696f19
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
53 changes: 27 additions & 26 deletions src/app/compatibility/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ export default async function Downloads() {
});
const avm1ApiDone = await getAVM1Progress();
const report = await fetchReport();
const summary = report ? report.summary : undefined;
const maxPoints = summary ? summary.max_points : NaN;
const implPoints = summary ? summary.impl_points : NaN;
const stubPenalty = summary ? summary.stub_penalty : NaN;
if (!report) {
return;
}
const summary = report.summary;
const maxPoints = summary.max_points;
const implPoints = summary.impl_points;
const stubPenalty = summary.stub_penalty;
const avm2ApiDone = Math.round((implPoints - stubPenalty) / maxPoints * 100);
const avm2ApiStubbed = Math.round(stubPenalty / maxPoints * 100);

Expand Down Expand Up @@ -92,28 +95,26 @@ export default async function Downloads() {
</Text>
</AvmBlock>

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

<Stack w="100%" align="center">
Expand Down
7 changes: 6 additions & 1 deletion src/app/downloads/github.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ function createGithubAuth() {
}
}

function throwBuildError() {
throw new Error("Build failed");
}

export async function getLatestReleases(): Promise<GithubRelease[]> {
const octokit = new Octokit({ authStrategy: createGithubAuth });
try {
Expand Down Expand Up @@ -70,6 +74,7 @@ export async function fetchReport(): Promise<AVM2Report | undefined> {
const releases = await getLatestReleases();
const latest = releases.find(release => release.avm2_report_asset_id !== undefined);
if (!latest?.avm2_report_asset_id) {
throwBuildError();
return;
}
const octokit = new Octokit({ authStrategy: createGithubAuth });
Expand Down Expand Up @@ -112,6 +117,6 @@ export async function getAVM1Progress(): Promise<number> {
totalItems += topLevelRoot.querySelectorAll("input.task-list-item-checkbox").length;
completedItems += topLevelRoot.querySelectorAll("input.task-list-item-checkbox:checked").length;
}
if (totalItems < 3348) return 75;
if (totalItems < 3348) throwBuildError();
return Math.round(completedItems/totalItems*100);
}

0 comments on commit d696f19

Please sign in to comment.