diff options
Diffstat (limited to 'worker/scripts/checkout_ci.ts')
-rwxr-xr-x | worker/scripts/checkout_ci.ts | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/worker/scripts/checkout_ci.ts b/worker/scripts/checkout_ci.ts index 6a1dcad..ac36d69 100755 --- a/worker/scripts/checkout_ci.ts +++ b/worker/scripts/checkout_ci.ts @@ -11,10 +11,11 @@ import { prependWith, TraceUtil, getStdoutMany, + IEither, } from '@emprespresso/pengueno'; import { mkdir, readFile, rm } from 'fs/promises'; import { join } from 'path'; -import { type CheckoutCiJob, type FetchCodeJob, PipelineImpl } from '@emprespresso/ci_model'; +import { type CheckoutCiJob, type FetchCodeJob, Pipeline, PipelineImpl } from '@emprespresso/ci_model'; import { executeJob, executePipeline } from '@emprespresso/ci_worker'; interface CiWorkflow { @@ -102,21 +103,24 @@ await LogMetricTraceable.ofLogTraceable(logTraceableJob) commands: getPipelineGenerationCommand(job, workflow), })); }) - .map(async (tEitherPipelineGenerationCommand) => { - const eitherJobCommand = await tEitherPipelineGenerationCommand.get(); - const pipelineSerialized = await eitherJobCommand.flatMapAsync(({ commands }) => - getStdoutMany( - tEitherPipelineGenerationCommand.move(commands).peek((t) => t.trace.trace(JSON.stringify(t.get()))), - ), - ); - return pipelineSerialized - .flatMap((results) => { - tEitherPipelineGenerationCommand.trace.trace(JSON.stringify(results)); - const pipeline = results.at(-1)!; - return PipelineImpl.from(pipeline); - }) - .joinRight(eitherJobCommand, (job, pipeline) => ({ job, pipeline })); - }) + .map( + async ( + tEitherPipelineGenerationCommand, + ): Promise<IEither<Error, { job: CheckoutCiJob; pipeline: Pipeline }>> => { + const eitherJobCommand = await tEitherPipelineGenerationCommand.get(); + const pipelineSerialized = await eitherJobCommand.flatMapAsync(({ commands }) => + getStdoutMany( + tEitherPipelineGenerationCommand.move(commands).peek((t) => t.trace.trace(JSON.stringify(t.get()))), + ), + ); + return pipelineSerialized + .flatMap((results) => { + const pipeline = results.at(-1)!; + return PipelineImpl.from(pipeline); + }) + .joinRight(eitherJobCommand, ({ job }, pipeline) => ({ job, pipeline })); + }, + ) .peek( TraceUtil.promiseify((tEitherPipeline) => tEitherPipeline |