Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into tom/ap-3253-update-cl…
Browse files Browse the repository at this point in the history
…i-to-be-callable-from-node-and-return-buildid
  • Loading branch information
tmeasday committed Jun 5, 2023
2 parents a206724 + 323eda5 commit 21ba085
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions action-src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ async function run() {
const untraced = getInput('untraced');
const workingDir = getInput('workingDir') || getInput('workingDirectory');
const zip = getInput('zip');
const junitReport = getInput('junitReport');

process.env.CHROMATIC_ACTION = 'true';
process.env.CHROMATIC_SHA = sha;
Expand Down Expand Up @@ -135,6 +136,7 @@ async function run() {
traceChanged: maybe(traceChanged),
untraced: maybe(untraced),
zip: maybe(zip, false),
junitReport: maybe(junitReport, false),
});

Object.entries(output).forEach(([key, value]) => setOutput(key, String(value)));
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ inputs:
zip:
description: 'Publish your Storybook to Chromatic as a single zip file instead of individual content files'
required: false
junitReport:
description: 'Write build results to a JUnit XML file.'
required: false

outputs:
code:
Expand Down
13 changes: 7 additions & 6 deletions bin-src/git/findAncestorBuildWithCommit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,22 @@ export async function findAncestorBuildWithCommit(
{ client }: Pick<Context, 'client'>,
buildNumber: number,
{ page = 10, limit = 80 } = {}
): Promise<AncestorBuildsQueryResult['app']['build']['ancestorBuilds'][0] | void> {
): Promise<AncestorBuildsQueryResult['app']['build']['ancestorBuilds'][0] | null> {
let skip = 0;
while (skip < limit) {
// eslint-disable-next-line no-await-in-loop
const { app } = (await client.runQuery(AncestorBuildsQuery, {
const { app } = await client.runQuery<AncestorBuildsQueryResult>(AncestorBuildsQuery, {
buildNumber,
skip,
limit: Math.min(page, limit - skip),
})) as AncestorBuildsQueryResult;
});

// eslint-disable-next-line no-await-in-loop
const results = await Promise.all(
app.build.ancestorBuilds.map(
async (build) => [build, await commitExists(build.commit)] as const
)
app.build.ancestorBuilds.map(async (build) => {
const exists = await commitExists(build.commit);
return [build, exists] as const;
})
);
const result = results.find(([build, exists]) => exists);

Expand Down

0 comments on commit 21ba085

Please sign in to comment.