Skip to content

Commit 7745922

Browse files
authored
Merge pull request #329 from github/general-fixes
General Fixes + Dependency Updates
2 parents 597c245 + caf9784 commit 7745922

File tree

8 files changed

+54
-63
lines changed

8 files changed

+54
-63
lines changed

__tests__/functions/prechecks.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ test('runs prechecks and finds the commit fetched via the rest call does not mat
270270

271271
expect(await prechecks(context, octokit, data)).toStrictEqual({
272272
message:
273-
'### ⚠️ Cannot proceed with deployment\n\nThe commit sha from the PR head does not match the commit sha from the graphql query\n\n- sha: `abc123`\n- commit_oid: `evilcommit123`. This is unexpected and could be caused by a commit being pushed to the branch after the initial rest call was made. Please review your PR timeline and try again.',
273+
'### ⚠️ Cannot proceed with deployment\n\nThe commit sha from the PR head does not match the commit sha from the graphql query\n\n- sha: `abc123`\n- commit_oid: `evilcommit123`\n\nThis is unexpected and could be caused by a commit being pushed to the branch after the initial rest call was made. Please review your PR timeline and try again.',
274274
status: false
275275
})
276276
})
@@ -308,7 +308,7 @@ test('runs prechecks and fails due to bad user permissions', async () => {
308308
.mockReturnValueOnce({data: {permission: 'read'}, status: 200})
309309
expect(await prechecks(context, octokit, data)).toStrictEqual({
310310
message:
311-
'👋 __monalisa__, seems as if you have not admin/write/maintain permissions in this repo, permissions: read',
311+
'👋 @monalisa, that command requires the following permission(s): `admin/write/maintain`\n\nYour current permissions: `read`',
312312
status: false
313313
})
314314
})

__tests__/functions/valid-permissions.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test('determines that a user has does not valid permissions to invoke the Action
4646
})
4747

4848
expect(await validPermissions(octokit, context, permissions)).toEqual(
49-
'👋 __monalisa__, seems as if you have not write/maintain/admin permissions in this repo, permissions: read'
49+
'👋 @monalisa, that command requires the following permission(s): `write/maintain/admin`\n\nYour current permissions: `read`'
5050
)
5151
expect(setOutputMock).toHaveBeenCalledWith('actor', 'monalisa')
5252
})

__tests__/main.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ test('successfully runs the action in noop mode', async () => {
238238
expect(saveStateMock).toHaveBeenCalledWith('comment_id', 123)
239239
expect(saveStateMock).toHaveBeenCalledWith('ref', 'test-ref')
240240
expect(saveStateMock).toHaveBeenCalledWith('noop', true)
241+
expect(infoMock).toHaveBeenCalledWith(
242+
`🧑‍🚀 commit sha to noop: ${COLORS.highlight}deadbeef${COLORS.reset}`
243+
)
244+
expect(infoMock).toHaveBeenCalledWith(
245+
`🚀 ${COLORS.success}deployment started!${COLORS.reset} (noop)`
246+
)
241247
})
242248

243249
test('successfully runs the action in noop mode when using sticky_locks_for_noop set to true', async () => {

dist/index.js

Lines changed: 4 additions & 4 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.

package-lock.json

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

src/functions/prechecks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export async function prechecks(context, octokit, data) {
331331
// This could occur if the branch had a commit pushed to it in between the rest call and the graphql query
332332
// In this case, we should not proceed with the deployment as we cannot guarantee the sha is safe for a variety of reasons
333333
} else if (sha !== commit_oid) {
334-
message = `### ⚠️ Cannot proceed with deployment\n\nThe commit sha from the PR head does not match the commit sha from the graphql query\n\n- sha: \`${sha}\`\n- commit_oid: \`${commit_oid}\`. This is unexpected and could be caused by a commit being pushed to the branch after the initial rest call was made. Please review your PR timeline and try again.`
334+
message = `### ⚠️ Cannot proceed with deployment\n\nThe commit sha from the PR head does not match the commit sha from the graphql query\n\n- sha: \`${sha}\`\n- commit_oid: \`${commit_oid}\`\n\nThis is unexpected and could be caused by a commit being pushed to the branch after the initial rest call was made. Please review your PR timeline and try again.`
335335

336336
return {message: message, status: false}
337337

src/functions/valid-permissions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export async function validPermissions(
3030
// Check to ensure the user has at least write permission on the repo
3131
const actorPermission = permissionRes.data.permission
3232
if (!validPermissionsArray.includes(actorPermission)) {
33-
return `👋 __${
33+
return `👋 @${
3434
context.actor
35-
}__, seems as if you have not ${validPermissionsArray.join(
35+
}, that command requires the following permission(s): \`${validPermissionsArray.join(
3636
'/'
37-
)} permissions in this repo, permissions: ${actorPermission}`
37+
)}\`\n\nYour current permissions: \`${actorPermission}\``
3838
}
3939

4040
// Return true if the user has permissions

0 commit comments

Comments
 (0)