@effected/github-actions 0.35.0 → 0.36.1
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/Action.js +7 -7
- package/ActionCache.js +4 -4
- package/ActionEnvironment.js +1 -1
- package/ActionInput.js +1 -1
- package/ActionLogger.js +197 -64
- package/ActionManifest.js +2 -2
- package/ActionOutputs.js +2 -2
- package/ActionState.js +1 -1
- package/ActionsIdentityToken.js +2 -2
- package/ActionsProvenance.js +2 -2
- package/ActionsRegistryCredential.js +2 -2
- package/Artifact.js +3 -3
- package/BlobStore.githubCache.js +2 -2
- package/BlobStore.js +4 -4
- package/CacheKey.js +2 -2
- package/CheckDocument.js +1 -1
- package/Checkout.js +361 -0
- package/DetachedProcess.js +4 -4
- package/DryRun.js +1 -1
- package/GitHubMarkdown.js +1 -1
- package/GitHubToken.js +2 -2
- package/ManagedDocument.js +1 -1
- package/OidcTokenIssuer.js +7 -7
- package/PackageManagerInstaller.js +3 -3
- package/README.md +2 -1
- package/Secret.js +1 -1
- package/ToolInstaller.js +4 -4
- package/index.d.ts +569 -103
- package/index.js +3 -2
- package/internal/actionsResults.js +1 -1
- package/internal/blobCause.js +1 -1
- package/internal/blobTransport.js +2 -2
- package/internal/cacheService.js +1 -1
- package/internal/checkout/asciiTrim.js +18 -0
- package/internal/checkout/credentials.js +563 -0
- package/internal/checkout/directory.js +119 -0
- package/internal/checkout/inputs.js +130 -0
- package/internal/checkout/refs.js +143 -0
- package/internal/checkout/settings.js +144 -0
- package/internal/checkout/source.js +418 -0
- package/internal/checkout/unsafePullRequest.js +62 -0
- package/internal/digest.js +1 -1
- package/internal/pnpmExe.js +1 -1
- package/internal/stepLog.js +225 -0
- package/internal/twirp.js +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { CommandNeutralizer, WorkflowCommand } from "@effected/github-commands";
|
|
2
|
+
import { Context, Inspectable } from "effect";
|
|
3
|
+
|
|
4
|
+
// src/internal/stepLog.ts
|
|
5
|
+
/**
|
|
6
|
+
* The step the current fiber is inside, or `null`.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* A `Context.Reference` for the reason `ActiveBuffer` is one: concurrent steps each keep their own frame, and nothing
|
|
10
|
+
* has to be restored on any exit path.
|
|
11
|
+
*/
|
|
12
|
+
const ActiveStep = Context.Reference("@effected/github-actions/ActiveStep", { defaultValue: () => null });
|
|
13
|
+
/** Open a step: a new outermost run, or a frame nested in `parent`'s run. */
|
|
14
|
+
const open = (name, parent, console, canFold, streaming, minimum) => parent === null ? {
|
|
15
|
+
name,
|
|
16
|
+
run: {
|
|
17
|
+
name: singleLine(name),
|
|
18
|
+
mode: "held",
|
|
19
|
+
lines: [],
|
|
20
|
+
console,
|
|
21
|
+
canFold,
|
|
22
|
+
failed: false,
|
|
23
|
+
streaming,
|
|
24
|
+
minimum
|
|
25
|
+
},
|
|
26
|
+
parent: null,
|
|
27
|
+
depth: 0,
|
|
28
|
+
warnings: 0,
|
|
29
|
+
errors: 0,
|
|
30
|
+
failedSteps: 0
|
|
31
|
+
} : {
|
|
32
|
+
name,
|
|
33
|
+
run: parent.run,
|
|
34
|
+
parent,
|
|
35
|
+
depth: parent.depth + 1,
|
|
36
|
+
warnings: 0,
|
|
37
|
+
errors: 0,
|
|
38
|
+
failedSteps: 0
|
|
39
|
+
};
|
|
40
|
+
/** Write one line, neutralized: every line is caller or program text. */
|
|
41
|
+
const write = (run, line) => {
|
|
42
|
+
run.console.log(CommandNeutralizer.text(line));
|
|
43
|
+
};
|
|
44
|
+
/** The indent a step's detail takes: two spaces per level of nesting. */
|
|
45
|
+
const indent = (depth) => " ".repeat(depth);
|
|
46
|
+
/** The runner's line breaks. */
|
|
47
|
+
const LINE_BREAK = /\r\n|\r|\n/;
|
|
48
|
+
/** Text on one line, for a name in a result, opening or prefix. */
|
|
49
|
+
const singleLine = (text) => text.replace(/\r\n|\r|\n/g, " ");
|
|
50
|
+
/** Write one detail line of a live run: indented under the step, prefixed while another run streams too. */
|
|
51
|
+
const writeLive = (run, line) => {
|
|
52
|
+
write(run, ` ${run.streaming.size >= 2 ? `[${run.name}] ` : ""}${line}`);
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Add detail to a step, held or streamed by its run's mode.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* Split at every line break first, so each line of a multi-line entry (a git transcript is one) takes the indent.
|
|
59
|
+
* Once the run has closed, a line (a fiber forked inside the step outlived it) is never dropped: it prints as an
|
|
60
|
+
* ordinary log line, unindented and unprefixed.
|
|
61
|
+
*/
|
|
62
|
+
const detail = (frame, text) => {
|
|
63
|
+
const run = frame.run;
|
|
64
|
+
for (const part of text.split(LINE_BREAK)) {
|
|
65
|
+
const line = `${indent(frame.depth)}${part}`;
|
|
66
|
+
if (run.mode === "held") run.lines.push(line);
|
|
67
|
+
else if (run.mode === "live") writeLive(run, line);
|
|
68
|
+
else write(run, part);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* The line a step writes when it starts streaming: `… <name> is taking longer than <window>, showing live output`, or
|
|
73
|
+
* `… <name>` alone for a step whose window is zero (runner debug, or `window: 0`), which streams from the start.
|
|
74
|
+
*/
|
|
75
|
+
const opening = (name, window) => window === void 0 ? `… ${singleLine(name)}` : `… ${singleLine(name)} is taking longer than ${window}, showing live output`;
|
|
76
|
+
/**
|
|
77
|
+
* Switch a held run to live: write its opening line and everything held so far, after which each detail line streams.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* One synchronous block, so no line can land between the flush and the switch. A run that is already live or has
|
|
81
|
+
* closed (the window timer lost the race with the step's end) is left alone.
|
|
82
|
+
*/
|
|
83
|
+
const goLive = (run, openingLine) => {
|
|
84
|
+
if (run.mode !== "held") return;
|
|
85
|
+
run.mode = "live";
|
|
86
|
+
run.streaming.add(run);
|
|
87
|
+
write(run, openingLine);
|
|
88
|
+
for (const line of run.lines.splice(0)) writeLive(run, line);
|
|
89
|
+
};
|
|
90
|
+
/** Count a warning or an error against a step and every step around it. */
|
|
91
|
+
const countAnnotation = (frame, kind) => {
|
|
92
|
+
for (let current = frame; current !== null; current = current.parent) if (kind === "warning") current.warnings += 1;
|
|
93
|
+
else current.errors += 1;
|
|
94
|
+
};
|
|
95
|
+
const green = (text) => `\x1b[32m${text}\x1b[39m`;
|
|
96
|
+
const yellow = (text) => `\x1b[33m${text}\x1b[39m`;
|
|
97
|
+
const red = (text) => `\x1b[31m${text}\x1b[39m`;
|
|
98
|
+
const dim = (text) => `\x1b[2m${text}\x1b[22m`;
|
|
99
|
+
/** A phase heading: bold, one line. */
|
|
100
|
+
const heading = (title) => `\x1b[1m${singleLine(title)}\x1b[22m`;
|
|
101
|
+
/** A duration as the result line shows it: tenths of a second under a minute, then minutes and seconds. */
|
|
102
|
+
const formatDuration = (millis) => {
|
|
103
|
+
if (millis < 6e4) return `${(Math.floor(millis / 100) / 10).toFixed(1)}s`;
|
|
104
|
+
const seconds = Math.floor(millis / 1e3);
|
|
105
|
+
return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
|
|
106
|
+
};
|
|
107
|
+
const plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
108
|
+
/** `<mark> <text> · <counts> · <duration>`, or `✗ <name> · interrupted`. */
|
|
109
|
+
const resultLine = (frame, outcome, millis) => {
|
|
110
|
+
if (outcome._tag === "Interrupted") return `${red("✗")} ${singleLine(frame.name)} · interrupted`;
|
|
111
|
+
const counts = [
|
|
112
|
+
...frame.warnings > 0 ? [plural(frame.warnings, "warning")] : [],
|
|
113
|
+
...frame.errors > 0 ? [plural(frame.errors, "error")] : [],
|
|
114
|
+
...frame.failedSteps > 0 ? [plural(frame.failedSteps, "failed step")] : []
|
|
115
|
+
];
|
|
116
|
+
return [
|
|
117
|
+
`${outcome._tag === "Failure" ? red("✗") : counts.length > 0 ? yellow("⚠") : green("✓")} ${singleLine(outcome.text)}`,
|
|
118
|
+
...counts,
|
|
119
|
+
dim(formatDuration(millis))
|
|
120
|
+
].join(" · ");
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* End a step and write what it owes the log.
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
* A nested step adds its result line to the enclosing step's detail; when it failed or was interrupted it counts as a
|
|
127
|
+
* failed step against every step around it and marks the run failed, so an outer step that recovers still shows `⚠`
|
|
128
|
+
* and never folds the failure away. A live outermost step has streamed its detail already, so it writes its result
|
|
129
|
+
* line alone, unfolded. A held outermost step writes its held detail: under a folded `::group::` titled by the result
|
|
130
|
+
* line when every step in the run succeeded, or indented beneath an unfolded result line otherwise, or when the step
|
|
131
|
+
* cannot fold. A step with no detail is its result line alone. Either way the run is closed afterwards.
|
|
132
|
+
*/
|
|
133
|
+
const close = (frame, outcome, millis) => {
|
|
134
|
+
const line = resultLine(frame, outcome, millis);
|
|
135
|
+
if (frame.parent !== null) {
|
|
136
|
+
if (outcome._tag !== "Success") {
|
|
137
|
+
frame.run.failed = true;
|
|
138
|
+
for (let current = frame.parent; current !== null; current = current.parent) current.failedSteps += 1;
|
|
139
|
+
}
|
|
140
|
+
detail(frame.parent, line);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const run = frame.run;
|
|
144
|
+
if (run.mode === "live") {
|
|
145
|
+
run.mode = "closed";
|
|
146
|
+
run.streaming.delete(run);
|
|
147
|
+
write(run, line);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
run.mode = "closed";
|
|
151
|
+
const held = run.lines.splice(0);
|
|
152
|
+
if (held.length === 0) {
|
|
153
|
+
write(run, line);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (outcome._tag === "Success" && run.canFold && !run.failed) {
|
|
157
|
+
run.console.log(WorkflowCommand.group(line));
|
|
158
|
+
for (const entry of held) write(run, entry);
|
|
159
|
+
run.console.log(WorkflowCommand.endGroup());
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
write(run, line);
|
|
163
|
+
for (const entry of held) write(run, ` ${entry}`);
|
|
164
|
+
};
|
|
165
|
+
/** `Console` arguments as one text, the way a log message is rendered. */
|
|
166
|
+
const consoleText = (args) => args.map((part) => typeof part === "string" ? part : Inspectable.toStringUnknown(part, 0)).join(" ");
|
|
167
|
+
const GROUP = "::group::";
|
|
168
|
+
const END_GROUP = "::endgroup::";
|
|
169
|
+
/**
|
|
170
|
+
* Route text written straight to `Console` inside a step: detail, except the workflow commands in it.
|
|
171
|
+
*
|
|
172
|
+
* @remarks
|
|
173
|
+
* Each line is read on its own. A group command becomes a `▸ <title>` header line of the detail and its end is
|
|
174
|
+
* dropped, because a group cannot open inside the step's fold. Every other workflow command (a line starting `::`)
|
|
175
|
+
* goes out at once, unchanged, through the run's console: an `::add-mask::` must reach the runner before the secret
|
|
176
|
+
* appears in any line, and an annotation is never held. A `::warning` or `::error` command counts against the step and
|
|
177
|
+
* every step around it, as a logged warning or error does.
|
|
178
|
+
*/
|
|
179
|
+
const routeConsole = (frame, args) => {
|
|
180
|
+
for (const line of consoleText(args).split(LINE_BREAK)) {
|
|
181
|
+
const command = line.trimStart();
|
|
182
|
+
if (command.startsWith(GROUP)) detail(frame, `▸ ${command.slice(9)}`);
|
|
183
|
+
else if (command.startsWith(END_GROUP)) {} else if (command.startsWith("::")) {
|
|
184
|
+
if (command.startsWith("::warning")) countAnnotation(frame, "warning");
|
|
185
|
+
else if (command.startsWith("::error")) countAnnotation(frame, "error");
|
|
186
|
+
frame.run.console.log(line);
|
|
187
|
+
} else detail(frame, line);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* The `Console` a step's body runs under: what it writes is the step's detail.
|
|
192
|
+
*
|
|
193
|
+
* @remarks
|
|
194
|
+
* Every writing method (`log`, `info`, `debug`, `trace`, `warn`, `error`, `dirxml`) goes through {@link routeConsole},
|
|
195
|
+
* so `@effected/cli-kit`'s renderers and a raw `Console.log` land in the fold, or stream while the step is live, rather
|
|
196
|
+
* than printing ahead of its `::group::`. The rest (`table`, `dir`, timers, counters, grouping) pass through to the
|
|
197
|
+
* run's console unchanged. The step log's own lines never go through this console: they are written through the run's.
|
|
198
|
+
*/
|
|
199
|
+
const capture = (frame) => {
|
|
200
|
+
const real = frame.run.console;
|
|
201
|
+
const route = (...args) => routeConsole(frame, args);
|
|
202
|
+
return {
|
|
203
|
+
assert: (condition, ...args) => real.assert(condition, ...args),
|
|
204
|
+
clear: () => real.clear(),
|
|
205
|
+
count: (label) => real.count(label),
|
|
206
|
+
countReset: (label) => real.countReset(label),
|
|
207
|
+
debug: route,
|
|
208
|
+
dir: (item, options) => real.dir(item, options),
|
|
209
|
+
dirxml: route,
|
|
210
|
+
error: route,
|
|
211
|
+
group: (...args) => real.group(...args),
|
|
212
|
+
groupCollapsed: (...args) => real.groupCollapsed(...args),
|
|
213
|
+
groupEnd: () => real.groupEnd(),
|
|
214
|
+
info: route,
|
|
215
|
+
log: route,
|
|
216
|
+
table: (tabularData, properties) => real.table(tabularData, properties),
|
|
217
|
+
time: (label) => real.time(label),
|
|
218
|
+
timeEnd: (label) => real.timeEnd(label),
|
|
219
|
+
timeLog: (label, ...args) => real.timeLog(label, ...args),
|
|
220
|
+
trace: route,
|
|
221
|
+
warn: route
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export { ActiveStep, capture, close, countAnnotation, detail, formatDuration, goLive, heading, open, opening };
|
package/internal/twirp.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/github-actions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The GitHub Actions runtime: env, inputs, outputs, state, logging, cache, artifacts, blob storage, OIDC and the token bridge.",
|
|
6
6
|
"keywords": [
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@effected/crypto": "^0.7.0",
|
|
42
|
-
"@effected/
|
|
42
|
+
"@effected/git": "^0.34.0",
|
|
43
|
+
"@effected/github": "^0.34.0",
|
|
43
44
|
"@effected/github-commands": "^0.10.0",
|
|
44
45
|
"@effected/glob": "^0.23.0",
|
|
45
46
|
"@effected/jwt": "^0.10.0",
|