Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Relegate unhelpful container id message to core.info instead
Barry Gordon committed Mar 8, 2022

Unverified

No user is associated with the committer email.
1 parent 2e5a468 commit 0edc582
Showing 3 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion __tests__/container-service.test.ts
@@ -40,7 +40,7 @@ describe('ContainerService', () => {

test('raises an exception', async () => {
await expect(ContainerService.run(container)).rejects.toThrow(
/Failure running container/
/The updater encountered one or more errors/
)
})
})
37 changes: 36 additions & 1 deletion __tests__/main.test.ts
@@ -3,6 +3,7 @@ import path from 'path'
import * as core from '@actions/core'
import {Context} from '@actions/github/lib/context'
import {ApiClient} from '../src/api-client'
import {ContainerRuntimeError} from '../src/container-service'
import {Updater, UpdaterFetchError} from '../src/updater'
import {ImageService} from '../src/image-service'
import * as inputs from '../src/inputs'
@@ -242,7 +243,41 @@ describe('run', () => {
})
})

describe('when there is an error running the update', () => {
describe('when there the update container exits with an error signal', () => {
beforeEach(() => {
jest
.spyOn(Updater.prototype, 'runUpdater')
.mockImplementationOnce(
jest.fn(async () =>
Promise.reject(new ContainerRuntimeError('the container melted'))
)
)

context = new Context()
})

test('it fails the workflow', async () => {
await run(context)

expect(core.setFailed).toHaveBeenCalledWith(
`Dependabot encountered an error performing the update\n\nError: the container melted\n\nFor more information see: https://test.dev/foo/bar/network/updates/1 (write access required)`
)
})

test('it relays a failure message to the dependabot service', async () => {
await run(context)

expect(reportJobErrorSpy).toHaveBeenCalledWith({
'error-type': 'actions_workflow_updater',
'error-details': {
'action-error': 'the container melted'
}
})
expect(markJobAsProcessedSpy).toHaveBeenCalled()
})
})

describe('when there is an unexpected error running the update', () => {
beforeEach(() => {
jest
.spyOn(Updater.prototype, 'runUpdater')
5 changes: 3 additions & 2 deletions src/container-service.ts
@@ -4,7 +4,7 @@ import {pack} from 'tar-stream'
import {FileFetcherInput, FileUpdaterInput, ProxyConfig} from './config-types'
import {outStream, errStream} from './utils'

class ContainerRuntimeError extends Error {}
export class ContainerRuntimeError extends Error {}

export const ContainerService = {
async storeInput(
@@ -50,8 +50,9 @@ export const ContainerService = {
if (outcome.StatusCode === 0) {
return true
} else {
core.info(`Failure running container ${container.id}`)
throw new ContainerRuntimeError(
`Failure running container ${container.id}`
'The updater encountered one or more errors.'
)
}
} finally {

0 comments on commit 0edc582

Please sign in to comment.