Skip to content

Commit

Permalink
Merge pull request #76 from ably/link-to-job
Browse files Browse the repository at this point in the history
Store URL of the GitHub job that performed upload
  • Loading branch information
lawrence-forooghian committed Jan 10, 2024
2 parents eec1421 + 79e47ea commit 11e3381
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
16 changes: 16 additions & 0 deletions migration/1702576832109-AddJobUrlsToUploads.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class AddJobUrlsToUploads1702576832109 implements MigrationInterface {
name = 'AddJobUrlsToUploads1702576832109'

public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
await queryRunner.query(`ALTER TABLE "uploads" DROP COLUMN "github_job_html_url"`);
await queryRunner.query(`ALTER TABLE "uploads" DROP COLUMN "github_job_api_url"`);
}

}
11 changes: 11 additions & 0 deletions src/uploads/details.viewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() },
Expand Down
10 changes: 10 additions & 0 deletions src/uploads/postUploads.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/uploads/upload.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 11e3381

Please sign in to comment.