@factorialco/gat 0.0.3 → 0.0.4

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.
@@ -1,6 +1,7 @@
1
1
  import { Job, JobOptions } from "./job";
2
2
  import type { Event, EventName, EventOptions } from "./event";
3
3
  import { BaseStep, Step } from "./step";
4
+ declare const DEFAULT_RUNNERS: string[];
4
5
  interface DefaultOptions {
5
6
  workingDirectory: string;
6
7
  }
@@ -8,7 +9,7 @@ interface EnvVar {
8
9
  name: string;
9
10
  value: string;
10
11
  }
11
- export declare class Workflow<JobStep extends BaseStep = Step, Runner = "ubuntu-22.04", JobName = never> {
12
+ export declare class Workflow<JobStep extends BaseStep = Step, Runner = typeof DEFAULT_RUNNERS, JobName = never> {
12
13
  name: string;
13
14
  events: Event[];
14
15
  jobs: Array<Job<JobStep, Runner, JobName>>;
@@ -20,6 +21,7 @@ export declare class Workflow<JobStep extends BaseStep = Step, Runner = "ubuntu-
20
21
  addJob<T extends string>(name: T, options: JobOptions<JobStep, Runner, JobName>): Workflow<JobStep, Runner, JobName | T>;
21
22
  setEnv(name: string, value: any): this;
22
23
  defaultRunner(): string;
24
+ private assignRunner;
23
25
  compile(): string;
24
26
  }
25
27
  export {};
package/dist/workflow.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Workflow = void 0;
7
7
  const yaml_1 = require("yaml");
8
8
  const kebabCase_1 = __importDefault(require("lodash/kebabCase"));
9
+ const DEFAULT_RUNNERS = ["ubuntu-22.04"];
9
10
  class Workflow {
10
11
  constructor(name) {
11
12
  this.name = name;
@@ -33,6 +34,11 @@ class Workflow {
33
34
  defaultRunner() {
34
35
  return "ubuntu-22.04";
35
36
  }
37
+ assignRunner(runsOn) {
38
+ const runnerName = runsOn ?? this.defaultRunner();
39
+ const isSelfHosted = !DEFAULT_RUNNERS.includes(runnerName);
40
+ return isSelfHosted ? ["self-hosted", runnerName] : [runnerName];
41
+ }
36
42
  compile() {
37
43
  const result = {
38
44
  name: this.name,
@@ -51,7 +57,7 @@ class Workflow {
51
57
  name,
52
58
  {
53
59
  if: ifExpression,
54
- "runs-on": runsOn ?? this.defaultRunner(),
60
+ "runs-on": this.assignRunner(runsOn),
55
61
  "timeout-minutes": timeout ?? 15,
56
62
  needs: dependsOn,
57
63
  services,
@@ -147,7 +147,7 @@ const workflow_1 = require("./workflow");
147
147
  (0, vitest_1.it)("allows custom types in a workflow", () => {
148
148
  const workflow = new workflow_1.Workflow("With custom types");
149
149
  workflow.on("push").addJob("job1", {
150
- runsOn: ["self-hosted", "standard-runner"],
150
+ runsOn: "standard-runner",
151
151
  steps: [
152
152
  {
153
153
  run: "echo 'Do something'",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/gat",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "TODO",
5
5
  "bin": {
6
6
  "gat": "dist/cli.js"