diff --git a/bot.json b/bot.json index a43eb55..60f4c52 100644 --- a/bot.json +++ b/bot.json @@ -5,8 +5,16 @@ }, "environments": { "default": { - "warmup": 4, - "timeout": 3000, + "warmup": 3, + "timeout": 4000, + "isolated": false, + "path": "docker/runner-default", + "overrides": ["meta.json_reporter.binary_files = true"] + }, + "isolated": { + "warmup": 2, + "timeout": 30000, + "isolated": true, "path": "docker/runner-default", "overrides": ["meta.json_reporter.binary_files = true"] } diff --git a/infra/cloud-config.yaml b/infra/cloud-config.yaml index bdd38e8..b81bda9 100644 --- a/infra/cloud-config.yaml +++ b/infra/cloud-config.yaml @@ -56,10 +56,16 @@ write_files: "default": { "warmup": 3, "timeout": 4000, + "isolated": false, "path": "https://github.com/mcbeet/beet-bot.git#main:docker/runner-default", - "overrides": [ - "meta.json_reporter.binary_files = true" - ] + "overrides": ["meta.json_reporter.binary_files = true"] + }, + "isolated": { + "warmup": 2, + "timeout": 30000, + "isolated": true, + "path": "https://github.com/mcbeet/beet-bot.git#main:docker/runner-default", + "overrides": ["meta.json_reporter.binary_files = true"] } } } diff --git a/packages/runner/src/build.ts b/packages/runner/src/build.ts index 3f77078..348265b 100644 --- a/packages/runner/src/build.ts +++ b/packages/runner/src/build.ts @@ -26,12 +26,12 @@ export const createBuilder = ({ warmup, timeout, setup }: BuilderOptions): Build return new Promise((resolve, reject) => { handle.on('spawn', () => { - console.log(`INFO: Successfully spawned worker #${handle.pid}`) + console.log(`INFO: Successfully spawned idle worker #${handle.pid}`) resolve({ handle, stop }) }) handle.on('error', (err) => { - console.log('WARN: Failed to spawn worker') + console.log('WARN: Failed to spawn idle worker') reject(err) }) }) diff --git a/packages/runner/src/docker.ts b/packages/runner/src/docker.ts index ebd77e5..b8d0b6b 100644 --- a/packages/runner/src/docker.ts +++ b/packages/runner/src/docker.ts @@ -14,7 +14,7 @@ export const deleteDockerBuilder = async (name: string) => { } } -export const setupDockerBuilder = async (name: string, path: string, overrides: string[] = []) => { +export const setupDockerBuilder = async (name: string, path: string, isolated: boolean, overrides: string[] = []) => { const tag = getDockerImageTag(name) try { @@ -30,7 +30,7 @@ export const setupDockerBuilder = async (name: string, path: string, overrides: const container = `${tag}-${id}` const handle = execa('docker', [ - 'run', '--name', container, '--rm', '-i', tag, + 'run', '--name', container, ...(isolated ? ['--network', 'none'] : []), '--rm', '-i', tag, 'beet', '-p', '@beet/preset_stdin.yml', ...overrides.flatMap(override => ['-s', override]), 'build', '--json' ]) diff --git a/packages/runner/src/pool.ts b/packages/runner/src/pool.ts index a650826..8e72e9b 100644 --- a/packages/runner/src/pool.ts +++ b/packages/runner/src/pool.ts @@ -9,6 +9,7 @@ export type PoolRunner = { export type EnvironmentOptions = { warmup: number timeout: number + isolated: boolean path: string overrides?: string[] } @@ -17,7 +18,7 @@ export const createPoolRunner = (environments: Record() for (const name in environments) { - const { warmup, timeout, path, overrides } = environments[name] + const { warmup, timeout, isolated, path, overrides } = environments[name] builders.set(name, createBuilder({ warmup, timeout, @@ -25,7 +26,7 @@ export const createPoolRunner = (environments: Record