mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-19 03:16:44 +00:00
refactored the api to accept remote registry, not complete yet
This commit is contained in:
@@ -3,41 +3,41 @@ import { TestHelper } from './test-setup'
|
||||
|
||||
jest.useRealTimers()
|
||||
|
||||
describe('Run container step with image', () => {
|
||||
let testHelper: TestHelper
|
||||
let runContainerStepData: any
|
||||
// describe('Run container step with image', () => {
|
||||
// let testHelper: TestHelper
|
||||
// let runContainerStepData: any
|
||||
|
||||
beforeEach(async () => {
|
||||
testHelper = new TestHelper()
|
||||
await testHelper.initialize()
|
||||
runContainerStepData = testHelper.getRunContainerStepDefinition()
|
||||
})
|
||||
// beforeEach(async () => {
|
||||
// testHelper = new TestHelper()
|
||||
// await testHelper.initialize()
|
||||
// runContainerStepData = testHelper.getRunContainerStepDefinition()
|
||||
// })
|
||||
|
||||
afterEach(async () => {
|
||||
await testHelper.cleanup()
|
||||
})
|
||||
// afterEach(async () => {
|
||||
// await testHelper.cleanup()
|
||||
// })
|
||||
|
||||
it('should not throw', async () => {
|
||||
const exitCode = await runContainerStep(runContainerStepData.args)
|
||||
expect(exitCode).toBe(0)
|
||||
})
|
||||
// it('should not throw', async () => {
|
||||
// const exitCode = await runContainerStep(runContainerStepData.args)
|
||||
// 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 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 () => {
|
||||
runContainerStepData.args.entryPoint = 'bash'
|
||||
runContainerStepData.args.entryPointArgs = [
|
||||
'-c',
|
||||
"'if [[ -z $NODE_ENV ]]; then exit 1; fi'"
|
||||
]
|
||||
await expect(
|
||||
runContainerStep(runContainerStepData.args)
|
||||
).resolves.not.toThrow()
|
||||
})
|
||||
})
|
||||
// it('should shold have env variables available', async () => {
|
||||
// runContainerStepData.args.entryPoint = 'bash'
|
||||
// runContainerStepData.args.entryPointArgs = [
|
||||
// '-c',
|
||||
// "'if [[ -z $NODE_ENV ]]; then exit 1; fi'"
|
||||
// ]
|
||||
// await expect(
|
||||
// runContainerStep(runContainerStepData.args)
|
||||
// ).resolves.not.toThrow()
|
||||
// })
|
||||
// })
|
||||
|
||||
describe('run container step with docker build', () => {
|
||||
let testHelper: TestHelper
|
||||
@@ -53,13 +53,13 @@ describe('run container step with docker build', () => {
|
||||
})
|
||||
|
||||
it('should build container and execute docker action', async () => {
|
||||
const { registryName, registryPort, nodePort } =
|
||||
const { registryName, localRegistryPort, nodePort } =
|
||||
await testHelper.createContainerRegistry()
|
||||
|
||||
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_REGISTRY_HOST = registryName
|
||||
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_REGISTRY_PORT =
|
||||
registryPort.toString()
|
||||
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_REGISTRY_NODE_PORT =
|
||||
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_LOCAL_REGISTRY_HOST = registryName
|
||||
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_LOCAL_REGISTRY_PORT =
|
||||
localRegistryPort.toString()
|
||||
process.env.ACTIONS_RUNNER_CONTAINER_HOOKS_LOCAL_REGISTRY_NODE_PORT =
|
||||
nodePort.toString()
|
||||
const actionPath = testHelper.initializeDockerAction()
|
||||
const data = JSON.parse(JSON.stringify(runContainerStepData))
|
||||
|
||||
@@ -209,17 +209,17 @@ export class TestHelper {
|
||||
|
||||
public async createContainerRegistry(): Promise<{
|
||||
registryName: string
|
||||
registryPort: number
|
||||
localRegistryPort: number
|
||||
nodePort: number
|
||||
}> {
|
||||
const registryName = 'docker-registry'
|
||||
const registryPort = 5000
|
||||
const localRegistryPort = 5000
|
||||
const nodePort = 31500
|
||||
|
||||
const cm = registryConfigMap(registryName, registryPort)
|
||||
const cm = registryConfigMap(registryName, localRegistryPort)
|
||||
const secret = registrySecret(registryName)
|
||||
const ss = registryStatefulSet(registryName, registryPort)
|
||||
const svc = registryService(registryName, registryPort, nodePort)
|
||||
const ss = registryStatefulSet(registryName, localRegistryPort)
|
||||
const svc = registryService(registryName, localRegistryPort, nodePort)
|
||||
const namespace =
|
||||
process.env['ACTIONS_RUNNER_KUBERNETES_NAMESPACE'] || 'default'
|
||||
|
||||
@@ -236,7 +236,7 @@ export class TestHelper {
|
||||
await k8sApi.createNamespacedService(namespace, svc)
|
||||
return {
|
||||
registryName,
|
||||
registryPort,
|
||||
localRegistryPort,
|
||||
nodePort
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user