Skip to content

Commit

Permalink
added support for commit-info and gha info
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangarano committed Jan 10, 2024
1 parent fc6ad2c commit bdd028b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/cypress-cloud/lib/ciProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import debugFn from "debug";

import _ from "lodash";
import { ValidationError } from "./errors";
import { GhaEventData } from "./git";

const debug = debugFn("currents:ci");

Expand Down Expand Up @@ -650,6 +651,7 @@ type CiProviderData = {
defaultBranch?: string;
remoteBranch?: string;
runAttempt?: string;
ghaEventData?: GhaEventData;
};

interface ProviderCommitParamsRes {
Expand Down Expand Up @@ -713,7 +715,7 @@ export function getCommitParams() {
}

export function getCI(ciBuildId?: string) {
const params = getCiParams();
const params = getCiParams() as CiParams;
const provider = getCiProvider();
if (!ciBuildId) checkForCiBuildFromCi(provider);

Expand Down Expand Up @@ -741,7 +743,7 @@ export function getCommitDefaults(existingInfo: CiProviderData) {
existingInfo,
(
memo: { [memoKey: string]: string | null },
value: string,
value: string | GhaEventData,
key: string
) => {
return (memo[key] = _.defaultTo(value || commitParamsObj[key], null));
Expand Down
13 changes: 13 additions & 0 deletions packages/cypress-cloud/lib/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
import { commitInfo } from "@currents/commit-info";
import { getCommitDefaults } from "./ciProvider";

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 (projectRoot: string) => {
const commit = await commitInfo();
return getCommitDefaults({
Expand All @@ -11,5 +23,6 @@ export const getGitInfo = async (projectRoot: string) => {
authorName: commit.author,
message: commit.message,
sha: commit.sha,
ghaEventData: commit.ghaEventData,
});
};
2 changes: 1 addition & 1 deletion packages/cypress-cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"typescript": "^4.7.4"
},
"dependencies": {
"@currents/commit-info": "^1.0.0",
"@currents/commit-info": "1.0.1-beta.0",
"axios": "^1.2.0",
"axios-retry": "^3.4.0",
"bluebird": "^3.7.2",
Expand Down

0 comments on commit bdd028b

Please sign in to comment.