Skip to content

Commit 1c1aa11

Browse files
fixup! ci(aio): change AIO preview server stuff to pull builds from CircleCI
1 parent 59f3f84 commit 1c1aa11

File tree

3 files changed

+55
-46
lines changed

3 files changed

+55
-46
lines changed

Diff for: aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/helper.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ interface CurlOptions {
182182
method?: string;
183183
options?: string;
184184
data?: any;
185-
payload?: any;
186185
url?: string;
187186
extraPath?: string;
188187
}
@@ -192,13 +191,9 @@ export function makeCurl(baseUrl: string) {
192191
method = 'POST',
193192
options = '',
194193
data = {},
195-
payload,
196194
url = baseUrl,
197195
extraPath = '',
198196
}: CurlOptions) {
199-
if (payload) {
200-
data = { payload };
201-
}
202197
const dataString = data ? JSON.stringify(data) : '';
203198
const cmd = `curl -iLX ${method} ` +
204199
`${options} ` +
@@ -209,5 +204,17 @@ export function makeCurl(baseUrl: string) {
209204
};
210205
}
211206

207+
export function payload(buildNum: number) {
208+
return {
209+
data: {
210+
payload: {
211+
build_num: buildNum,
212+
build_parameters: { CIRCLE_JOB: 'aio_preview' },
213+
},
214+
},
215+
};
216+
}
217+
218+
212219
// Exports
213220
export const helper = new Helper();

Diff for: aio/aio-builds-setup/dockerbuild/scripts-js/lib/verify-setup/server-integration.e2e.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import {AIO_NGINX_HOSTNAME} from '../common/env-variables';
33
import {computeShortSha} from '../common/utils';
44
import {ALT_SHA, BuildNums, PrNums, SHA} from './constants';
5-
import {helper as h, makeCurl} from './helper';
5+
import {helper as h, makeCurl, payload} from './helper';
66
import {customMatchers} from './jasmine-custom-matchers';
77

88
// Tests
@@ -33,7 +33,7 @@ h.runForAllSupportedSchemes((scheme, port) => describe(`integration (on ${scheme
3333
const idxContentRegex = new RegExp(`${regexPrefix} \\/index\\.html$`);
3434
const barContentRegex = new RegExp(`${regexPrefix} \\/foo\\/bar\\.js$`);
3535

36-
await circleBuild({ payload: { build_num: BUILD} }).then(h.verifyResponse(201));
36+
await circleBuild(payload(BUILD)).then(h.verifyResponse(201));
3737
await Promise.all([
3838
getFile(PR, SHA, 'index.html').then(h.verifyResponse(200, idxContentRegex)),
3939
getFile(PR, SHA, 'foo/bar.js').then(h.verifyResponse(200, barContentRegex)),
@@ -48,7 +48,7 @@ h.runForAllSupportedSchemes((scheme, port) => describe(`integration (on ${scheme
4848
const BUILD = BuildNums.TRUST_CHECK_UNTRUSTED;
4949
const PR = PrNums.TRUST_CHECK_UNTRUSTED;
5050

51-
await circleBuild({ payload: { build_num: BUILD} }).then(h.verifyResponse(202));
51+
await circleBuild(payload(BUILD)).then(h.verifyResponse(202));
5252
await Promise.all([
5353
getFile(PR, SHA, 'index.html').then(h.verifyResponse(404)),
5454
getFile(PR, SHA, 'foo/bar.js').then(h.verifyResponse(404)),
@@ -63,7 +63,7 @@ h.runForAllSupportedSchemes((scheme, port) => describe(`integration (on ${scheme
6363
const BUILD = BuildNums.TRUST_CHECK_ERROR;
6464
const PR = PrNums.TRUST_CHECK_ERROR;
6565

66-
await circleBuild({ payload: { build_num: BUILD} }).then(h.verifyResponse(500));
66+
await circleBuild(payload(BUILD)).then(h.verifyResponse(500));
6767
expect({ prNum: PR }).toExistAsAnArtifact();
6868
expect({ prNum: PR }).not.toExistAsABuild();
6969
expect({ prNum: PR, isPublic: false }).not.toExistAsABuild();
@@ -95,7 +95,7 @@ h.runForAllSupportedSchemes((scheme, port) => describe(`integration (on ${scheme
9595
const barContentRegex2 = new RegExp(`${regexPrefix2} \\/foo\\/bar\\.js$`);
9696

9797
h.createDummyBuild(PR, ALT_SHA);
98-
await circleBuild({ payload: { build_num: BUILD }}).then(h.verifyResponse(201));
98+
await circleBuild(payload(BUILD)).then(h.verifyResponse(201));
9999
await Promise.all([
100100
getFile(PR, ALT_SHA, 'index.html').then(h.verifyResponse(200, idxContentRegex1)),
101101
getFile(PR, ALT_SHA, 'foo/bar.js').then(h.verifyResponse(200, barContentRegex1)),
@@ -113,7 +113,7 @@ h.runForAllSupportedSchemes((scheme, port) => describe(`integration (on ${scheme
113113
const PR = PrNums.TRUST_CHECK_UNTRUSTED;
114114

115115
h.createDummyBuild(PR, ALT_SHA, false);
116-
await circleBuild({ payload: { build_num: BUILD }}).then(h.verifyResponse(202));
116+
await circleBuild(payload(BUILD)).then(h.verifyResponse(202));
117117

118118
await Promise.all([
119119
getFile(PR, ALT_SHA, 'index.html').then(h.verifyResponse(404)),
@@ -135,7 +135,7 @@ h.runForAllSupportedSchemes((scheme, port) => describe(`integration (on ${scheme
135135

136136
h.createDummyBuild(PR, ALT_SHA, false);
137137

138-
await circleBuild({ payload: { build_num: BUILD} }).then(h.verifyResponse(500));
138+
await circleBuild(payload(BUILD)).then(h.verifyResponse(500));
139139

140140
expect({ prNum: PR }).toExistAsAnArtifact();
141141
expect({ prNum: PR }).not.toExistAsABuild();
@@ -154,7 +154,7 @@ h.runForAllSupportedSchemes((scheme, port) => describe(`integration (on ${scheme
154154

155155
h.createDummyBuild(PR, SHA);
156156

157-
await circleBuild({ payload: { build_num: BUILD }}).then(h.verifyResponse(409));
157+
await circleBuild(payload(BUILD)).then(h.verifyResponse(409));
158158
await Promise.all([
159159
getFile(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, SHA, 'index.html').then(h.verifyResponse(200, idxContentRegex)),
160160
getFile(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, SHA, 'foo/bar.js').then(h.verifyResponse(200, barContentRegex)),
@@ -170,7 +170,7 @@ h.runForAllSupportedSchemes((scheme, port) => describe(`integration (on ${scheme
170170
const PR = PrNums.TRUST_CHECK_UNTRUSTED;
171171
h.createDummyBuild(PR, SHA, false);
172172

173-
await circleBuild({ payload: { build_num: BUILD }}).then(h.verifyResponse(409));
173+
await circleBuild(payload(BUILD)).then(h.verifyResponse(409));
174174

175175
expect({ prNum: PR }).toExistAsAnArtifact();
176176
expect({ prNum: PR, isPublic: false }).toExistAsABuild();

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

+34-32
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {join} from 'path';
44
import {AIO_UPLOAD_HOSTNAME, AIO_UPLOAD_PORT, AIO_WWW_USER} from '../common/env-variables';
55
import {computeShortSha} from '../common/utils';
66
import {ALT_SHA, BuildNums, PrNums, SHA, SIMILAR_SHA} from './constants';
7-
import {helper as h, makeCurl} from './helper';
7+
import {helper as h, makeCurl, payload} from './helper';
88
import {customMatchers} from './jasmine-custom-matchers';
99

1010
// Tests
@@ -51,63 +51,65 @@ describe('upload-server', () => {
5151
await Promise.all([
5252
curl({ data: '' }).then(h.verifyResponse(400)),
5353
curl({ data: {} }).then(h.verifyResponse(400)),
54-
curl({ payload: {} }).then(h.verifyResponse(400)),
55-
curl({ payload: { build_num: 0 } }).then(h.verifyResponse(400)),
56-
curl({ payload: { build_num: -1 } }).then(h.verifyResponse(400)),
54+
curl({ data: { payload: {} } }).then(h.verifyResponse(400)),
55+
curl({ data: { payload: { build_num: 1 } } }).then(h.verifyResponse(400)),
56+
curl({ data: { payload: { build_num: 1, build_parameters: {} } } }).then(h.verifyResponse(400)),
57+
curl(payload(0)).then(h.verifyResponse(400)),
58+
curl(payload(-1)).then(h.verifyResponse(400)),
5759
]);
5860
});
5961

6062
it('should respond with 500 if the CircleCI API request errors', async () => {
61-
await curl({ payload: { build_num: BuildNums.BUILD_INFO_ERROR } }).then(h.verifyResponse(500));
62-
await curl({ payload: { build_num: BuildNums.BUILD_INFO_404 } }).then(h.verifyResponse(500));
63+
await curl(payload(BuildNums.BUILD_INFO_ERROR)).then(h.verifyResponse(500));
64+
await curl(payload(BuildNums.BUILD_INFO_404)).then(h.verifyResponse(500));
6365
});
6466

6567
it('should respond with 204 if the build on CircleCI failed', async () => {
66-
await curl({ payload: { build_num: BuildNums.BUILD_INFO_BUILD_FAILED } }).then(h.verifyResponse(204));
68+
await curl(payload(BuildNums.BUILD_INFO_BUILD_FAILED)).then(h.verifyResponse(204));
6769
});
6870

6971
it('should respond with 500 if the github org from CircleCI does not match what is configured', async () => {
70-
await curl({ payload: { build_num: BuildNums.BUILD_INFO_INVALID_GH_ORG } }).then(h.verifyResponse(500));
72+
await curl(payload(BuildNums.BUILD_INFO_INVALID_GH_ORG)).then(h.verifyResponse(500));
7173
});
7274

7375
it('should respond with 500 if the github repo from CircleCI does not match what is configured', async () => {
74-
await curl({ payload: { build_num: BuildNums.BUILD_INFO_INVALID_GH_REPO } }).then(h.verifyResponse(500));
76+
await curl(payload(BuildNums.BUILD_INFO_INVALID_GH_REPO)).then(h.verifyResponse(500));
7577
});
7678

7779
it('should respond with 500 if the github files API errors', async () => {
78-
await curl({ payload: { build_num: BuildNums.CHANGED_FILES_ERROR } }).then(h.verifyResponse(500));
79-
await curl({ payload: { build_num: BuildNums.CHANGED_FILES_404 } }).then(h.verifyResponse(500));
80+
await curl(payload(BuildNums.CHANGED_FILES_ERROR)).then(h.verifyResponse(500));
81+
await curl(payload(BuildNums.CHANGED_FILES_404)).then(h.verifyResponse(500));
8082
});
8183

8284
it('should respond with 204 if no significant files are changed by the PR', async () => {
83-
await curl({ payload: { build_num: BuildNums.CHANGED_FILES_NONE } }).then(h.verifyResponse(204));
85+
await curl(payload(BuildNums.CHANGED_FILES_NONE)).then(h.verifyResponse(204));
8486
});
8587

8688
it('should respond with 500 if the CircleCI artifact API fails', async () => {
87-
await curl({ payload: { build_num: BuildNums.BUILD_ARTIFACTS_ERROR } }).then(h.verifyResponse(500));
88-
await curl({ payload: { build_num: BuildNums.BUILD_ARTIFACTS_404 } }).then(h.verifyResponse(500));
89-
await curl({ payload: { build_num: BuildNums.BUILD_ARTIFACTS_EMPTY } }).then(h.verifyResponse(500));
90-
await curl({ payload: { build_num: BuildNums.BUILD_ARTIFACTS_MISSING } }).then(h.verifyResponse(500));
89+
await curl(payload(BuildNums.BUILD_ARTIFACTS_ERROR)).then(h.verifyResponse(500));
90+
await curl(payload(BuildNums.BUILD_ARTIFACTS_404)).then(h.verifyResponse(500));
91+
await curl(payload(BuildNums.BUILD_ARTIFACTS_EMPTY)).then(h.verifyResponse(500));
92+
await curl(payload(BuildNums.BUILD_ARTIFACTS_MISSING)).then(h.verifyResponse(500));
9193
});
9294

9395
it('should respond with 500 if fetching the artifact errors', async () => {
94-
await curl({ payload: { build_num: BuildNums.DOWNLOAD_ARTIFACT_ERROR } }).then(h.verifyResponse(500));
95-
await curl({ payload: { build_num: BuildNums.DOWNLOAD_ARTIFACT_404 } }).then(h.verifyResponse(500));
96+
await curl(payload(BuildNums.DOWNLOAD_ARTIFACT_ERROR)).then(h.verifyResponse(500));
97+
await curl(payload(BuildNums.DOWNLOAD_ARTIFACT_404)).then(h.verifyResponse(500));
9698
});
9799

98100
it('should respond with 500 if the GH trusted API fails', async () => {
99-
await curl({ payload: { build_num: BuildNums.TRUST_CHECK_ERROR } }).then(h.verifyResponse(500));
101+
await curl(payload(BuildNums.TRUST_CHECK_ERROR)).then(h.verifyResponse(500));
100102
expect({ prNum: PrNums.TRUST_CHECK_ERROR }).toExistAsAnArtifact();
101103
});
102104

103105
it('should respond with 201 if a new public build is created', async () => {
104-
await curl({ payload: { build_num: BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER } })
106+
await curl(payload(BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER))
105107
.then(h.verifyResponse(201));
106108
expect({ prNum: PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER }).toExistAsABuild();
107109
});
108110

109111
it('should respond with 202 if a new private build is created', async () => {
110-
await curl({ payload: { build_num: BuildNums.TRUST_CHECK_UNTRUSTED } }).then(h.verifyResponse(202));
112+
await curl(payload(BuildNums.TRUST_CHECK_UNTRUSTED)).then(h.verifyResponse(202));
111113
expect({ prNum: PrNums.TRUST_CHECK_UNTRUSTED, isPublic: false }).toExistAsABuild();
112114
});
113115

@@ -121,7 +123,7 @@ describe('upload-server', () => {
121123
describe(`for ${label} builds`, () => {
122124

123125
it('should extract the contents of the uploaded file', async () => {
124-
await curl({ payload: { build_num: build } })
126+
await curl(payload(build))
125127
.then(h.verifyResponse(statusCode));
126128
expect(h.readBuildFile(prNum, SHA, 'index.html', isPublic))
127129
.toContain(`PR: ${prNum} | SHA: ${SHA} | File: /index.html`);
@@ -131,7 +133,7 @@ describe('upload-server', () => {
131133
});
132134

133135
it(`should create files/directories owned by '${AIO_WWW_USER}'`, async () => {
134-
await curl({ payload: { build_num: build } })
136+
await curl(payload(build))
135137
.then(h.verifyResponse(statusCode));
136138

137139
const shaDir = h.getShaDir(h.getPrDir(prNum, isPublic), SHA);
@@ -147,14 +149,14 @@ describe('upload-server', () => {
147149
});
148150

149151
it('should delete the uploaded file', async () => {
150-
await curl({ payload: { build_num: build } })
152+
await curl(payload(build))
151153
.then(h.verifyResponse(statusCode));
152154
expect({ prNum, SHA }).not.toExistAsAnArtifact();
153155
expect({ prNum, isPublic }).toExistAsABuild();
154156
});
155157

156158
it('should make the build directory non-writable', async () => {
157-
await curl({ payload: { build_num: build } })
159+
await curl(payload(build))
158160
.then(h.verifyResponse(statusCode));
159161

160162
// See https://github.com/nodejs/node-v0.x-archive/issues/3045#issuecomment-4862588.
@@ -183,7 +185,7 @@ describe('upload-server', () => {
183185
h.writeBuildFile(prNum, SHA, 'index.html', 'My content', isPublic, true);
184186
expect(h.readBuildFile(prNum, SHA, 'index.html', isPublic, true)).toBe('My content');
185187

186-
await curl({ payload: { build_num: build } })
188+
await curl(payload(build))
187189
.then(h.verifyResponse(statusCode));
188190

189191
expect(h.readBuildFile(prNum, SHA, 'index.html', isPublic, false)).toContain('index.html');
@@ -198,7 +200,7 @@ describe('upload-server', () => {
198200
h.createDummyBuild(prNum, SHA, isPublic);
199201
// distinguish this build from the downloaded one
200202
h.writeBuildFile(prNum, SHA, 'index.html', 'My content', isPublic);
201-
await curl({ payload: { build_num: build } }).then(h.verifyResponse(409, overwriteRe));
203+
await curl(payload(build)).then(h.verifyResponse(409, overwriteRe));
202204
expect(h.readBuildFile(prNum, SHA, 'index.html', isPublic)).toBe('My content');
203205
expect({ prNum, isPublic }).toExistAsABuild();
204206
expect({ prNum }).toExistAsAnArtifact();
@@ -215,15 +217,15 @@ describe('upload-server', () => {
215217
h.writeBuildFile(prNum, SIMILAR_SHA, 'index.html', 'My content', isPublic);
216218
expect(h.readBuildFile(prNum, SIMILAR_SHA, 'index.html', isPublic)).toBe('My content');
217219

218-
await curl({ payload: { build_num: build } }).then(h.verifyResponse(409, overwriteRe));
220+
await curl(payload(build)).then(h.verifyResponse(409, overwriteRe));
219221
expect(h.readBuildFile(prNum, SIMILAR_SHA, 'index.html', isPublic)).toBe('My content');
220222
expect({ prNum, isPublic, sha: SIMILAR_SHA }).toExistAsABuild();
221223
expect({ prNum, sha: SIMILAR_SHA }).toExistAsAnArtifact();
222224
});
223225

224226
it('should only delete the SHA directory on error (for existing PR)', async () => {
225227
h.createDummyBuild(prNum, ALT_SHA, isPublic);
226-
await curl({ payload: { build_num: BuildNums.TRUST_CHECK_ERROR } }).then(h.verifyResponse(500));
228+
await curl(payload(BuildNums.TRUST_CHECK_ERROR)).then(h.verifyResponse(500));
227229
expect({ prNum: PrNums.TRUST_CHECK_ERROR }).toExistAsAnArtifact();
228230
expect({ prNum, isPublic, sha: SHA }).not.toExistAsABuild();
229231
expect({ prNum, isPublic, sha: ALT_SHA }).toExistAsABuild();
@@ -233,15 +235,15 @@ describe('upload-server', () => {
233235

234236
it('should update the PR\'s visibility', async () => {
235237
h.createDummyBuild(prNum, ALT_SHA, !isPublic);
236-
await curl({ payload: { build_num: build } }).then(h.verifyResponse(statusCode));
238+
await curl(payload(build)).then(h.verifyResponse(statusCode));
237239
expect({ prNum, isPublic }).toExistAsABuild();
238240
expect({ prNum, isPublic, sha: ALT_SHA }).toExistAsABuild();
239241
});
240242

241243

242244
it('should not overwrite existing builds (but keep the updated visibility)', async () => {
243245
h.createDummyBuild(prNum, SHA, !isPublic);
244-
await curl({ payload: { build_num: build } }).then(h.verifyResponse(409));
246+
await curl(payload(build)).then(h.verifyResponse(409));
245247
expect({ prNum, isPublic }).toExistAsABuild();
246248
expect({ prNum, isPublic: !isPublic }).not.toExistAsABuild();
247249
// since it errored we didn't clear up the downloaded artifact - perhaps we should?
@@ -257,7 +259,7 @@ describe('upload-server', () => {
257259
const errorRegex = new RegExp(`^Request to move '${h.getPrDir(prNum, !isPublic)}' ` +
258260
`to existing directory '${h.getPrDir(prNum, isPublic)}'.`);
259261

260-
await curl({ payload: { build_num: build } }).then(h.verifyResponse(409, errorRegex));
262+
await curl(payload(build)).then(h.verifyResponse(409, errorRegex));
261263

262264
expect({ prNum, isPublic }).not.toExistAsABuild();
263265

0 commit comments

Comments
 (0)