Skip to content

Commit

Permalink
Include storybookUrl and webUrl on skipped rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
codykaup committed Sep 27, 2024
1 parent 38a7b49 commit cb887f1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions node-src/tasks/gitInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,21 @@ describe('setGitInfo', () => {
await setGitInfo(ctx, {} as any);
expect(ctx.options.forceRebuild).toBe(true);
});

it('sets storybookUrl and rebuildForBuild on skipped rebuild', async () => {
const lastBuild = {
id: 'parent',
status: 'ACCEPTED',
webUrl: 'some-web-url',
storybookUrl: 'some-storybook-url',
};

getParentCommits.mockResolvedValue([commitInfo.commit]);
client.runQuery.mockReturnValue({ app: { lastBuild } });

const ctx = { log, options: {}, client } as any;
await setGitInfo(ctx, {} as any);
expect(ctx.rebuildForBuild).toEqual(lastBuild);
expect(ctx.storybookUrl).toEqual(lastBuild.storybookUrl);
});
});
6 changes: 6 additions & 0 deletions node-src/tasks/gitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const LastBuildQuery = `
lastBuild(ref: $commit, branch: $branch) {
id
status(legacy: false)
storybookUrl
webUrl
}
}
}
Expand All @@ -48,6 +50,8 @@ interface LastBuildQueryResult {
lastBuild: {
id: string;
status: string;
storybookUrl: string;
webUrl: string;
};
};
}
Expand Down Expand Up @@ -141,6 +145,8 @@ export const setGitInfo = async (ctx: Context, task: Task) => {
!ctx.git.matchesBranch(ctx.options.forceRebuild)
) {
ctx.skip = true;
ctx.rebuildForBuild = result.app.lastBuild;
ctx.storybookUrl = result.app.lastBuild.storybookUrl;
transitionTo(skippedRebuild, true)(ctx, task);
ctx.log.info(forceRebuildHint());
ctx.exitCode = 0;
Expand Down
6 changes: 6 additions & 0 deletions node-src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ export interface Context {
};
}[];
};
rebuildForBuild: {
id: string;
status: string;
webUrl: string;
storybookUrl: string;
};
sourceDir: string;
buildCommand?: string;
buildLogFile?: string;
Expand Down

0 comments on commit cb887f1

Please sign in to comment.