Skip to content

Commit 936bab2

Browse files
committed
fix(docs-infra): do not detect a running job as failed
Previously, the preview server would incorrectly identify a running `aio_preview` CI job as failed and therefore skip creating a preview. This happened because it only checked whether the job's status is `success`, failing to account for the fact that the job would have a `running` status. (This bug was accidentally introduced in #45934.) This commit avoids the problem by getting rid of the job status check altogether. This check does not offer any benefit, since the CI job will always be in a `running` state (i.e. neither successfully completed nor failed).
1 parent 1a34b97 commit 936bab2

File tree

8 files changed

+2
-31
lines changed

8 files changed

+2
-31
lines changed

aio/aio-builds-setup/dockerbuild/scripts-js/lib/common/circle-ci-api.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ export interface BuildInfo {
3333
/** The job name (e.g. `'aio_preview'`). */
3434
name: string;
3535

36-
/** The job status (e.g. `'success'` or `'failed'`). */
37-
status: string;
38-
3936
/** Info about the organization which the project related to this job belongs to. */
4037
organization: {
4138
name: string;

aio/aio-builds-setup/dockerbuild/scripts-js/lib/preview-server/build-retriever.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export interface GithubInfo {
1313
pr: number;
1414
repo: string;
1515
sha: string;
16-
success: boolean;
1716
}
1817

1918
/**
@@ -42,7 +41,6 @@ export class BuildRetriever {
4241
pr: +pipelineInfo.vcs.review_id,
4342
repo: buildInfo.project.name,
4443
sha: pipelineInfo.vcs.revision,
45-
success: buildInfo.status === 'success',
4644
};
4745
return githubInfo;
4846
}

aio/aio-builds-setup/dockerbuild/scripts-js/lib/preview-server/preview-server-factory.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,7 @@ export class PreviewServerFactory {
120120
return;
121121
}
122122

123-
const { pr, sha, org, repo, success } = await buildRetriever.getGithubInfo(buildNum);
124-
125-
if (!success) {
126-
res.sendStatus(204);
127-
logger.log(`PR:${pr}, Build:${buildNum} - Skipping preview processing because this build did not succeed.`);
128-
return;
129-
}
123+
const { pr, sha, org, repo } = await buildRetriever.getGithubInfo(buildNum);
130124

131125
assert(cfg.githubOrg === org,
132126
`Invalid webhook: expected "githubOrg" property to equal "${cfg.githubOrg}" but got "${org}".`);

aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export const enum BuildNums {
22
BUILD_INFO_ERROR = 1,
33
BUILD_INFO_404,
4-
BUILD_INFO_BUILD_FAILED,
54
BUILD_INFO_INVALID_GH_ORG,
65
BUILD_INFO_INVALID_GH_REPO,
76
PIPELINE_INFO_ERROR,

aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/mock-external-apis.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const UNTRUSTED_USER = 'untrusted-user';
3131

3232
const BASIC_BUILD_INFO = {
3333
name: 'test_job',
34-
status: 'success',
3534
organization: {name: AIO_GITHUB_ORGANIZATION},
3635
project: {name: AIO_GITHUB_REPO},
3736
pipeline: {id: PipelineIds.PIPELINE_INFO_OK},
@@ -114,7 +113,6 @@ circleCiApi.get(pipelineInfoUrl(PipelineIds.PIPELINE_INFO_OK)).reply(200, BASIC_
114113
// BUILD INFO errors
115114
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_ERROR)).replyWithError('BUILD_INFO_ERROR');
116115
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_404)).reply(404, 'BUILD_INFO_404');
117-
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_BUILD_FAILED)).reply(200, { ...BASIC_BUILD_INFO, status: 'failed' });
118116
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_INVALID_GH_ORG)).reply(200, { ...BASIC_BUILD_INFO, organization: { name: 'bad' } });
119117
circleCiApi.get(buildInfoUrl(BuildNums.BUILD_INFO_INVALID_GH_REPO)).reply(200, { ...BASIC_BUILD_INFO, project: { name: 'bad' } });
120118

aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/preview-server.e2e.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ describe('preview-server', () => {
152152
await curl(payload(BuildNums.PIPELINE_INFO_404)).then(h.verifyResponse(500));
153153
});
154154

155-
it('should respond with 204 if the build on CircleCI failed', async () => {
156-
await curl(payload(BuildNums.BUILD_INFO_BUILD_FAILED)).then(h.verifyResponse(204));
157-
});
158-
159155
it('should respond with 500 if the github org from CircleCI does not match what is configured', async () => {
160156
await curl(payload(BuildNums.BUILD_INFO_INVALID_GH_ORG)).then(h.verifyResponse(500));
161157
});

aio/aio-builds-setup/dockerbuild/scripts-js/test/preview-server/build-retriever.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ describe('BuildRetriever', () => {
2424
BUILD_INFO = {
2525
number: 12345,
2626
name: 'test_job',
27-
status: 'success',
2827
organization: {name: 'ORG'},
2928
project: {name: 'REPO'},
3029
pipeline: {id: 'test_pipeline'},
@@ -77,7 +76,7 @@ describe('BuildRetriever', () => {
7776
const info = await retriever.getGithubInfo(12345);
7877
expect(api.getBuildInfo).toHaveBeenCalledWith(12345);
7978
expect(api.getPipelineInfo).toHaveBeenCalledWith('test_pipeline');
80-
expect(info).toEqual({org: 'ORG', pr: 777, repo: 'REPO', sha: 'COMMIT', success: true});
79+
expect(info).toEqual({org: 'ORG', pr: 777, repo: 'REPO', sha: 'COMMIT'});
8180
});
8281
});
8382

aio/aio-builds-setup/dockerbuild/scripts-js/test/preview-server/preview-server-factory.spec.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ describe('PreviewServerFactory', () => {
410410
pr: PR,
411411
repo: defaultConfig.githubRepo,
412412
sha: SHA,
413-
success: true,
414413
};
415414
BASIC_PAYLOAD = { payload: { build_num: BUILD_NUM, build_parameters: { CIRCLE_JOB: 'aio_preview' } } };
416415
AFFECTS_SIGNIFICANT_FILES = true;
@@ -481,15 +480,6 @@ describe('PreviewServerFactory', () => {
481480
await agent.post(URL).send(BASIC_PAYLOAD).expect(202);
482481
});
483482

484-
it('should not create a preview if the build was not successful', async () => {
485-
BUILD_INFO.success = false;
486-
await agent.post(URL).send(BASIC_PAYLOAD).expect(204);
487-
expect(getGithubInfoSpy).toHaveBeenCalledWith(BUILD_NUM);
488-
expect(downloadBuildArtifactSpy).not.toHaveBeenCalled();
489-
expect(getPrIsTrustedSpy).not.toHaveBeenCalled();
490-
expect(createBuildSpy).not.toHaveBeenCalled();
491-
});
492-
493483
it('should fail if the CircleCI request fails', async () => {
494484
// Note it is important to put the `reject` into `and.callFake`;
495485
// If you just `and.returnValue` the rejected promise

0 commit comments

Comments
 (0)