API

Jobs

Jobs are isolated machines that run your tasks

Jobs wrap your tasks, providing a runner and a context for your tasks to run in.

Using tasks directly - You can run tasks without wrapping with a job. A default job with the "ubuntu-4x" runner is created for you.

Example

.pandaci/example.workflow.ts
import { job } from "jsr:@pandaci/workflow"

// Simple job
await job("A very cool job", () => {
  // ...
})


// Job with a custom runner
await job("A very cool job", { runner: "ubuntu-8x" }, () => {
  // ...
})

Methods

job.if

The if method allows you to skip a job based on a condition.

job.if(env.PANDACI_BRANCH === "main")("Skip this job", () => {
  // ...
})

job.nothrow

The nothrow method allows you to suppress errors if the condition is met.

job.nothrow("Skip this job", () => {
  // ...
})

job.skip

The skip method allows you to skip a job if the condition is met.

job.skip("Skip this job", () => {
  // ...
})

Job options

  • runner - The runner to use for this job. Defaults to "ubuntu-4x".
  • skip - Skip this job if the condition is met. Defaults to false.
  • throws - Throw an error if the condition is met. Defaults to true.

Return value

JobPromise

The promise returned when a job is awaited. It's an extension of Promise<JobResult>.

JobResult

The result of a job. This is whats returned when a job is awaited.

PropertyTypeDescription
namestringThe name of the job.
conclusionConclusion ('success' | 'failure' | 'skipped')The conclusion of the job.
isFailurebooleanTrue if the job failed.
isSuccessbooleanTrue if the job succeeded.
isSkippedbooleanTrue if the job was skipped.
idstringThe id of the job.
runnerstringThe runner used for the job.

JobError

Thrown when a job fails.

PropertyTypeDescription
conclusionConclusion ('success' | 'failure' | 'skipped')The conclusion of the job.
isFailurebooleanTrue if the job failed.
isSuccessbooleanTrue if the job succeeded.
isSkippedbooleanTrue if the job was skipped.
idstringThe id of the job.
runnerstringThe runner used for the job.
jobNamestringThe name of the job.

Usage

import { job, type JobError } from "jsr:@pandaci/workflow"

job("A job", () => {
 // A failing task
}).catch((error: JobError) => {
  console.log(error.jobName)
})