Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch -1 reaction failures #392

Merged
merged 1 commit into from
Jan 26, 2024
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
2 changes: 1 addition & 1 deletion src/backport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@
addReaction(octokit, task, Reaction.HOORAY)
} catch (e) {
// Add a thumbs down reaction to the comment to indicate that we failed
addReaction(octokit, task, Reaction.THUMBS_DOWN)
try {
addReaction(octokit, task, Reaction.THUMBS_DOWN)

Check warning on line 146 in src/backport.ts

View check run for this annotation

Codecov / codecov/patch

src/backport.ts#L146

Added line #L146 was not covered by tests
const failureComment = getFailureCommentBody(task, backportBranch, e?.message)
await commentOnPR(octokit, task, failureComment)
} catch (e) {
Expand Down
16 changes: 13 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createNodeMiddleware } from '@octokit/webhooks'
import { createServer } from 'http'
import { info, error } from 'node:console'
import { info, error, warn } from 'node:console'
import { Octokit } from '@octokit/rest'

import { addToQueue } from './queue'
Expand Down Expand Up @@ -167,7 +167,12 @@
const isMerged = typeof payload.issue?.pull_request?.merged_at === 'string'

if (isClosed && !isMerged) {
addReaction(authOctokit, { owner, repo, commentId } as Task, Reaction.THUMBS_DOWN)
try {
addReaction(authOctokit, { owner, repo, commentId } as Task, Reaction.THUMBS_DOWN)

Check warning on line 171 in src/index.ts

View check run for this annotation

Codecov / codecov/patch

src/index.ts#L170-L171

Added lines #L170 - L171 were not covered by tests
} catch (e) {
// Safely ignore
warn(`Failed to add reaction to comment: ${e.message}`)

Check warning on line 174 in src/index.ts

View check run for this annotation

Codecov / codecov/patch

src/index.ts#L174

Added line #L174 was not covered by tests
}
error(`Ignoring comment on closed but unmerged PR ${htmlUrl}`)
return
}
Expand Down Expand Up @@ -251,7 +256,12 @@
} catch (e) {
// This should really not happen, but if it does, we want to know about it
if (e instanceof Error) {
addReaction(authOctokit, { owner, repo, commentId } as Task, Reaction.THUMBS_DOWN)
try {
addReaction(authOctokit, { owner, repo, commentId } as Task, Reaction.THUMBS_DOWN)

Check warning on line 260 in src/index.ts

View check run for this annotation

Codecov / codecov/patch

src/index.ts#L259-L260

Added lines #L259 - L260 were not covered by tests
} catch (e) {
// Safely ignore
warn(`Failed to add reaction to comment: ${e.message}`)

Check warning on line 263 in src/index.ts

View check run for this annotation

Codecov / codecov/patch

src/index.ts#L263

Added line #L263 was not covered by tests
}
error(`Failed to handle backport request: ${e.message}`)
return
}
Expand Down
Loading