Skip to content

Commit

Permalink
fix: Comments on Issues should not trigger 'checks' action (#759)
Browse files Browse the repository at this point in the history
Co-authored-by: Shine Lee <[email protected]>
  • Loading branch information
andekande and shine2lay committed Jun 20, 2024
1 parent c1751e2 commit 2ad0b2a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion __fixtures__/unit/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ module.exports = {
user: {
login: 'creator'
},
number: (options.number) ? options.number : 1
number: (options.number) ? options.number : 1,
pull_request: {}
}
},
log: {
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CHANGELOG
=====================================
| June 20, 2024: fix: Comments on Issues should not trigger `checks` action `#759 <https://github.com/mergeability/mergeable/pull/759>`_
| June 20, 2024: fix: Respect all comments in lastComment validator and comment action `#755 <https://github.com/mergeability/mergeable/pull/755>`_
| June 12, 2024: feat: Support `issue_comment` event as trigger for actions `#754 <https://github.com/mergeability/mergeable/pull/754>`_
| June 10, 2024: fix: Docker image not working `#753 <https://github.com/mergeability/mergeable/pull/753>`_
Expand Down
15 changes: 12 additions & 3 deletions lib/actions/checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const createChecks = async (context, payload, actionObj) => {
// Note: octokit (wrapped by probot) requires head_branch.
// Contradicting API docs that only requires head_sha
// --> https://developer.github.com/v3/checks/runs/#create-a-check-run
if (context.payload.checksuite) {
params.head_branch = context.payload.checksuite.head_branch
params.head_sha = context.payload.checksuite.head_sha
if (context.payload.check_suite) {
params.head_branch = context.payload.check_suite.head_branch
params.head_sha = context.payload.check_suite.head_sha
} else if (context.eventName === 'issue_comment') {
const issueNumber = context.payload.issue.number
const pullRequest = (await actionObj.githubAPI.getPR(context, issueNumber)).data
Expand Down Expand Up @@ -104,6 +104,9 @@ class Checks extends Action {
}

async beforeValidate (context, settings, name) {
if (context.eventName === 'issue_comment' && !context.payload.issue?.pull_request) {
return Promise.resolve()
}
const result = await createChecks(context, {
status: 'in_progress',
output: {
Expand All @@ -127,10 +130,16 @@ class Checks extends Action {
}

async run ({ context, settings, payload }) {
if (context.eventName === 'issue_comment' && !context.payload.issue?.pull_request) {
return Promise.resolve()
}
await createChecks(context, payload, this)
}

async afterValidate (context, settings, name, results) {
if (context.eventName === 'issue_comment' && !context.payload.issue?.pull_request) {
return Promise.resolve()
}
const checkRunResult = this.checkRunResult.get(name)
const payload = settings.payload ? this.populatePayloadWithResult(settings.payload, results, context) : undefined

Expand Down
3 changes: 3 additions & 0 deletions lib/actions/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class Merge extends Action {
async beforeValidate () {}

async afterValidate (context, settings, name, results) {
if (context.eventName === 'issue_comment' && !context.payload.issue?.pull_request) {
return Promise.resolve()
}
if (settings.merge_method && !MERGE_METHOD_OPTIONS.includes(settings.merge_method)) {
throw new UnSupportedSettingError(`Unknown Merge method, supported options are ${MERGE_METHOD_OPTIONS.join(', ')}`)
}
Expand Down

0 comments on commit 2ad0b2a

Please sign in to comment.