Skip to content

Commit

Permalink
Avoid outputting two annotations in setFailed
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry Gordon committed Mar 8, 2022
1 parent de52b25 commit 6269879
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ describe('run', () => {
process.env.GITHUB_ACTOR = 'dependabot[bot]'
process.env.GITHUB_WORKSPACE = workspace

process.env.GITHUB_SERVER_URL = 'https://test.dev'
process.env.GITHUB_REPOSITORY = 'foo/bar'

markJobAsProcessedSpy = jest.spyOn(
ApiClient.prototype,
'markJobAsProcessed'
Expand Down Expand Up @@ -130,7 +133,7 @@ describe('run', () => {
await run(context)

expect(core.setFailed).toHaveBeenCalledWith(
new Error('unexpected error retrieving job params')
`Error: unexpected error retrieving job params\n\nFor more information see: https://test.dev/foo/bar/network/updates/1 (write access required)`
)
})

Expand Down Expand Up @@ -159,7 +162,7 @@ describe('run', () => {
await run(context)

expect(core.setFailed).toHaveBeenCalledWith(
new Error('error getting job details')
`Error: error getting job details\n\nFor more information see: https://test.dev/foo/bar/network/updates/1 (write access required)`
)
})

Expand Down
8 changes: 5 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,16 @@ function botSay(message: string): void {
}

function setFailed(message: string | Error): void {
core.setFailed(message)
if (jobId) {
core.error(
message = [
message,
`For more information see: ${dependabotJobUrl(
jobId
)} (write access required)`
)
].join('\n\n')
}

core.setFailed(message)
}

function dependabotJobUrl(id: number): string {
Expand Down

0 comments on commit 6269879

Please sign in to comment.