@factorialco/gat 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/job.d.ts +6 -4
- package/dist/workflow.d.ts +2 -2
- package/dist/workflow.js +42 -38
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Workflow } from "./workflow";
|
|
2
|
-
import { type ConcurrencyGroup, type
|
|
2
|
+
import { type ConcurrencyGroup, type StepsJobOptions, type UsesJobOptions, type Matrix, type Service } from "./job";
|
|
3
3
|
import { type RunStep, type UseStep, type BaseStep } from "./step";
|
|
4
|
-
export { Workflow, RunStep, UseStep, BaseStep, ConcurrencyGroup,
|
|
4
|
+
export { Workflow, RunStep, UseStep, BaseStep, ConcurrencyGroup, StepsJobOptions, UsesJobOptions, Matrix, Service, };
|
package/dist/job.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface Service {
|
|
|
20
20
|
options?: string;
|
|
21
21
|
volumes?: string[];
|
|
22
22
|
}
|
|
23
|
-
export interface
|
|
23
|
+
export interface BaseJobOptions<RunnerDefinition, Name> {
|
|
24
24
|
prettyName?: string;
|
|
25
25
|
permissions?: object;
|
|
26
26
|
ifExpression?: string;
|
|
@@ -31,11 +31,13 @@ export interface JobOptions<Step, RunnerDefinition, Name> {
|
|
|
31
31
|
env?: Record<string, string>;
|
|
32
32
|
concurrency?: ConcurrencyGroup | null;
|
|
33
33
|
matrix?: Matrix | string;
|
|
34
|
-
steps: Step[];
|
|
35
34
|
outputs?: Record<string, string>;
|
|
36
35
|
workingDirectory?: string;
|
|
37
36
|
}
|
|
38
|
-
export interface
|
|
37
|
+
export interface StepsJobOptions<Step, RunnerDefinition, Name> extends BaseJobOptions<RunnerDefinition, Name> {
|
|
38
|
+
steps: Step[];
|
|
39
|
+
}
|
|
40
|
+
export interface UsesJobOptions<RunnerDefinition, Name> extends BaseJobOptions<RunnerDefinition, Name> {
|
|
39
41
|
uses: string;
|
|
40
42
|
with?: Record<string, string | number | boolean | object>;
|
|
41
43
|
secrets?: Record<string, string | number | boolean | object> | "inherit";
|
|
@@ -43,5 +45,5 @@ export interface UsesJobOptions {
|
|
|
43
45
|
export type StringWithNoSpaces<T> = T extends `${string} ${string}` ? never : T extends ` ${string}` ? never : T extends `${string} ` ? never : T;
|
|
44
46
|
export interface Job<Step, RunnerDefinition, Name> {
|
|
45
47
|
name: string;
|
|
46
|
-
options:
|
|
48
|
+
options: StepsJobOptions<Step, RunnerDefinition, Name> | UsesJobOptions<RunnerDefinition, Name>;
|
|
47
49
|
}
|
package/dist/workflow.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConcurrencyGroup, Job,
|
|
1
|
+
import { ConcurrencyGroup, Job, StepsJobOptions, StringWithNoSpaces, UsesJobOptions } from "./job";
|
|
2
2
|
import type { Event, EventName, EventOptions } from "./event";
|
|
3
3
|
import { type Step } from "./step";
|
|
4
4
|
interface DefaultOptions {
|
|
@@ -22,7 +22,7 @@ export declare class Workflow<JobStep extends Step = Step, Runner extends Runner
|
|
|
22
22
|
constructor(name: string);
|
|
23
23
|
on<T extends EventName>(name: T, options?: EventOptions<T>): this;
|
|
24
24
|
addDefaults(options: DefaultOptions): this;
|
|
25
|
-
addJob<T extends string>(name: StringWithNoSpaces<T>, options:
|
|
25
|
+
addJob<T extends string>(name: StringWithNoSpaces<T>, options: StepsJobOptions<JobStep, Runner, JobName> | UsesJobOptions<Runner, JobName>): Workflow<JobStep, Runner, JobName | T>;
|
|
26
26
|
setEnv(name: string, value: string): this;
|
|
27
27
|
setConcurrencyGroup(concurrencyGroup: ConcurrencyGroup | null): this;
|
|
28
28
|
defaultRunner(): string;
|
package/dist/workflow.js
CHANGED
|
@@ -91,56 +91,61 @@ class Workflow {
|
|
|
91
91
|
? Object.fromEntries(this.env.map(({ name, value }) => [name, value]))
|
|
92
92
|
: undefined,
|
|
93
93
|
jobs: Object.fromEntries(await Promise.all(this.jobs.map(async ({ name, options: jobOptions }) => {
|
|
94
|
+
const { prettyName, permissions, ifExpression, runsOn, matrix, env, dependsOn, services, timeout, concurrency, outputs, workingDirectory, } = jobOptions;
|
|
95
|
+
const computedOptions = {
|
|
96
|
+
name: prettyName,
|
|
97
|
+
permissions,
|
|
98
|
+
if: ifExpression,
|
|
99
|
+
"runs-on": runsOn ?? this.defaultRunner(),
|
|
100
|
+
"timeout-minutes": timeout ?? 15,
|
|
101
|
+
needs: dependsOn,
|
|
102
|
+
services,
|
|
103
|
+
concurrency: concurrency
|
|
104
|
+
? {
|
|
105
|
+
group: `${(0, kebabCase_1.default)(this.name)}-${name}-${concurrency.groupSuffix}`,
|
|
106
|
+
"cancel-in-progress": concurrency.cancelPrevious,
|
|
107
|
+
}
|
|
108
|
+
: undefined,
|
|
109
|
+
strategy: matrix
|
|
110
|
+
? {
|
|
111
|
+
"fail-fast": false,
|
|
112
|
+
matrix: typeof matrix === "string"
|
|
113
|
+
? matrix
|
|
114
|
+
: {
|
|
115
|
+
...Object.fromEntries(matrix.elements.map(({ id, options }) => [
|
|
116
|
+
id,
|
|
117
|
+
options,
|
|
118
|
+
])),
|
|
119
|
+
include: matrix.extra,
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
: undefined,
|
|
123
|
+
env,
|
|
124
|
+
defaults: workingDirectory
|
|
125
|
+
? {
|
|
126
|
+
run: {
|
|
127
|
+
"working-directory": workingDirectory,
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
: undefined,
|
|
131
|
+
outputs,
|
|
132
|
+
};
|
|
94
133
|
if ("uses" in jobOptions) {
|
|
95
134
|
return [
|
|
96
135
|
name,
|
|
97
136
|
{
|
|
137
|
+
...computedOptions,
|
|
98
138
|
uses: jobOptions.uses,
|
|
99
139
|
with: jobOptions.with,
|
|
100
140
|
secrets: jobOptions.secrets,
|
|
101
141
|
},
|
|
102
142
|
];
|
|
103
143
|
}
|
|
104
|
-
const { prettyName, permissions, ifExpression, runsOn, matrix, env, steps, dependsOn, services, timeout, concurrency, outputs, workingDirectory, } = jobOptions;
|
|
105
144
|
return [
|
|
106
145
|
name,
|
|
107
146
|
{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if: ifExpression,
|
|
111
|
-
"runs-on": runsOn ?? this.defaultRunner(),
|
|
112
|
-
"timeout-minutes": timeout ?? 15,
|
|
113
|
-
needs: dependsOn,
|
|
114
|
-
services,
|
|
115
|
-
concurrency: concurrency
|
|
116
|
-
? {
|
|
117
|
-
group: `${(0, kebabCase_1.default)(this.name)}-${name}-${concurrency.groupSuffix}`,
|
|
118
|
-
"cancel-in-progress": concurrency.cancelPrevious,
|
|
119
|
-
}
|
|
120
|
-
: undefined,
|
|
121
|
-
strategy: matrix
|
|
122
|
-
? {
|
|
123
|
-
"fail-fast": false,
|
|
124
|
-
matrix: typeof matrix === "string"
|
|
125
|
-
? matrix
|
|
126
|
-
: {
|
|
127
|
-
...Object.fromEntries(matrix.elements.map(({ id, options }) => [
|
|
128
|
-
id,
|
|
129
|
-
options,
|
|
130
|
-
])),
|
|
131
|
-
include: matrix.extra,
|
|
132
|
-
},
|
|
133
|
-
}
|
|
134
|
-
: undefined,
|
|
135
|
-
env,
|
|
136
|
-
defaults: workingDirectory
|
|
137
|
-
? {
|
|
138
|
-
run: {
|
|
139
|
-
"working-directory": workingDirectory,
|
|
140
|
-
},
|
|
141
|
-
}
|
|
142
|
-
: undefined,
|
|
143
|
-
steps: await Promise.all(steps.map(async (step) => {
|
|
147
|
+
...computedOptions,
|
|
148
|
+
steps: await Promise.all(jobOptions.steps.map(async (step) => {
|
|
144
149
|
const { id, name, ifExpression, workingDirectory, continueOnError, timeout, ...options } = step;
|
|
145
150
|
return {
|
|
146
151
|
id,
|
|
@@ -153,7 +158,6 @@ class Workflow {
|
|
|
153
158
|
uses: await supplyChainAttack(step),
|
|
154
159
|
};
|
|
155
160
|
})),
|
|
156
|
-
outputs,
|
|
157
161
|
},
|
|
158
162
|
];
|
|
159
163
|
}))),
|