mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-14 08:36:45 +00:00
fixed prepare-job for docker to allow for no job container
This commit is contained in:
@@ -94,7 +94,10 @@ export async function prepareJob(
|
||||
)
|
||||
}
|
||||
|
||||
const isAlpine = await isContainerAlpine(containerMetadata!.id)
|
||||
let isAlpine = false
|
||||
if (containerMetadata?.id) {
|
||||
isAlpine = await isContainerAlpine(containerMetadata.id)
|
||||
}
|
||||
|
||||
if (containerMetadata?.id) {
|
||||
containerMetadata.ports = await containerPorts(containerMetadata.id)
|
||||
@@ -105,7 +108,10 @@ export async function prepareJob(
|
||||
}
|
||||
}
|
||||
|
||||
const healthChecks: Promise<void>[] = [healthCheck(containerMetadata!)]
|
||||
const healthChecks: Promise<void>[] = []
|
||||
if (containerMetadata) {
|
||||
healthChecks.push(healthCheck(containerMetadata))
|
||||
}
|
||||
for (const service of servicesMetadata) {
|
||||
healthChecks.push(healthCheck(service))
|
||||
}
|
||||
|
||||
@@ -118,4 +118,14 @@ describe('prepare job', () => {
|
||||
expect(redisServicePorts['80']).toBe('8080')
|
||||
expect(redisServicePorts['8080']).toBe('8088')
|
||||
})
|
||||
|
||||
it('should run prepare job without job container without exception', async () => {
|
||||
prepareJobDefinition.args.container = null
|
||||
const prepareJobOutput = testSetup.createOutputFile(
|
||||
'prepare-job-output.json'
|
||||
)
|
||||
await expect(
|
||||
prepareJob(prepareJobDefinition.args, prepareJobOutput)
|
||||
).resolves.not.toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -72,22 +72,22 @@ export async function prepareJob(
|
||||
new Set([PodPhase.PENDING])
|
||||
)
|
||||
core.debug('Job pod is ready for traffic')
|
||||
|
||||
let isAlpine = false
|
||||
try {
|
||||
isAlpine = await isPodContainerAlpine(
|
||||
createdPod.metadata.name,
|
||||
JOB_CONTAINER_NAME
|
||||
)
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to determine if the pod is alpine: ${err}`)
|
||||
}
|
||||
core.debug(`Setting isAlpine to ${isAlpine}`)
|
||||
generateResponseFile(responseFile, createdPod, isAlpine)
|
||||
} catch (err) {
|
||||
await prunePods()
|
||||
throw new Error(`Pod failed to come online with error: ${err}`)
|
||||
}
|
||||
|
||||
let isAlpine = false
|
||||
try {
|
||||
isAlpine = await isPodContainerAlpine(
|
||||
createdPod.metadata.name,
|
||||
JOB_CONTAINER_NAME
|
||||
)
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to determine if the pod is alpine: ${err}`)
|
||||
}
|
||||
core.debug(`Setting isAlpine to ${isAlpine}`)
|
||||
generateResponseFile(responseFile, createdPod, isAlpine)
|
||||
}
|
||||
|
||||
function generateResponseFile(
|
||||
|
||||
Reference in New Issue
Block a user