diff options
Diffstat (limited to 'worker/scripts/run_pipeline')
-rw-r--r-- | worker/scripts/run_pipeline | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/worker/scripts/run_pipeline b/worker/scripts/run_pipeline new file mode 100644 index 0000000..ad58573 --- /dev/null +++ b/worker/scripts/run_pipeline @@ -0,0 +1,28 @@ +#!/usr/bin/env -S deno --allow-env --allow-net --allow-read + +import { type Job, PipelineImpl } from "@liz-ci/model"; +import { getRequiredEnv, getStdout, validateIdentifier } from "@liz-ci/utils"; + +const stages = await (Deno.readTextFile(getRequiredEnv("pipeline"))) + .then(PipelineImpl.from) + .then((pipeline) => pipeline.getStages()); + +const validateJob = (job: Job) => { + Object.entries(job.arguments).forEach((e) => { + if (!e.every(validateIdentifier)) { + throw new Error(`job of type ${job.type} has invalid entry ${e}`); + } + }); +}; + +for (const stage of stages) { + await Promise.all( + stage.parallelJobs.map((job) => { + validateJob(job); + + return getStdout(job.type, { + env: job.arguments, + }); + }), + ); +} |