diff --git a/migration/1702576832109-AddJobUrlsToUploads.ts b/migration/1702576832109-AddJobUrlsToUploads.ts new file mode 100644 index 0000000..3b83a6f --- /dev/null +++ b/migration/1702576832109-AddJobUrlsToUploads.ts @@ -0,0 +1,16 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class AddJobUrlsToUploads1702576832109 implements MigrationInterface { + name = 'AddJobUrlsToUploads1702576832109' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "uploads" ADD "github_job_api_url" character varying`); + await queryRunner.query(`ALTER TABLE "uploads" ADD "github_job_html_url" character varying`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "uploads" DROP COLUMN "github_job_html_url"`); + await queryRunner.query(`ALTER TABLE "uploads" DROP COLUMN "github_job_api_url"`); + } + +} diff --git a/src/uploads/details.viewModel.ts b/src/uploads/details.viewModel.ts index e8dcef8..e5f5064 100644 --- a/src/uploads/details.viewModel.ts +++ b/src/uploads/details.viewModel.ts @@ -162,6 +162,17 @@ export class UploadDetailsViewModel { term: 'GitHub job', description: { type: 'text', text: this.upload.githubJob }, }, + { + term: 'GitHub job URL', + description: + this.upload.githubJobHtmlUrl == null + ? { type: 'text', text: 'Not known' } + : { + type: 'link', + text: this.upload.githubJobHtmlUrl, + href: this.upload.githubJobHtmlUrl, + }, + }, { term: 'Loop iteration', description: { type: 'text', text: this.upload.iteration.toString() }, diff --git a/src/uploads/postUploads.controller.ts b/src/uploads/postUploads.controller.ts index 7bea6ca..e232514 100644 --- a/src/uploads/postUploads.controller.ts +++ b/src/uploads/postUploads.controller.ts @@ -62,6 +62,14 @@ class CreateUploadDTO { @IsString() github_job!: string; + @ValidateIf((_, value: unknown) => value !== null && value !== undefined) + @IsString() + github_job_api_url!: string | null | undefined; /* backwards compatibility */ + + @ValidateIf((_, value: unknown) => value !== null && value !== undefined) + @IsString() + github_job_html_url!: string | null | undefined; /* backwards compatibility */ + @IsNumber() @Type(() => Number) iteration!: number; @@ -141,6 +149,8 @@ export class PostUploadsController { githubBaseRef: body.github_base_ref, githubHeadRef: body.github_head_ref, githubJob: body.github_job, + githubJobApiUrl: body.github_job_api_url ?? null, + githubJobHtmlUrl: body.github_job_html_url ?? null, iteration: body.iteration, }, crashReports, diff --git a/src/uploads/upload.entity.ts b/src/uploads/upload.entity.ts index 8731748..082077b 100644 --- a/src/uploads/upload.entity.ts +++ b/src/uploads/upload.entity.ts @@ -64,6 +64,14 @@ export class Upload { @Column({ name: 'github_job' }) githubJob!: string; + // The URL of a GitHub REST API endpoint describing the job that performed this upload. + @Column({ name: 'github_job_api_url', nullable: true, type: 'varchar' }) + githubJobApiUrl!: string | null; + + // The URL of a GitHub web page describing the job that performed this upload. + @Column({ name: 'github_job_html_url', nullable: true, type: 'varchar' }) + githubJobHtmlUrl!: string | null; + // If running the tests multiple times inside a single CI job, this is the number of the current iteration. @Column() iteration!: number;