Skip to content

Commit

Permalink
Imitate correct build/publish failure output
Browse files Browse the repository at this point in the history
  • Loading branch information
FyreByrd committed Oct 18, 2024
1 parent 95bb408 commit 88c64ec
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 21 deletions.
12 changes: 9 additions & 3 deletions source/SIL.AppBuilder.Portal/node-server/job-executors/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export class Product extends ScriptoriaJobExecutor<BullMQ.ScriptoriaJobType.Buil
WorkflowJobId: true
}
});
if (!productData) {
throw new Error(`Product #${job.data.productId} does not exist!`);
}
job.updateProgress(25);
const response = await BuildEngine.Requests.createBuild(
productData.Project.OrganizationId,
Expand All @@ -36,7 +39,6 @@ export class Product extends ScriptoriaJobExecutor<BullMQ.ScriptoriaJobType.Buil
job.updateProgress(50);
if (response.responseType === 'error') {
const flow = await Workflow.restore(job.data.productId);
// TODO: Match DWKit failure output
flow.send({ type: 'Build Failed', userId: null, comment: response.message });
job.updateProgress(100);
return 0;
Expand Down Expand Up @@ -83,15 +85,19 @@ export class Check extends ScriptoriaJobExecutor<BullMQ.ScriptoriaJobType.Build_
} else {
// TODO: what does the 'expired' status mean?
if (response.status === 'completed' || response.status === 'expired') {
await queues.scriptoria.removeRepeatableByKey(job.repeatJobKey);
await queues.scriptoria.removeRepeatableByKey(job.repeatJobKey!);
if (response.error) {
job.log(response.error);
}
const flow = await Workflow.restore(job.data.productId);
if (response.result === 'SUCCESS') {
flow.send({ type: 'Build Successful', userId: null });
} else {
flow.send({ type: 'Build Failed', userId: null, comment: response.error });
flow.send({
type: 'Build Failed',
userId: null,
comment: `system.build-failed,${response.artifacts['consoleText'] ?? ''}`
});
}
job.updateProgress(100);
return response.id;
Expand Down
36 changes: 21 additions & 15 deletions source/SIL.AppBuilder.Portal/node-server/job-executors/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export class Product extends ScriptoriaJobExecutor<BullMQ.ScriptoriaJobType.Publ
job.updateProgress(50);
if (response.responseType === 'error') {
const flow = await Workflow.restore(job.data.productId);
// TODO: Match DWKit failure output
flow.send({ type: 'Publish Failed', userId: null, comment: response.message });
job.updateProgress(100);
return 0;
Expand All @@ -50,19 +49,22 @@ export class Product extends ScriptoriaJobExecutor<BullMQ.ScriptoriaJobType.Publ
});
job.updateProgress(75);

await queues.scriptoria.add(`Check status of Publish #${response.id}`, {
type: BullMQ.ScriptoriaJobType.Publish_Check,
productId: job.data.productId,
organizationId: productData.Project.OrganizationId,
jobId: productData.WorkflowJobId,
buildId: productData.WorkflowBuildId,
releaseId: response.id
},
{
repeat: {
pattern: '*/1 * * * *' // every minute
await queues.scriptoria.add(
`Check status of Publish #${response.id}`,
{
type: BullMQ.ScriptoriaJobType.Publish_Check,
productId: job.data.productId,
organizationId: productData.Project.OrganizationId,
jobId: productData.WorkflowJobId,
buildId: productData.WorkflowBuildId,
releaseId: response.id
},
{
repeat: {
pattern: '*/1 * * * *' // every minute
}
}
});
);
job.updateProgress(100);

return response.id;
Expand Down Expand Up @@ -92,7 +94,11 @@ export class Check extends ScriptoriaJobExecutor<BullMQ.ScriptoriaJobType.Publis
if (response.result === 'SUCCESS') {
flow.send({ type: 'Publish Successful', userId: null });
} else {
flow.send({ type: 'Publish Failed', userId: null, comment: response.error });
flow.send({
type: 'Publish Failed',
userId: null,
comment: `system.publish-failed,${response.artifacts['consoleText'] ?? ''}`
});
}
job.updateProgress(100);
return response.id;
Expand All @@ -101,4 +107,4 @@ export class Check extends ScriptoriaJobExecutor<BullMQ.ScriptoriaJobType.Publis
return 0;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
<input type="hidden" name="storeLanguageId" value={null} />
</form>
<form method="dialog" class="modal-backdrop">
<button on:click={() => selectingStore = false}>close</button>
<button on:click={() => (selectingStore = false)}>close</button>
</form>
</dialog>
</div>
Expand Down Expand Up @@ -364,7 +364,13 @@
</span>
{/if}
<br />
<a href={transition.Comment.replace('system.build-failed,', '')}>
<a
class="link"
href={transition.Comment.replace(
/system\.(build|publish)-failed,/,
''
)}
>
{m.project_products_publications_console()}
</a>
{:else}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,28 @@
</tr>
{#if task.Comment}
<tr>
<div class="pl-7">{task.Comment}</div>
<div class="pl-7">
{#if task.Comment.startsWith('system.')}
{#if task.Comment.startsWith('system.build-failed')}
<span>
{m.system_buildFailed()}
</span>
{:else if task.Comment.startsWith('system.publish-failed')}
<span>
{m.system_publishFailed()}
</span>
{/if}
<br />
<a
class="link"
href={task.Comment.replace(/system\.(build|publish)-failed,/, '')}
>
{m.project_products_publications_console()}
</a>
{:else}
{task.Comment}
{/if}
</div>
</tr>
{/if}
{/each}
Expand Down

0 comments on commit 88c64ec

Please sign in to comment.