Skip to content

Commit a5a8942

Browse files
fixup! ci(aio): change AIO preview server stuff to use CircleCI
1 parent 66e00e5 commit a5a8942

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Diff for: aio/aio-builds-setup/dockerbuild/scripts-js/lib/upload-server/build-retriever.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class BuildRetriever {
4242
public async downloadBuildArtifact(buildNum: number, pr: number, sha: string, artifactPath: string) {
4343
try {
4444
const outPath = computeArtifactDownloadPath(this.downloadDir, pr, sha, artifactPath);
45-
const downloadExists = await promisify(fs.exists)(outPath);
45+
const downloadExists = await new Promise(resolve => fs.exists(outPath, exists => resolve(exists)));
4646
if (!downloadExists) {
4747
const url = await this.api.getBuildArtifactUrl(buildNum, artifactPath);
4848
const response = await fetch(url, {size: this.downloadSizeLimit});

Diff for: aio/aio-builds-setup/dockerbuild/scripts-js/test/upload-server/build-retriever.spec.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('BuildRetriever', () => {
4141

4242
EXISTS_RESULT = false;
4343
existsSpy = spyOn(fs, 'exists').and.callFake(
44-
(_path: string, callback: (err?: any) => {}) => callback(EXISTS_RESULT),
44+
(_path: string, callback: (exists: boolean) => {}) => callback(EXISTS_RESULT),
4545
);
4646
});
4747

@@ -96,6 +96,17 @@ describe('BuildRetriever', () => {
9696
artifactRequest.done();
9797
});
9898

99+
it('should not download the artifact if it already exists', async () => {
100+
const artifactRequestInterceptor = nock(BASE_URL).get(ARTIFACT_PATH);
101+
const artifactRequest = artifactRequestInterceptor.reply(200, ARTIFACT_CONTENTS);
102+
EXISTS_RESULT = true;
103+
await retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH);
104+
expect(existsSpy).toHaveBeenCalled();
105+
expect(getBuildArtifactUrlSpy).not.toHaveBeenCalled();
106+
expect(artifactRequest.isDone()).toEqual(false);
107+
nock.removeInterceptor(artifactRequestInterceptor);
108+
});
109+
99110
it('should write the artifact file to disk', async () => {
100111
const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).reply(200, ARTIFACT_CONTENTS);
101112
await retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH);

0 commit comments

Comments
 (0)