Skip to content

Commit 2a7ecf6

Browse files
authored
refactor: improves run action (#77)
1 parent 2cc52cb commit 2a7ecf6

File tree

11 files changed

+169
-43
lines changed

11 files changed

+169
-43
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ on:
77
type: string
88
required: false
99
default: latest
10+
local:
11+
description: Forces local mode
12+
required: false
13+
type: string
14+
default: "false"
15+
verbosity:
16+
description: The verbosity level to use
17+
required: false
18+
type: string
19+
default: "info"
1020
secrets:
1121
earthly_token:
1222
description: Optional Earthly token used to login to Earthly cloud during local builds of Forge CLI
@@ -76,6 +86,8 @@ jobs:
7686
with:
7787
earthfiles: ${{ toJson(fromJson(needs.discover.outputs.earthfiles)['^check(-.*)?$']) }}
7888
forge_version: ${{ inputs.forge_version }}
89+
local: ${{ inputs.local }}
90+
verbosity: ${{ inputs.verbosity }}
7991
secrets:
8092
earthly_token: ${{ secrets.earthly_token }}
8193

@@ -86,6 +98,8 @@ jobs:
8698
with:
8799
earthfiles: ${{ toJson(fromJson(needs.discover.outputs.earthfiles)['^build(-.*)?$']) }}
88100
forge_version: ${{ inputs.forge_version }}
101+
local: ${{ inputs.local }}
102+
verbosity: ${{ inputs.verbosity }}
89103
secrets:
90104
earthly_token: ${{ secrets.earthly_token }}
91105

@@ -96,6 +110,8 @@ jobs:
96110
with:
97111
earthfiles: ${{ toJson(fromJson(needs.discover.outputs.earthfiles)['^package(-.*)?$']) }}
98112
forge_version: ${{ inputs.forge_version }}
113+
local: ${{ inputs.local }}
114+
verbosity: ${{ inputs.verbosity }}
99115
secrets:
100116
earthly_token: ${{ secrets.earthly_token }}
101117

@@ -106,6 +122,8 @@ jobs:
106122
with:
107123
earthfiles: ${{ toJson(fromJson(needs.discover.outputs.earthfiles)['^test(-.*)?$']) }}
108124
forge_version: ${{ inputs.forge_version }}
125+
local: ${{ inputs.local }}
126+
verbosity: ${{ inputs.verbosity }}
109127
secrets:
110128
earthly_token: ${{ secrets.earthly_token }}
111129

@@ -126,6 +144,8 @@ jobs:
126144
with:
127145
releases: ${{ needs.discover.outputs.releases }}
128146
forge_version: ${{ inputs.forge_version }}
147+
local: ${{ inputs.local }}
148+
verbosity: ${{ inputs.verbosity }}
129149
secrets:
130150
earthly_token: ${{ secrets.earthly_token }}
131151

@@ -136,6 +156,8 @@ jobs:
136156
with:
137157
deployments: ${{ needs.discover.outputs.deployments }}
138158
forge_version: ${{ inputs.forge_version }}
159+
local: ${{ inputs.local }}
160+
verbosity: ${{ inputs.verbosity }}
139161
secrets:
140162
earthly_token: ${{ secrets.earthly_token }}
141163

.github/workflows/deploy.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ on:
1111
The version of the forge CLI to install (use 'local' for testing)
1212
required: true
1313
type: string
14+
local:
15+
description: Forces local mode
16+
required: false
17+
type: string
18+
default: "false"
19+
verbosity:
20+
description: The verbosity level to use
21+
required: false
22+
type: string
23+
default: "info"
1424
secrets:
1525
earthly_token:
1626
description: Optional Earthly token used to login to Earthly cloud during local builds of Forge CLI
@@ -55,5 +65,11 @@ jobs:
5565
with:
5666
skip_earthly: ${{ steps.local.outputs.skip }}
5767
- name: Deploy
58-
run: |
59-
forge -vv deploy ${{ matrix.deployment }}
68+
uses: input-output-hk/catalyst-forge/actions/run@master
69+
with:
70+
command: deploy
71+
args: ${{ matrix.deployment }}
72+
local: ${{ inputs.local }}
73+
verbosity: ${{ inputs.verbosity }}
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/docs.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ on:
1111
The version of the forge CLI to install (use 'local' for testing)
1212
required: true
1313
type: string
14+
local:
15+
description: Forces local mode
16+
required: false
17+
type: string
18+
default: "false"
19+
target_args:
20+
description: Extra arguments to pass to the target (if command is "run")
21+
required: false
22+
type: string
23+
default: ""
24+
verbosity:
25+
description: The verbosity level to use
26+
required: false
27+
type: string
28+
default: "info"
1429
secrets:
1530
earthly_token:
1631
description: Optional Earthly token used to login to Earthly cloud during local builds of Forge CLI
@@ -53,11 +68,12 @@ jobs:
5368
with:
5469
skip_earthly: ${{ steps.local.outputs.skip }}
5570
- name: Run
56-
id: run
5771
uses: input-output-hk/catalyst-forge/actions/run@master
5872
with:
59-
artifact: ${{ env.OUTPUT }}
60-
path: ${{ matrix.earthfile }}
73+
command: run
74+
args: --artifact ${{ env.OUTPUT }} ${{ matrix.earthfile }}
75+
local: ${{ inputs.local }}
76+
verbosity: ${{ inputs.verbosity }}
6177
env:
6278
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6379
- name: Set env

.github/workflows/dogfood.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ jobs:
1616
uses: ./.github/workflows/ci.yml
1717
with:
1818
forge_version: local
19+
verbosity: debug
1920
secrets:
2021
earthly_token: ${{ secrets.EARTHLY_TOKEN }}

.github/workflows/release.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ on:
1717
The version of the forge CLI to install (use 'local' for testing)
1818
required: true
1919
type: string
20+
local:
21+
description: Forces local mode
22+
required: false
23+
type: string
24+
default: "false"
25+
verbosity:
26+
description: The verbosity level to use
27+
required: false
28+
type: string
29+
default: "info"
2030
secrets:
2131
earthly_token:
2232
description: Optional Earthly token used to login to Earthly cloud during local builds of Forge CLI
@@ -58,12 +68,12 @@ jobs:
5868
uses: input-output-hk/catalyst-forge/actions/setup@master
5969
with:
6070
skip_earthly: ${{ steps.local.outputs.skip }}
61-
- name: Run
62-
run: |
63-
if [[ ${{ inputs.force }} == "true" ]]; then
64-
forge -vv release --force ${{ matrix.release.project }} ${{ matrix.release.name }}
65-
else
66-
forge -vv release ${{ matrix.release.project }} ${{ matrix.release.name }}
67-
fi
71+
- name: Release
72+
uses: input-output-hk/catalyst-forge/actions/run@master
73+
with:
74+
command: release
75+
args: ${{ matrix.release.project }} ${{ matrix.release.name }}
76+
local: ${{ inputs.local }}
77+
verbosity: ${{ inputs.verbosity }}
6878
env:
6979
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/run.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ on:
1111
The version of the forge CLI to install (use 'local' for testing)
1212
required: true
1313
type: string
14+
local:
15+
description: Forces local mode
16+
required: false
17+
type: string
18+
default: "false"
19+
target_args:
20+
description: Extra arguments to pass to the target (if command is "run")
21+
required: false
22+
type: string
23+
default: ""
24+
verbosity:
25+
description: The verbosity level to use
26+
required: false
27+
type: string
28+
default: "info"
1429
secrets:
1530
earthly_token:
1631
description: Optional Earthly token used to login to Earthly cloud during local builds of Forge CLI
@@ -53,6 +68,10 @@ jobs:
5368
- name: Run
5469
uses: input-output-hk/catalyst-forge/actions/run@master
5570
with:
56-
path: ${{ matrix.earthfile }}
71+
command: run
72+
args: ${{ matrix.earthfile }}
73+
local: ${{ inputs.local }}
74+
target_args: ${{ inputs.target_args }}
75+
verbosity: ${{ inputs.verbosity }}
5776
env:
5877
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

actions/run/action.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
name: Run
22
description: Execute Earthfiles
33
inputs:
4-
artifact:
5-
description: Dump all produced artifacts to the given path (ignored if empty).
4+
args:
5+
description: The arguments to pass
6+
required: false
67
default: ""
8+
command:
9+
description: The command to run
10+
required: true
711
local:
8-
description: Forces the target to run locally (ignores satellite).
12+
description: Forces local mode
13+
required: false
914
default: "false"
10-
path:
11-
description: The path to the Earthfile, including target (i.e. path/to/project+target)
12-
required: true
1315
target_args:
14-
description: Extra arguments to pass to the target
16+
description: Extra arguments to pass to the target (if command is "run")
1517
required: false
1618
default: ""
19+
verbosity:
20+
description: The verbosity level to use
21+
required: false
22+
default: "info"
1723
outputs:
1824
result:
19-
description: The result of the run
25+
description: The result of running the command
2026

2127
runs:
2228
using: node20

actions/run/dist/index.js

Lines changed: 28 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

actions/run/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

actions/run/src/main.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,47 @@ const exec = require("@actions/exec");
33

44
async function run() {
55
try {
6-
const artifact = core.getInput("artifact", { required: false });
6+
const args = core.getInput("args", { required: false });
7+
const command = core.getInput("command", { required: true });
78
const local = core.getBooleanInput("local", { required: false });
8-
const path = core.getInput("path", { required: true });
99
const targetArgs = core.getInput("target_args", { required: false });
10+
const verbosity = core.getInput("verbosity", { required: false });
11+
12+
let verbosityLevel = 0;
13+
switch (verbosity) {
14+
case "error":
15+
verbosityLevel = 1;
16+
break;
17+
case "info":
18+
verbosityLevel = 2;
19+
break;
20+
case "debug":
21+
verbosityLevel = 3;
22+
break;
23+
}
1024

11-
const args = ["-vv", "run", "--ci"];
25+
const forgeArgs = ["--ci"];
1226

13-
if (artifact !== "") {
14-
args.push("--artifact", artifact);
27+
if (verbosityLevel > 0) {
28+
forgeArgs.push(`-${"v".repeat(verbosityLevel)}`);
1529
}
1630

1731
if (local === true) {
18-
args.push("--local");
32+
forgeArgs.push("--local");
1933
}
2034

21-
args.push(path);
35+
forgeArgs.push(command);
36+
37+
if (args !== "") {
38+
forgeArgs.push(...args.split(" "));
39+
}
2240

2341
if (targetArgs !== "") {
24-
args.push("--", ...targetArgs.split(" "));
42+
forgeArgs.push("--", ...targetArgs.split(" "));
2543
}
2644

27-
core.info(`Running forge ${args.join(" ")}`);
28-
const result = await runForge(args);
45+
core.info(`Running forge ${forgeArgs.join(" ")}`);
46+
const result = await runForge(forgeArgs);
2947

3048
core.setOutput("result", result.stdout);
3149
} catch (error) {

0 commit comments

Comments
 (0)