Skip to content

Commit

Permalink
feat(core): send prHeadCommit at build creation
Browse files Browse the repository at this point in the history
Closes #50
  • Loading branch information
gregberge committed Jul 14, 2023
1 parent 12cffdc commit 919bd89
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/core/src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface CreateBuildInput {
parallel?: boolean | null;
parallelNonce?: string | null;
prNumber?: number | null;
prHeadCommit?: string | null;
}

export interface CreateBuildOutput {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/ci-environment/services/buildkite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const service: Service = {
prNumber: env.BUILDKITE_PULL_REQUEST
? Number(env.BUILDKITE_PULL_REQUEST)
: null,
prHeadCommit: null,
};
},
};
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/ci-environment/services/circleci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const service: Service = {
jobId: null,
runId: null,
prNumber: getPrNumber({ env }),
prHeadCommit: null,
};
},
};
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/ci-environment/services/github-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ const service: Service = {
config: ({ env }) => {
const payload = readEventPayload({ env });
return {
commit: payload?.pull_request?.head.sha || process.env.GITHUB_SHA || null,
commit: process.env.GITHUB_SHA || null,
branch: payload?.pull_request?.head.ref || getBranch({ env }) || null,
owner: env.GITHUB_REPOSITORY_OWNER || null,
repository: getRepository({ env }),
jobId: env.GITHUB_JOB || null,
runId: env.GITHUB_RUN_ID || null,
prNumber: payload?.pull_request?.number || null,
prHeadCommit: payload?.pull_request?.head.sha ?? null,
};
},
};
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/ci-environment/services/heroku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const service: Service = {
jobId: null,
runId: null,
prNumber: null,
prHeadCommit: null,
}),
};

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/ci-environment/services/travis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const service: Service = {
jobId: null,
runId: null,
prNumber: getPrNumber(ctx),
prHeadCommit: null,
};
},
};
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/ci-environment/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface CiEnvironment {
jobId: string | null;
runId: string | null;
prNumber: number | null;
prHeadCommit: string | null;
}

export interface Service {
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ const schema = {
default: null,
nullable: true,
},
prHeadCommit: {
env: "ARGOS_PR_HEAD_COMMIT",
format: Number,
default: null,
nullable: true,
},
parallel: {
env: "ARGOS_PARALLEL",
default: false,
Expand Down Expand Up @@ -118,6 +124,7 @@ export interface Config {
jobId: string | null;
runId: string | null;
prNumber: number | null;
prHeadCommit: string | null;
}

export const createConfig = () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const getConfigFromOptions = (options: UploadParameters) => {
buildName: config.get("buildName") ?? options.buildName ?? null,
prNumber:
config.get("prNumber") ?? options.prNumber ?? ciEnv?.prNumber ?? null,
prHeadCommit: config.get("prHeadCommit") ?? ciEnv?.prHeadCommit ?? null,
ciService: ciEnv?.name ?? null,
owner: ciEnv?.owner ?? null,
repository: ciEnv?.repository ?? null,
Expand Down Expand Up @@ -121,6 +122,7 @@ export const upload = async (params: UploadParameters) => {
new Set(screenshots.map((screenshot) => screenshot.hash))
),
prNumber: config.prNumber,
prHeadCommit: config.prHeadCommit,
});

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

0 comments on commit 919bd89

Please sign in to comment.