From 8dc12a1e77e9825363b31b8179f9b05188bdf99c Mon Sep 17 00:00:00 2001 From: Miguel Langarano Date: Sun, 21 Jan 2024 20:10:41 -0500 Subject: [PATCH] added gha commit info --- packages/cypress-cloud/lib/ciProvider.ts | 2 ++ packages/cypress-cloud/lib/git.ts | 31 +++++++++++++++++------- packages/cypress-cloud/package.json | 2 +- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/packages/cypress-cloud/lib/ciProvider.ts b/packages/cypress-cloud/lib/ciProvider.ts index f4d5533..e9fbd0e 100644 --- a/packages/cypress-cloud/lib/ciProvider.ts +++ b/packages/cypress-cloud/lib/ciProvider.ts @@ -31,6 +31,7 @@ import debugFn from "debug"; import _ from "lodash"; import { ValidationError } from "./errors"; +import { GhaEventData } from "./git"; const debug = debugFn("currents:ci"); @@ -650,6 +651,7 @@ type CiProviderData = { defaultBranch?: string; remoteBranch?: string; runAttempt?: string; + ghaEventData?: GhaEventData; }; interface ProviderCommitParamsRes { diff --git a/packages/cypress-cloud/lib/git.ts b/packages/cypress-cloud/lib/git.ts index 067dcc9..fd7742d 100644 --- a/packages/cypress-cloud/lib/git.ts +++ b/packages/cypress-cloud/lib/git.ts @@ -1,15 +1,28 @@ // @ts-ignore -import git from "@cypress/commit-info"; +import { commitInfo } from "@currents/commit-info"; import { getCommitDefaults } from "./ciProvider"; -export const getGitInfo = async (projectRoot: string) => { - const commitInfo = await git.commitInfo(projectRoot); +export type GhaEventData = { + headRef: string; + headSha: string; + baseRef: string; + baseSha: string; + issueUrl: string; + htmlUrl: string; + prTitle: string; + senderAvatarUrl: string; + senderHtmlUrl: string; +}; + +export const getGitInfo = async () => { + const commit = await commitInfo(); return getCommitDefaults({ - branch: commitInfo.branch, - remoteOrigin: commitInfo.remote, - authorEmail: commitInfo.email, - authorName: commitInfo.author, - message: commitInfo.message, - sha: commitInfo.sha, + branch: commit.branch, + remoteOrigin: commit.remote, + authorEmail: commit.email, + authorName: commit.author, + message: commit.message, + sha: commit.sha, + ghaEventData: commit.ghaEventData, }); }; diff --git a/packages/cypress-cloud/package.json b/packages/cypress-cloud/package.json index 7b1f799..8f158fa 100644 --- a/packages/cypress-cloud/package.json +++ b/packages/cypress-cloud/package.json @@ -53,7 +53,7 @@ "typescript": "^4.7.4" }, "dependencies": { - "@cypress/commit-info": "^2.2.0", + "@cypress/commit-info": "1.0.1-beta.0", "axios": "^1.2.0", "axios-retry": "^3.4.0", "bluebird": "^3.7.2",