Skip to content

Commit eb058b5

Browse files
authored
handling for fail (#55)
Signed-off-by: Piotr Karpala <[email protected]>
1 parent eac31bc commit eb058b5

File tree

5 files changed

+26
-18
lines changed

5 files changed

+26
-18
lines changed

__tests__/main.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ describe('action', () => {
201201
expect(createCommentMock).toHaveBeenCalled()
202202
})
203203

204-
it('sets a failed status when github fails', async () => {
204+
it('doesnt set failed status when github fails', async () => {
205205
// Set the action's inputs as return values from core.getInput()
206206
mockInput()
207207
createChecksMock.mockRejectedValue(new Error('Failed to create check'))
@@ -211,7 +211,7 @@ describe('action', () => {
211211
expect(runMock).toHaveReturned()
212212

213213
// Verify that all of the core library functions were called correctly
214-
expect(setFailedMock).toHaveBeenNthCalledWith(1, 'Failed to create comment')
214+
expect(setFailedMock).toHaveBeenCalledTimes(0)
215215
})
216216

217217
it('fails if no pylint file provided', async () => {

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 11 additions & 7 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/main.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,17 @@ async function run() {
9898
core.debug(
9999
`Trying to add a comment instead for repo:${repo_name} owner:${repo_owner} issue:${issueNumber}`
100100
)
101-
const commentResp = await octokit.rest.issues.createComment({
102-
owner: repo_owner,
103-
repo: repo_name,
104-
issue_number: issueNumber,
105-
body: comment
106-
})
107-
core.debug(`response from comment create: ${commentResp.status}`)
101+
try {
102+
const commentResp = await octokit.rest.issues.createComment({
103+
owner: repo_owner,
104+
repo: repo_name,
105+
issue_number: issueNumber,
106+
body: comment
107+
})
108+
core.debug(`response from comment create: ${commentResp.status}`)
109+
} catch (commentError) {
110+
core.error(`Error creating comment: ${commentError}`)
111+
}
108112
}
109113
}
110114

0 commit comments

Comments
 (0)