Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.4 KB
Raw Blame
import type { PRCheckJob, PRCheckStep } from './github/check-types'

export type StepOutcome = 'success' | 'failure' | 'skipped' | 'pending'

export function resolveStepOutcome(step: Pick<PRCheckStep, 'status' | 'conclusion'>): StepOutcome {
  switch (step.conclusion ?? step.status) {
    case 'success':
      return 'success'
    case 'failure':
    case 'failed':
    case 'action_required':
    case 'cancelled':
    case 'stale':
    case 'startup_failure':
    case 'timed_out':
      return 'failure'
    case 'skipped':
    case 'neutral':
      return 'skipped'
    case null:
    default:
      return 'pending'
  }
}

export type JobStepBreakdown = {
  failed: PRCheckStep[]
  succeeded: PRCheckStep[]
  skipped: PRCheckStep[]
  pending: PRCheckStep[]
  total: number
}

export function summarizeJobSteps(job: Pick<PRCheckJob, 'steps'>): JobStepBreakdown {
  const breakdown: JobStepBreakdown = {
    failed: [],
    succeeded: [],
    skipped: [],
    pending: [],
    total: job.steps.length
  }
  for (const step of job.steps) {
    switch (resolveStepOutcome(step)) {
      case 'failure':
        breakdown.failed.push(step)
        break
      case 'success':
        breakdown.succeeded.push(step)
        break
      case 'skipped':
        breakdown.skipped.push(step)
        break
      case 'pending':
        breakdown.pending.push(step)
        break
    }
  }
  return breakdown
}