Skip to content

Commit 6d20671

Browse files
committed
account for noopMode with issueops parameters
1 parent 94f5613 commit 6d20671

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

__tests__/functions/prechecks.test.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,3 +1472,52 @@ test('runs prechecks and finds that the IssueOps commands are valid with paramet
14721472

14731473
expect(infoMock).toHaveBeenCalledWith('issueops command used with parameters')
14741474
})
1475+
1476+
test('runs prechecks and finds that the IssueOps commands are valid with parameters and from a defined admin', async () => {
1477+
var octogoodres = octokit
1478+
octogoodres['rest']['repos']['getCollaboratorPermissionLevel'] = jest
1479+
.fn()
1480+
.mockReturnValueOnce({data: {permission: 'admin'}, status: 200})
1481+
octogoodres['graphql'] = jest.fn().mockReturnValue({
1482+
repository: {
1483+
pullRequest: {
1484+
reviewDecision: 'REVIEW_REQUIRED',
1485+
commits: {
1486+
nodes: [
1487+
{
1488+
commit: {
1489+
statusCheckRollup: {
1490+
state: 'SUCCESS'
1491+
}
1492+
}
1493+
}
1494+
]
1495+
}
1496+
}
1497+
}
1498+
})
1499+
jest.spyOn(isAdmin, 'isAdmin').mockImplementation(() => {
1500+
return true
1501+
})
1502+
expect(
1503+
await prechecks(
1504+
'.deploy noop to production',
1505+
'.deploy',
1506+
'noop',
1507+
'disabled',
1508+
'main',
1509+
'123',
1510+
true,
1511+
context,
1512+
octogoodres
1513+
)
1514+
).toStrictEqual({
1515+
message: '✔️ All CI checks passed and **noop** requested - OK',
1516+
noopMode: true,
1517+
ref: 'test-ref',
1518+
status: true
1519+
})
1520+
1521+
expect(infoMock).toHaveBeenCalledWith('issueops command used with parameters')
1522+
expect(infoMock).toHaveBeenCalledWith('noop mode used with parameters')
1523+
})

dist/index.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/functions/prechecks.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ export async function prechecks(
8181
// Check to see if the IssueOps command was used in a basic form with other params
8282
} else if (regexCommandWithParameters.test(comment)) {
8383
core.info(`issueops command used with parameters`)
84+
if (comment.includes(noop_trigger)) {
85+
core.info('noop mode used with parameters')
86+
noopMode = true
87+
}
8488
// If no regex patterns matched, the IssueOps command was used in an unsupported way
8589
} else {
8690
message = dedent(`

0 commit comments

Comments
 (0)