Skip to content

[no-ticket] always finish created builds #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
27 changes: 16 additions & 11 deletions visual-js/visual-snapshots/src/app/pdf-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,27 @@ export class PdfCommandHandler {
private readonly pdfSnapshotUploader: PdfSnapshotUploader
) {}

public async handle(globsOrDirs: string[], params: PdfCommandParams) {
public async handle(
globsOrDirs: string[],
params: PdfCommandParams
): Promise<void> {
const pdfFilePaths = await getFiles(globsOrDirs, "*.pdf");

const buildId =
params.buildId ?? (await this.visualSnapshotsApi.createBuild(params));

await this.pdfSnapshotUploader.uploadSnapshots({
buildId,
pdfFilePaths,
suiteName: params.suiteName,
testNameFormat: params.testName,
snapshotNameFormat: params.snapshotName,
});

if (!params.buildId) {
await this.visualSnapshotsApi.finishBuild(buildId);
try {
await this.pdfSnapshotUploader.uploadSnapshots({
buildId,
pdfFilePaths,
suiteName: params.suiteName,
testNameFormat: params.testName,
snapshotNameFormat: params.snapshotName,
});
} finally {
if (!params.buildId) {
await this.visualSnapshotsApi.finishBuild(buildId);
}
}
}
}
4 changes: 2 additions & 2 deletions visual-js/visual-snapshots/src/commands/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ export const pdfCommand = (clientVersion: string) => {
new PdfCommandHandler(visualSnapshotsApi, pdfSnapshotUploader)
.handle(globsOrDirs, params)
.then(() => {
console.log("Successfully created PDF snapshots");
console.info("Successfully created PDF snapshots.");
})
.catch((err) => {
console.error(`An error occured when creating PDF snapshots: ${err}`);
console.error(`At least one PDF snapshot creation failed: ${err}.`);
});
});
};
Loading