Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/build/src/barque.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ describe('Barque', () => {
appleCodesignIdentity: 'appleCodesignIdentity',
isCi: true,
platform: 'linux',
distributionBuildVariant: BuildVariant.Linux,
repo: {
owner: 'owner',
repo: 'repo',
Expand All @@ -60,7 +59,7 @@ describe('Barque', () => {
let err;

try {
await barque.releaseToBarque(tarballURL);
await barque.releaseToBarque(BuildVariant.Linux, tarballURL);
} catch (error) {
err = error;
}
Expand All @@ -80,7 +79,7 @@ describe('Barque', () => {
let err;

try {
await barque.releaseToBarque(tarballURL);
await barque.releaseToBarque(BuildVariant.Linux, tarballURL);
} catch (error) {
err = error;
}
Expand All @@ -103,7 +102,7 @@ describe('Barque', () => {

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

await barque.releaseToBarque(tarballURL);
await barque.releaseToBarque(BuildVariant.Linux, tarballURL);
expect(barque.createCuratorDir).to.have.been.called;
expect(barque.extractLatestCurator).to.have.been.called;
expect(barque.execCurator).to.not.have.been.called;
Expand Down
7 changes: 1 addition & 6 deletions packages/build/src/barque.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@ export class Barque {
*
* @returns {Promise} The promise.
*/
async releaseToBarque(tarballURL: string): Promise<any> {
const buildVariant = this.config.distributionBuildVariant;
if (!buildVariant) {
throw new Error('distributionBuildVariant is not set in configuration');
}

async releaseToBarque(buildVariant: BuildVariant, tarballURL: string): Promise<any> {
const repoConfig = path.join(this.config.rootDir, 'config', 'repo-config.yml');
const curatorDirPath = await this.createCuratorDir();
await this.extractLatestCurator(curatorDirPath);
Expand Down
12 changes: 10 additions & 2 deletions packages/build/src/local/trigger-release-publish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,24 @@ describe('local trigger-release-publish', () => {
expect.fail('Expected error');
});

it('fails if there are failed tasks', async() => {
it('fails if there are failed tasks and user cancels', async() => {
getTasks.resolves([successTask, failedTask]);
const confirm = sinon.stub().resolves(false);
try {
await verifyEvergreenStatusFn('sha', evergreenProvider);
await verifyEvergreenStatusFn('sha', evergreenProvider, confirm);
} catch (e) {
expect(e.message).to.contain('Some Evergreen tasks were not successful');
expect(getTasks).to.have.been.calledWith('mongosh', 'sha');
return;
}
expect.fail('Expected error');
});

it('continues if there are failed tasks but user acknowledges', async() => {
getTasks.resolves([successTask, failedTask]);
const confirm = sinon.stub().resolves(true);
await verifyEvergreenStatusFn('sha', evergreenProvider, confirm);
expect(confirm).to.have.been.called;
});
});
});
19 changes: 13 additions & 6 deletions packages/build/src/local/trigger-release-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,24 @@ export async function triggerReleasePublish(

export async function verifyEvergreenStatusFn(
commitSha: string,
evergreenApiProvider: Promise<EvergreenApi> = EvergreenApi.fromUserConfiguration()
evergreenApiProvider: Promise<EvergreenApi> = EvergreenApi.fromUserConfiguration(),
confirm: typeof confirmFn = confirmFn,
): Promise<void> {
const evergreenApi = await evergreenApiProvider;
const tasks = await evergreenApi.getTasks('mongosh', commitSha);
const unsuccessfulTasks = tasks.filter(t => t.status !== 'success');

if (unsuccessfulTasks.length) {
console.error('!! Detected the following failed tasks on Evergreen:');
unsuccessfulTasks.forEach(t => {
console.error(` > ${t.display_name} on ${t.build_variant}`);
});
if (!unsuccessfulTasks.length) {
return;
}

console.error('!! Detected the following not successful tasks on Evergreen:');
unsuccessfulTasks.forEach(t => {
console.error(` > ${t.display_name} on ${t.build_variant}`);
});

const stillContinue = await confirm('!! Do you want to continue and still release despite non-successful tasks?');
if (!stillContinue) {
console.error('!! Please trigger a new draft and ensure all tasks complete successfully.');
throw new Error('Some Evergreen tasks were not successful.');
}
Expand Down
4 changes: 3 additions & 1 deletion packages/build/src/run-publish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ describe('publish', () => {
appleCodesignIdentity: 'appleCodesignIdentity',
isCi: true,
platform: 'platform',
distributionBuildVariant: BuildVariant.Linux,
repo: {
owner: 'owner',
repo: 'repo',
Expand Down Expand Up @@ -178,12 +177,15 @@ describe('publish', () => {

expect(barque.releaseToBarque).to.have.been.callCount(3);
expect(barque.releaseToBarque).to.have.been.calledWith(
BuildVariant.Linux,
'https://s3.amazonaws.com/mciuploads/project/v0.7.0-draft.42/mongosh-0.7.0-linux.tgz'
);
expect(barque.releaseToBarque).to.have.been.calledWith(
BuildVariant.Redhat,
'https://s3.amazonaws.com/mciuploads/project/v0.7.0-draft.42/mongosh-0.7.0-x86_64.rpm'
);
expect(barque.releaseToBarque).to.have.been.calledWith(
BuildVariant.Debian,
'https://s3.amazonaws.com/mciuploads/project/v0.7.0-draft.42/mongosh_0.7.0_amd64.deb'
);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/run-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function publishArtifactsToBarque(
const tarballName = getTarballFile(variant, releaseVersion, packageName);
const tarballUrl = getEvergreenArtifactUrl(project, mostRecentDraftTag, tarballName.path);
console.info(`mongosh: Publishing ${variant} artifact to barque ${tarballUrl}`);
await barque.releaseToBarque(tarballUrl);
await barque.releaseToBarque(variant, tarballUrl);
}
console.info('mongosh: Submitting to barque complete');
}