From cb887f18822b739b3cfcb853406479a1a1942d16 Mon Sep 17 00:00:00 2001 From: Cody Kaup Date: Fri, 27 Sep 2024 15:41:47 -0500 Subject: [PATCH] Include storybookUrl and webUrl on skipped rebuild --- node-src/tasks/gitInfo.test.ts | 17 +++++++++++++++++ node-src/tasks/gitInfo.ts | 6 ++++++ node-src/types.ts | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/node-src/tasks/gitInfo.test.ts b/node-src/tasks/gitInfo.test.ts index 3fc736347..cab1e6d96 100644 --- a/node-src/tasks/gitInfo.test.ts +++ b/node-src/tasks/gitInfo.test.ts @@ -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); + }); }); diff --git a/node-src/tasks/gitInfo.ts b/node-src/tasks/gitInfo.ts index b3e1586b0..7fc553692 100644 --- a/node-src/tasks/gitInfo.ts +++ b/node-src/tasks/gitInfo.ts @@ -38,6 +38,8 @@ const LastBuildQuery = ` lastBuild(ref: $commit, branch: $branch) { id status(legacy: false) + storybookUrl + webUrl } } } @@ -48,6 +50,8 @@ interface LastBuildQueryResult { lastBuild: { id: string; status: string; + storybookUrl: string; + webUrl: string; }; }; } @@ -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; diff --git a/node-src/types.ts b/node-src/types.ts index dc6af7740..32931e590 100644 --- a/node-src/types.ts +++ b/node-src/types.ts @@ -307,6 +307,12 @@ export interface Context { }; }[]; }; + rebuildForBuild: { + id: string; + status: string; + webUrl: string; + storybookUrl: string; + }; sourceDir: string; buildCommand?: string; buildLogFile?: string;