Diffinery

codician/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

174 lines · 4.7 KBRaw History
1/** Normalized workflow model produced by parseWorkflow(). */
2
3export interface WorkflowError {
4 /** Dotted path into the workflow, e.g. `jobs.build.steps[2].run`. */
5 path: string;
6 /** 1-based line in the YAML source, when known. */
7 line?: number;
8 /** 1-based column in the YAML source, when known. */
9 col?: number;
10 /** Message; warnings are prefixed with `warning:`. */
11 message: string;
12}
13
14export interface RefFilters {
15 branches?: string[];
16 branchesIgnore?: string[];
17 tags?: string[];
18 tagsIgnore?: string[];
19 paths?: string[];
20 pathsIgnore?: string[];
21}
22
23export interface PushTrigger extends RefFilters {}
24
25export interface PullRequestTrigger {
26 types?: string[];
27 branches?: string[];
28 branchesIgnore?: string[];
29 paths?: string[];
30 pathsIgnore?: string[];
31}
32
33export interface ScheduleTrigger {
34 cron: string;
35}
36
37export interface DispatchInput {
38 description?: string;
39 required?: boolean;
40 default?: unknown;
41 /** string | boolean | number | choice | environment (workflow_dispatch) — string | boolean | number (workflow_call). */
42 type?: string;
43 options?: string[];
44 deprecationMessage?: string;
45}
46
47export interface WorkflowDispatchTrigger {
48 inputs?: Record<string, DispatchInput>;
49}
50
51export interface WorkflowCallTrigger {
52 inputs?: Record<string, DispatchInput>;
53 outputs?: Record<string, { description?: string; value: string }>;
54 secrets?: Record<string, { description?: string; required?: boolean }>;
55}
56
57export interface WorkflowRunTrigger {
58 workflows?: string[];
59 types?: string[];
60 branches?: string[];
61 branchesIgnore?: string[];
62}
63
64/** Generic event configuration (issues, issue_comment, release, ...). */
65export interface ActivityTrigger {
66 types?: string[];
67 [key: string]: unknown;
68}
69
70export interface WorkflowOn {
71 push?: PushTrigger;
72 pull_request?: PullRequestTrigger;
73 pull_request_target?: PullRequestTrigger;
74 schedule?: ScheduleTrigger[];
75 workflow_dispatch?: WorkflowDispatchTrigger;
76 workflow_call?: WorkflowCallTrigger;
77 workflow_run?: WorkflowRunTrigger;
78 [event: string]: unknown;
79}
80
81export interface Defaults {
82 run?: { shell?: string; "working-directory"?: string };
83}
84
85export type Permissions = "read-all" | "write-all" | Record<string, string>;
86
87export interface Concurrency {
88 group: string;
89 /** Boolean, or an expression string evaluated at runtime. */
90 cancelInProgress: boolean | string;
91}
92
93export interface ContainerSpec {
94 image: string;
95 credentials?: { username?: string; password?: string };
96 env?: Record<string, string>;
97 ports?: Array<string | number>;
98 volumes?: string[];
99 options?: string;
100}
101
102export interface EnvironmentSpec {
103 name: string;
104 url?: string;
105}
106
107/** Compatible with `StepSpec` in @diffinery/shared. */
108export interface StepSpec {
109 id?: string;
110 name?: string;
111 if?: string;
112 run?: string;
113 uses?: string;
114 with?: Record<string, string>;
115 env?: Record<string, string>;
116 shell?: string;
117 "working-directory"?: string;
118 "continue-on-error"?: boolean | string;
119 "timeout-minutes"?: number | string;
120}
121
122export interface Strategy {
123 /** Raw matrix (map, or a `${{ }}` expression string); expand with expandMatrix(). */
124 matrix?: unknown;
125 /** Defaults to true; may be an expression string. */
126 failFast: boolean | string;
127 maxParallel?: number | string;
128}
129
130export interface Job {
131 key: string;
132 name?: string;
133 /** Runner labels; an expression string stays a single (unevaluated) entry. */
134 runsOn: string[];
135 /** Runner group, from `runs-on: { group: ... }`. */
136 runsOnGroup?: string;
137 needs: string[];
138 if?: string;
139 env: Record<string, string>;
140 defaults: Defaults;
141 outputs: Record<string, string>;
142 steps: StepSpec[];
143 strategy?: Strategy;
144 /** Defaults to 360; may be an expression string. */
145 timeoutMinutes: number | string;
146 /** Defaults to false; may be an expression string. */
147 continueOnError: boolean | string;
148 permissions?: Permissions;
149 concurrency?: Concurrency;
150 services?: Record<string, ContainerSpec>;
151 container?: ContainerSpec;
152 environment?: EnvironmentSpec;
153 /** Reusable workflow reference (`owner/repo/.github/workflows/x.yml@ref` or `./.github/workflows/x.yml`). */
154 uses?: string;
155 /** Inputs for a reusable workflow call (values keep their YAML types). */
156 with?: Record<string, unknown>;
157 secrets?: "inherit" | Record<string, string>;
158}
159
160export interface Workflow {
161 /** Path the workflow was loaded from, e.g. `.github/workflows/ci.yml`. */
162 path: string;
163 name?: string;
164 runName?: string;
165 on: WorkflowOn;
166 env: Record<string, string>;
167 defaults: Defaults;
168 permissions?: Permissions;
169 concurrency?: Concurrency;
170 /** Jobs keyed by job id, in file order. */
171 jobs: Record<string, Job>;
172 /** The YAML document as plain JS (aliases and merge keys resolved). */
173 raw: Record<string, unknown>;
174}