Skip to content

Commit

Permalink
feat: allow to specify ref branch & ref commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Sep 17, 2023
1 parent d54097c commit a6c4ee3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ program
)
.option("--parallel-total <number>", "The number of parallel nodes being ran")
.option("--parallel-nonce <string>", "A unique ID for this parallel build")
.option(
"--reference-branch <string>",
"Branch used as baseline for screenshot comparison",
)
.option(
"--reference-commit <string>",
"Commit used as baseline for screenshot comparison",
)
.action(async (directory, options) => {
const spinner = ora("Uploading screenshots").start();
try {
Expand All @@ -54,6 +62,8 @@ program
parallel: options.parallel
? { nonce: options.parallelNonce, total: options.parallelTotal }
: false,
referenceBranch: options.referenceBranch,
referenceCommit: options.referenceCommit,
});
spinner.succeed(`Build created: ${result.build.url}`);
} catch (error: any) {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface CreateBuildInput {
parallelNonce?: string | null;
prNumber?: number | null;
prHeadCommit?: string | null;
referenceBranch?: string | null;
referenceCommit?: string | null;
}

export interface CreateBuildOutput {
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ const schema = {
default: null,
nullable: true,
},
referenceBranch: {
env: "ARGOS_REFERENCE_BRANCH",
format: String,
default: null,
nullable: true,
},
referenceCommit: {
env: "ARGOS_REFERENCE_COMMIT",
format: String,
default: null,
nullable: true,
},
ciService: {
format: String,
default: null,
Expand Down Expand Up @@ -119,6 +131,8 @@ export interface Config {
parallel: boolean;
parallelNonce: string | null;
parallelTotal: number | null;
referenceBranch: string | null;
referenceCommit: string | null;
owner: string | null;
repository: string | null;
jobId: string | null;
Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export interface UploadParameters {
total: number;
}
| false;
/** Branch used as baseline for screenshot comparison */
referenceBranch?: string;
/** Commit used as baseline for screenshot comparison */
referenceCommit?: string;
}

const getConfigFromOptions = (options: UploadParameters) => {
Expand All @@ -57,6 +61,10 @@ const getConfigFromOptions = (options: UploadParameters) => {
prNumber:
options.prNumber ?? config.get("prNumber") ?? ciEnv?.prNumber ?? null,
prHeadCommit: config.get("prHeadCommit") ?? ciEnv?.prHeadCommit ?? null,
referenceBranch:
options.referenceBranch ?? config.get("referenceBranch") ?? null,
referenceCommit:
options.referenceCommit ?? config.get("referenceCommit") ?? null,
ciService: ciEnv?.name ?? null,
owner: ciEnv?.owner ?? null,
repository: ciEnv?.repository ?? null,
Expand Down Expand Up @@ -123,6 +131,8 @@ export const upload = async (params: UploadParameters) => {
),
prNumber: config.prNumber,
prHeadCommit: config.prHeadCommit,
referenceBranch: config.referenceBranch,
referenceCommit: config.referenceCommit,
});

debug("Got screenshots", result);
Expand Down

0 comments on commit a6c4ee3

Please sign in to comment.