mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-13 16:16:46 +00:00
Add limitation and throw if an entrypoint is not specified for container step (#77)
This commit is contained in:
@@ -10,13 +10,7 @@ import {
|
|||||||
waitForJobToComplete,
|
waitForJobToComplete,
|
||||||
waitForPodPhases
|
waitForPodPhases
|
||||||
} from '../k8s'
|
} from '../k8s'
|
||||||
import {
|
import { containerVolumes, PodPhase } from '../k8s/utils'
|
||||||
containerVolumes,
|
|
||||||
DEFAULT_CONTAINER_ENTRY_POINT,
|
|
||||||
DEFAULT_CONTAINER_ENTRY_POINT_ARGS,
|
|
||||||
PodPhase,
|
|
||||||
writeEntryPointScript
|
|
||||||
} from '../k8s/utils'
|
|
||||||
import { JOB_CONTAINER_NAME } from './constants'
|
import { JOB_CONTAINER_NAME } from './constants'
|
||||||
|
|
||||||
export async function runContainerStep(
|
export async function runContainerStep(
|
||||||
@@ -82,17 +76,13 @@ function createPodSpec(
|
|||||||
const podContainer = new k8s.V1Container()
|
const podContainer = new k8s.V1Container()
|
||||||
podContainer.name = JOB_CONTAINER_NAME
|
podContainer.name = JOB_CONTAINER_NAME
|
||||||
podContainer.image = container.image
|
podContainer.image = container.image
|
||||||
|
podContainer.workingDir = container.workingDirectory
|
||||||
const { entryPoint, entryPointArgs } = container
|
podContainer.command = container.entryPoint
|
||||||
container.entryPoint = 'sh'
|
? [container.entryPoint]
|
||||||
|
: undefined
|
||||||
const { containerPath } = writeEntryPointScript(
|
podContainer.args = container.entryPointArgs?.length
|
||||||
container.workingDirectory,
|
? container.entryPointArgs
|
||||||
entryPoint || DEFAULT_CONTAINER_ENTRY_POINT,
|
: undefined
|
||||||
entryPoint ? entryPointArgs || [] : DEFAULT_CONTAINER_ENTRY_POINT_ARGS
|
|
||||||
)
|
|
||||||
container.entryPointArgs = ['-e', containerPath]
|
|
||||||
podContainer.command = [container.entryPoint, ...container.entryPointArgs]
|
|
||||||
|
|
||||||
if (secretName) {
|
if (secretName) {
|
||||||
podContainer.envFrom = [
|
podContainer.envFrom = [
|
||||||
|
|||||||
@@ -23,16 +23,11 @@ describe('Run container step', () => {
|
|||||||
expect(exitCode).toBe(0)
|
expect(exitCode).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should fail if the working directory does not exist', async () => {
|
|
||||||
runContainerStepData.args.workingDirectory = '/foo/bar'
|
|
||||||
await expect(runContainerStep(runContainerStepData.args)).rejects.toThrow()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should shold have env variables available', async () => {
|
it('should shold have env variables available', async () => {
|
||||||
runContainerStepData.args.entryPoint = 'bash'
|
runContainerStepData.args.entryPoint = 'bash'
|
||||||
runContainerStepData.args.entryPointArgs = [
|
runContainerStepData.args.entryPointArgs = [
|
||||||
'-c',
|
'-c',
|
||||||
"'if [[ -z $NODE_ENV ]]; then exit 1; fi'"
|
'if [[ -z $NODE_ENV ]]; then exit 1; fi'
|
||||||
]
|
]
|
||||||
await expect(
|
await expect(
|
||||||
runContainerStep(runContainerStepData.args)
|
runContainerStep(runContainerStepData.args)
|
||||||
|
|||||||
Reference in New Issue
Block a user