Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15589,7 +15589,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12367,7 +12367,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/checkAndroidStatus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -737110,7 +737110,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11634,7 +11634,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/checkSVGCompression/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20159,7 +20159,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11853,7 +11853,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/formatCodeCovComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11821,7 +11821,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/getArtifactInfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11595,7 +11595,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11781,7 +11781,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/getPreviousVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11592,7 +11592,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/getPullRequestDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11724,7 +11724,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11826,7 +11826,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/isStagingDeployLocked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11595,7 +11595,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13047,7 +13047,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/postTestBuildComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11724,7 +11724,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
40 changes: 32 additions & 8 deletions .github/actions/javascript/proposalPoliceComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11596,6 +11596,28 @@ function isCommentCreatedEvent(payload) {
function isCommentEditedEvent(payload) {
return payload.action === CONST_1.default.ACTIONS.EDITED;
}
/**
* Checks if a comment body matches the criteria for a Proposal.
*/
function getIsProposal(body) {
if (!body) {
return false;
}
const lowerCaseBody = body.toLowerCase();
return body.includes(CONST_1.default.PROPOSAL_KEYWORD) && lowerCaseBody.includes(CONST_1.default.PROPOSAL_HEADER_A) && lowerCaseBody.includes(CONST_1.default.PROPOSAL_HEADER_B);
}
/**
* Determines if a comment author is a known bot or a bot-type account.
*/
function getIsBotAuthor(user) {
if (!user) {
return false;
}
const knownBotLogins = [CONST_1.default.COMMENT.NAME_MELVIN_BOT, CONST_1.default.COMMENT.NAME_MELVIN_USER, CONST_1.default.COMMENT.NAME_CODEX, CONST_1.default.COMMENT.NAME_GITHUB_ACTIONS];
const isBotType = user.type === CONST_1.default.COMMENT.TYPE_BOT;
const isKnownLogin = knownBotLogins.includes(user.login ?? '');
return isBotType || isKnownLogin;
}
// Main function to process the workflow event
async function run() {
// Capture the timestamp immediately at the start of the run
Expand Down Expand Up @@ -11650,21 +11672,22 @@ async function run() {
core.endGroup();
let didFindDuplicate = false;
let originalProposal;
const isNewCommentAProposal = getIsProposal(newProposalBody);
if (!isNewCommentAProposal) {
console.log('New comment is not a proposal. Skipping duplicate check.');
return;
}
for (const previousProposal of commentsResponse) {
const body = previousProposal.body ?? '';
const lowerCaseBody = body.toLowerCase() ?? '';
const isProposal = !!body.includes(CONST_1.default.PROPOSAL_KEYWORD) && !!lowerCaseBody.includes(CONST_1.default.PROPOSAL_HEADER_A) && !!lowerCaseBody.includes(CONST_1.default.PROPOSAL_HEADER_B);
const isProposal = getIsProposal(body);
const previousProposalCreatedAt = new Date(previousProposal.created_at).getTime();
// Early continue if not a proposal or previous comment is newer than current one
if (!isProposal || previousProposalCreatedAt >= newProposalCreatedAt) {
continue;
}
const isAuthorBot = previousProposal.user?.login === CONST_1.default.COMMENT.NAME_MELVIN ||
previousProposal.user?.login === CONST_1.default.COMMENT.NAME_CODEX ||
previousProposal.user?.login === CONST_1.default.COMMENT.NAME_GITHUB_ACTIONS ||
previousProposal.user?.type === CONST_1.default.COMMENT.TYPE_BOT;
const isBotAuthor = getIsBotAuthor(previousProposal.user);
// Skip prompting if comment author is the GH bot
if (isAuthorBot) {
if (isBotAuthor) {
continue;
}
const duplicateCheckPrompt = proposalPolice_1.default.getPromptForNewProposalDuplicateCheck(previousProposal.body, newProposalBody);
Expand Down Expand Up @@ -11871,7 +11894,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@ function isCommentEditedEvent(payload: IssueCommentEvent): payload is IssueComme
return payload.action === CONST.ACTIONS.EDITED;
}

/**
* Checks if a comment body matches the criteria for a Proposal.
*/
function getIsProposal(body: string | null | undefined): boolean {
if (!body) {
return false;
}
const lowerCaseBody = body.toLowerCase();
return body.includes(CONST.PROPOSAL_KEYWORD) && lowerCaseBody.includes(CONST.PROPOSAL_HEADER_A) && lowerCaseBody.includes(CONST.PROPOSAL_HEADER_B);
}

/**
* Determines if a comment author is a known bot or a bot-type account.
*/
function getIsBotAuthor(user: {login?: string; type?: string} | null | undefined): boolean {
if (!user) {
return false;
}

const knownBotLogins: string[] = [CONST.COMMENT.NAME_MELVIN_BOT, CONST.COMMENT.NAME_MELVIN_USER, CONST.COMMENT.NAME_CODEX, CONST.COMMENT.NAME_GITHUB_ACTIONS];

const isBotType = user.type === CONST.COMMENT.TYPE_BOT;
const isKnownLogin = knownBotLogins.includes(user.login ?? '');

return isBotType || isKnownLogin;
}

// Main function to process the workflow event
async function run() {
// Capture the timestamp immediately at the start of the run
Expand Down Expand Up @@ -93,22 +120,24 @@ async function run() {

let didFindDuplicate = false;
let originalProposal: TupleToUnion<typeof commentsResponse> | undefined;

const isNewCommentAProposal = getIsProposal(newProposalBody);
if (!isNewCommentAProposal) {
console.log('New comment is not a proposal. Skipping duplicate check.');
return;
}

for (const previousProposal of commentsResponse) {
const body = previousProposal.body ?? '';
const lowerCaseBody = body.toLowerCase() ?? '';
const isProposal = !!body.includes(CONST.PROPOSAL_KEYWORD) && !!lowerCaseBody.includes(CONST.PROPOSAL_HEADER_A) && !!lowerCaseBody.includes(CONST.PROPOSAL_HEADER_B);
const isProposal = getIsProposal(body);
const previousProposalCreatedAt = new Date(previousProposal.created_at).getTime();
// Early continue if not a proposal or previous comment is newer than current one
if (!isProposal || previousProposalCreatedAt >= newProposalCreatedAt) {
continue;
}
const isAuthorBot =
previousProposal.user?.login === CONST.COMMENT.NAME_MELVIN ||
previousProposal.user?.login === CONST.COMMENT.NAME_CODEX ||
previousProposal.user?.login === CONST.COMMENT.NAME_GITHUB_ACTIONS ||
previousProposal.user?.type === CONST.COMMENT.TYPE_BOT;
const isBotAuthor = getIsBotAuthor(previousProposal.user);
// Skip prompting if comment author is the GH bot
if (isAuthorBot) {
if (isBotAuthor) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11605,7 +11605,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/reviewerChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11697,7 +11697,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/verifySignedCommits/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11637,7 +11637,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/javascript/waitForPreviousRuns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11646,7 +11646,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
3 changes: 2 additions & 1 deletion .github/libs/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const CONST = {
},
COMMENT: {
TYPE_BOT: 'Bot',
NAME_MELVIN: 'melvin-bot',
NAME_MELVIN_BOT: 'melvin-bot',
NAME_MELVIN_USER: 'MelvinBot',
NAME_CODEX: 'chatgpt-codex-connector',
NAME_GITHUB_ACTIONS: 'github-actions',
},
Expand Down
Loading