export type JobState = 'pass' | 'fail' | 'running' | 'queued' | 'waiting' | 'skipped' | 'cancelled';
export type Step = { name: string; state: JobState; seconds: number | null; log: string[] };
export type Tests = { passed: number; failed: number; failures: { name: string; message: string }[] };
export type EnvName = 'staging' | 'production';
// What running the job's main step produces; a rerun replays it.
export type Script = { lines: string[]; seconds: number; outcome: 'pass' | 'fail' };
export type Gate = { reason: string; approvedBy: string | null; at: string | null };
export type Job = {
id: string;
name: string;
needs: string[];
state: JobState;
runner: string;
steps: Step[];
tests: Tests | null;
env: EnvName | null;
gate: Gate | null;
script: Script;
pending: string[];
};
export type RunEvent = { kind: 'pull'; pull: number } | { kind: 'push' } | { kind: 'schedule' } | { kind: 'release'; tag: string } | { kind: 'rollback'; tag: string };
export type Run = {
id: number;
workflow: 'CI' | 'Deploy' | 'Nightly';
event: RunEvent;
actor: string;
agent: boolean;
branch: string;
sha: string;
subject: string;
startedAt: string;
jobs: Job[];
artifacts: { name: string; mb: number }[];
note: { agent: string; text: string; pull: number | null } | null;
};
export type Deploy = { runId: number | null; sha: string; tag: string | null; at: string; by: string; agent: boolean };
export type Environment = { name: EnvName; url: string; instances: number; current: Deploy; previous: Deploy | null };