Skip to content

Commit 647f7e2

Browse files
committed
fix(ci): pass project name to downloadReportArtifact
1 parent 61d49ea commit 647f7e2

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

packages/ci/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ This will additionally compare reports from both source and target branches and
7474
The PR flow requires interacting with the Git provider's API to post a comparison comment.
7575
Wrap these requests in functions and pass them in as an object which configures the provider.
7676

77-
| Property | Required | Type | Description |
78-
| :----------------------- | :------: | :----------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------- |
79-
| `createComment` | yes | `(body: string) => Promise<Comment>` | Posts a new comment to PR |
80-
| `updateComment` | yes | `(id: number, body: string) => Promise<Comment>` | Updates existing PR comment |
81-
| `listComments` | yes | `() => Promise<Comment[]>` | Fetches all comments from PR |
82-
| `maxCommentChars` | yes | `number` | Character limit for comment body |
83-
| `downloadReportArtifact` | no | `() => Promise<string \| null>` | Fetches previous report for base branch (returns path to downloaded `report.json`), used as cache to speed up comparison |
77+
| Property | Required | Type | Description |
78+
| :----------------------- | :------: | :----------------------------------------------- | :------------------------------------------------------------------------------------------------------------------- |
79+
| `createComment` | yes | `(body: string) => Promise<Comment>` | Posts a new comment to PR |
80+
| `updateComment` | yes | `(id: number, body: string) => Promise<Comment>` | Updates existing PR comment |
81+
| `listComments` | yes | `() => Promise<Comment[]>` | Fetches all comments from PR |
82+
| `maxCommentChars` | yes | `number` | Character limit for comment body |
83+
| `downloadReportArtifact` | no | `(project?: string) => Promise<string \| null>` | Fetches previous (root/project) `report.json` for base branch and returns path, used as cache to speed up comparison |
8484

8585
A `Comment` object has the following required properties:
8686

packages/ci/src/lib/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export type GitRefs = {
3737
*/
3838
export type ProviderAPIClient = {
3939
maxCommentChars: number;
40-
downloadReportArtifact?: () => Promise<string | null>;
40+
downloadReportArtifact?: (project?: string) => Promise<string | null>;
4141
listComments: () => Promise<Comment[]>;
4242
updateComment: (id: number, body: string) => Promise<Comment>;
4343
createComment: (body: string) => Promise<Comment>;

packages/ci/src/lib/run.integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ describe('runInCI', () => {
328328
expect.stringContaining(diffMdString),
329329
);
330330
expect(api.createComment).not.toHaveBeenCalled();
331-
expect(api.downloadReportArtifact).toHaveBeenCalledWith();
331+
expect(api.downloadReportArtifact).toHaveBeenCalledWith(undefined);
332332

333333
expect(utils.executeProcess).toHaveBeenCalledTimes(2);
334334
expect(utils.executeProcess).toHaveBeenNthCalledWith(1, {

packages/ci/src/lib/run.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,17 @@ async function runOnProject(args: {
189189
}
190190

191191
async function collectPreviousReport(args: {
192+
project: ProjectConfig | null;
192193
base: GitBranch;
193194
api: ProviderAPIClient;
194195
settings: Settings;
195196
ctx: CommandContext;
196197
git: SimpleGit;
197198
}): Promise<string | null> {
198-
const { base, api, settings, ctx, git } = args;
199+
const { project, base, api, settings, ctx, git } = args;
199200
const logger = settings.logger;
200201

201-
const cachedBaseReport = await api.downloadReportArtifact?.();
202+
const cachedBaseReport = await api.downloadReportArtifact?.(project?.name);
202203
if (api.downloadReportArtifact != null) {
203204
logger.info(
204205
`Previous report artifact ${cachedBaseReport ? 'found' : 'not found'}`,

0 commit comments

Comments
 (0)