Skip to content

Commit f96b9e5

Browse files
authored
chore(build): fix releasing to barque and evergreen checks (#677)
1 parent cb9376f commit f96b9e5

File tree

6 files changed

+31
-20
lines changed

6 files changed

+31
-20
lines changed

packages/build/src/barque.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ describe('Barque', () => {
3737
appleCodesignIdentity: 'appleCodesignIdentity',
3838
isCi: true,
3939
platform: 'linux',
40-
distributionBuildVariant: BuildVariant.Linux,
4140
repo: {
4241
owner: 'owner',
4342
repo: 'repo',
@@ -60,7 +59,7 @@ describe('Barque', () => {
6059
let err;
6160

6261
try {
63-
await barque.releaseToBarque(tarballURL);
62+
await barque.releaseToBarque(BuildVariant.Linux, tarballURL);
6463
} catch (error) {
6564
err = error;
6665
}
@@ -80,7 +79,7 @@ describe('Barque', () => {
8079
let err;
8180

8281
try {
83-
await barque.releaseToBarque(tarballURL);
82+
await barque.releaseToBarque(BuildVariant.Linux, tarballURL);
8483
} catch (error) {
8584
err = error;
8685
}
@@ -103,7 +102,7 @@ describe('Barque', () => {
103102

104103
const tarballURL = 'https://s3.amazonaws.com/mciuploads/mongosh/5ed7ee5d8683818eb28d9d3b5c65837cde4a08f5/mongosh-0.1.0-linux.tgz';
105104

106-
await barque.releaseToBarque(tarballURL);
105+
await barque.releaseToBarque(BuildVariant.Linux, tarballURL);
107106
expect(barque.createCuratorDir).to.have.been.called;
108107
expect(barque.extractLatestCurator).to.have.been.called;
109108
expect(barque.execCurator).to.not.have.been.called;

packages/build/src/barque.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ export class Barque {
6363
*
6464
* @returns {Promise} The promise.
6565
*/
66-
async releaseToBarque(tarballURL: string): Promise<any> {
67-
const buildVariant = this.config.distributionBuildVariant;
68-
if (!buildVariant) {
69-
throw new Error('distributionBuildVariant is not set in configuration');
70-
}
71-
66+
async releaseToBarque(buildVariant: BuildVariant, tarballURL: string): Promise<any> {
7267
const repoConfig = path.join(this.config.rootDir, 'config', 'repo-config.yml');
7368
const curatorDirPath = await this.createCuratorDir();
7469
await this.extractLatestCurator(curatorDirPath);

packages/build/src/local/trigger-release-publish.spec.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,24 @@ describe('local trigger-release-publish', () => {
211211
expect.fail('Expected error');
212212
});
213213

214-
it('fails if there are failed tasks', async() => {
214+
it('fails if there are failed tasks and user cancels', async() => {
215215
getTasks.resolves([successTask, failedTask]);
216+
const confirm = sinon.stub().resolves(false);
216217
try {
217-
await verifyEvergreenStatusFn('sha', evergreenProvider);
218+
await verifyEvergreenStatusFn('sha', evergreenProvider, confirm);
218219
} catch (e) {
219220
expect(e.message).to.contain('Some Evergreen tasks were not successful');
220221
expect(getTasks).to.have.been.calledWith('mongosh', 'sha');
221222
return;
222223
}
223224
expect.fail('Expected error');
224225
});
226+
227+
it('continues if there are failed tasks but user acknowledges', async() => {
228+
getTasks.resolves([successTask, failedTask]);
229+
const confirm = sinon.stub().resolves(true);
230+
await verifyEvergreenStatusFn('sha', evergreenProvider, confirm);
231+
expect(confirm).to.have.been.called;
232+
});
225233
});
226234
});

packages/build/src/local/trigger-release-publish.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,24 @@ export async function triggerReleasePublish(
5151

5252
export async function verifyEvergreenStatusFn(
5353
commitSha: string,
54-
evergreenApiProvider: Promise<EvergreenApi> = EvergreenApi.fromUserConfiguration()
54+
evergreenApiProvider: Promise<EvergreenApi> = EvergreenApi.fromUserConfiguration(),
55+
confirm: typeof confirmFn = confirmFn,
5556
): Promise<void> {
5657
const evergreenApi = await evergreenApiProvider;
5758
const tasks = await evergreenApi.getTasks('mongosh', commitSha);
5859
const unsuccessfulTasks = tasks.filter(t => t.status !== 'success');
5960

60-
if (unsuccessfulTasks.length) {
61-
console.error('!! Detected the following failed tasks on Evergreen:');
62-
unsuccessfulTasks.forEach(t => {
63-
console.error(` > ${t.display_name} on ${t.build_variant}`);
64-
});
61+
if (!unsuccessfulTasks.length) {
62+
return;
63+
}
64+
65+
console.error('!! Detected the following not successful tasks on Evergreen:');
66+
unsuccessfulTasks.forEach(t => {
67+
console.error(` > ${t.display_name} on ${t.build_variant}`);
68+
});
69+
70+
const stillContinue = await confirm('!! Do you want to continue and still release despite non-successful tasks?');
71+
if (!stillContinue) {
6572
console.error('!! Please trigger a new draft and ensure all tasks complete successfully.');
6673
throw new Error('Some Evergreen tasks were not successful.');
6774
}

packages/build/src/run-publish.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ describe('publish', () => {
5656
appleCodesignIdentity: 'appleCodesignIdentity',
5757
isCi: true,
5858
platform: 'platform',
59-
distributionBuildVariant: BuildVariant.Linux,
6059
repo: {
6160
owner: 'owner',
6261
repo: 'repo',
@@ -178,12 +177,15 @@ describe('publish', () => {
178177

179178
expect(barque.releaseToBarque).to.have.been.callCount(3);
180179
expect(barque.releaseToBarque).to.have.been.calledWith(
180+
BuildVariant.Linux,
181181
'https://s3.amazonaws.com/mciuploads/project/v0.7.0-draft.42/mongosh-0.7.0-linux.tgz'
182182
);
183183
expect(barque.releaseToBarque).to.have.been.calledWith(
184+
BuildVariant.Redhat,
184185
'https://s3.amazonaws.com/mciuploads/project/v0.7.0-draft.42/mongosh-0.7.0-x86_64.rpm'
185186
);
186187
expect(barque.releaseToBarque).to.have.been.calledWith(
188+
BuildVariant.Debian,
187189
'https://s3.amazonaws.com/mciuploads/project/v0.7.0-draft.42/mongosh_0.7.0_amd64.deb'
188190
);
189191
});

packages/build/src/run-publish.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async function publishArtifactsToBarque(
9696
const tarballName = getTarballFile(variant, releaseVersion, packageName);
9797
const tarballUrl = getEvergreenArtifactUrl(project, mostRecentDraftTag, tarballName.path);
9898
console.info(`mongosh: Publishing ${variant} artifact to barque ${tarballUrl}`);
99-
await barque.releaseToBarque(tarballUrl);
99+
await barque.releaseToBarque(variant, tarballUrl);
100100
}
101101
console.info('mongosh: Submitting to barque complete');
102102
}

0 commit comments

Comments
 (0)