mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-14 16:46:43 +00:00
added force cleanup for network and cleanUp hook is cleaning up based on the label
This commit is contained in:
@@ -175,6 +175,7 @@ export async function containerNetworkPrune(): Promise<void> {
|
|||||||
const dockerArgs = [
|
const dockerArgs = [
|
||||||
'network',
|
'network',
|
||||||
'prune',
|
'prune',
|
||||||
|
'--force',
|
||||||
'--filter',
|
'--filter',
|
||||||
`label=${getRunnerLabel()}`
|
`label=${getRunnerLabel()}`
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { prepareJob, cleanupJob } from '../src/hooks'
|
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
import { cleanupJob, prepareJob } from '../src/hooks'
|
||||||
import TestSetup from './test-setup'
|
import TestSetup from './test-setup'
|
||||||
|
|
||||||
const prepareJobInputPath = path.resolve(
|
const prepareJobInputPath = path.resolve(
|
||||||
@@ -50,13 +50,6 @@ describe('cleanup job', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should cleanup successfully', async () => {
|
it('should cleanup successfully', async () => {
|
||||||
const prepareJobOutputContent = fs.readFileSync(
|
await expect(cleanupJob()).resolves.not.toThrow()
|
||||||
prepareJobOutputPath,
|
|
||||||
'utf-8'
|
|
||||||
)
|
|
||||||
const parsedPrepareJobOutput = JSON.parse(prepareJobOutputContent)
|
|
||||||
await expect(
|
|
||||||
cleanupJob(prepareJobData.args, parsedPrepareJobOutput.state, null)
|
|
||||||
).resolves.not.toThrow()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ jest.useRealTimers()
|
|||||||
|
|
||||||
describe('container pull', () => {
|
describe('container pull', () => {
|
||||||
it('should fail', async () => {
|
it('should fail', async () => {
|
||||||
const arg = { image: 'doesNotExist' }
|
const arg = { image: 'does-not-exist' }
|
||||||
await expect(containerPull(arg.image, '')).rejects.toThrow()
|
await expect(containerPull(arg.image, '')).rejects.toThrow()
|
||||||
})
|
})
|
||||||
it('should succeed', async () => {
|
it('should succeed', async () => {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import {
|
|
||||||
prepareJob,
|
|
||||||
cleanupJob,
|
|
||||||
runScriptStep,
|
|
||||||
runContainerStep
|
|
||||||
} from '../src/hooks'
|
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
import {
|
||||||
|
cleanupJob,
|
||||||
|
prepareJob,
|
||||||
|
runContainerStep,
|
||||||
|
runScriptStep
|
||||||
|
} from '../src/hooks'
|
||||||
import TestSetup from './test-setup'
|
import TestSetup from './test-setup'
|
||||||
|
|
||||||
const prepareJobJson = fs.readFileSync(
|
const prepareJobJson = fs.readFileSync(
|
||||||
@@ -83,7 +83,7 @@ describe('e2e', () => {
|
|||||||
await expect(
|
await expect(
|
||||||
runContainerStep(containerStepData.args, resp.state)
|
runContainerStep(containerStepData.args, resp.state)
|
||||||
).resolves.not.toThrow()
|
).resolves.not.toThrow()
|
||||||
await expect(cleanupJob(resp, resp.state, null)).resolves.not.toThrow()
|
await expect(cleanupJob()).resolves.not.toThrow()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should prepare job, then run script step, then run container step with Dockerfile then cleanup', async () => {
|
it('should prepare job, then run script step, then run container step with Dockerfile then cleanup', async () => {
|
||||||
@@ -112,6 +112,6 @@ ENTRYPOINT [ "tail", "-f", "/dev/null" ]
|
|||||||
await expect(
|
await expect(
|
||||||
runContainerStep(containerStepDataCopy.args, resp.state)
|
runContainerStep(containerStepDataCopy.args, resp.state)
|
||||||
).resolves.not.toThrow()
|
).resolves.not.toThrow()
|
||||||
await expect(cleanupJob(resp, resp.state, null)).resolves.not.toThrow()
|
await expect(cleanupJob()).resolves.not.toThrow()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user