Skip to content
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
34 changes: 34 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,40 @@ describe('run', () => {
})
})

describe('when the package manager has no configured updater image', () => {
beforeEach(() => {
jest.spyOn(ImageService, 'pull')
jest.spyOn(ApiClient.prototype, 'getJobDetails').mockImplementationOnce(
jest.fn(async () => {
return {'package-manager': 'unknown_ecosystem'} as JobDetails
})
)
context = new Context()
})

test('it fails the workflow without attempting to pull images', async () => {
await run(context)

expect(core.setFailed).toHaveBeenCalledWith(
expect.stringContaining('Error fetching updater images')
)
// eslint-disable-next-line @typescript-eslint/unbound-method
expect(ImageService.pull).not.toHaveBeenCalled()
})

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

expect(reportJobErrorSpy).toHaveBeenCalledWith({
'error-type': 'actions_workflow_image',
'error-details': {
'action-error': expect.stringContaining('unknown_ecosystem')
}
})
expect(markJobAsProcessedSpy).toHaveBeenCalled()
})
})

describe('when there is an error pulling all images', () => {
beforeEach(() => {
jest
Expand Down
11 changes: 11 additions & 0 deletions dist/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ export async function run(context: Context): Promise<void> {
params.updaterImage || updaterImageName(details['package-manager'])
let proxyImage = PROXY_IMAGE_NAME

if (!updaterImage) {
await failJob(
apiClient,
'Error fetching updater images',
new Error(
`No updater image is configured for package manager '${details['package-manager']}' in this action revision`
),
DependabotErrorType.Image
)
return
}

// The sendMetrics function is used to send metrics to the API client.
// It uses the package manager as a tag to identify the metric.
const sendMetricsWithPackageManager: MetricReporter = async (
Expand Down
Loading