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.

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