@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
package/Action.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
2
|
+
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
3
|
+
import { WorkflowCommand } from "@effected/github-commands";
|
|
4
|
+
import { Cause, Effect, Exit, Layer, LogLevel, Option, References, Result } from "effect";
|
|
5
|
+
import { FetchHttpClient } from "effect/http";
|
|
1
6
|
import { ActionEnvironment } from "./ActionEnvironment.js";
|
|
2
7
|
import { ActionInput } from "./ActionInput.js";
|
|
3
8
|
import { ActionLogger } from "./ActionLogger.js";
|
|
4
9
|
import { ActionOutputs } from "./ActionOutputs.js";
|
|
5
10
|
import { ActionState } from "./ActionState.js";
|
|
6
|
-
import { WorkflowCommand } from "@effected/github-commands";
|
|
7
|
-
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
8
|
-
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
9
|
-
import { Cause, Effect, Exit, Layer, LogLevel, Option, References, Result } from "effect";
|
|
10
|
-
import { FetchHttpClient } from "effect/http";
|
|
11
11
|
|
|
12
12
|
// src/Action.ts
|
|
13
13
|
/**
|
|
@@ -109,8 +109,8 @@ const describeError = (error) => {
|
|
|
109
109
|
*
|
|
110
110
|
* - **It does not wrap the program in a log buffer.** A buffer that swallowed
|
|
111
111
|
* the transcript on an unhandled defect would leave a run that failed and
|
|
112
|
-
* printed nothing. `ActionLogger.
|
|
113
|
-
* exit path including a defect, so the
|
|
112
|
+
* printed nothing. `ActionLogger.step` is opt-in and writes its result line on
|
|
113
|
+
* every exit path including a defect, so the holding is where the caller can
|
|
114
114
|
* see it.
|
|
115
115
|
* - **It does not throw.** The returned promise always resolves; the failure is
|
|
116
116
|
* in `process.exitCode`, which is what the runner reads. An action entry
|
package/ActionCache.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { GlobPattern, GlobSet } from "@effected/glob";
|
|
2
|
+
import { Context, Effect, FileSystem, Layer, Option, Path, Schema } from "effect";
|
|
3
|
+
import { HttpClient } from "effect/http";
|
|
4
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
1
5
|
import { ActionEnvironment } from "./ActionEnvironment.js";
|
|
2
6
|
import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
|
|
3
7
|
import { httpFileTransfer } from "./internal/blobTransport.js";
|
|
@@ -7,10 +11,6 @@ import { isWindowsRunner } from "./internal/runner.js";
|
|
|
7
11
|
import { spawnOnce } from "./internal/spawn.js";
|
|
8
12
|
import { twirpCall, twirpFailureFields } from "./internal/twirp.js";
|
|
9
13
|
import { unstubbed } from "./internal/unstubbed.js";
|
|
10
|
-
import { Context, Effect, FileSystem, Layer, Option, Path, Schema } from "effect";
|
|
11
|
-
import { HttpClient } from "effect/http";
|
|
12
|
-
import { GlobPattern, GlobSet } from "@effected/glob";
|
|
13
|
-
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
14
14
|
|
|
15
15
|
// src/ActionCache.ts
|
|
16
16
|
/**
|
package/ActionEnvironment.js
CHANGED
package/ActionInput.js
CHANGED
package/ActionLogger.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { ActionEnvironment } from "./ActionEnvironment.js";
|
|
2
1
|
import { CommandNeutralizer, WorkflowCommand } from "@effected/github-commands";
|
|
3
|
-
import { Console, Context, Effect, Exit, Inspectable, Layer, LogLevel, Logger, References } from "effect";
|
|
2
|
+
import { Cause, Clock, Console, Context, Deferred, Duration, Effect, Exit, Fiber, Inspectable, Layer, LogLevel, Logger, References, Stream } from "effect";
|
|
3
|
+
import { ChildProcessSpawner, CommandLine } from "effect/process";
|
|
4
|
+
import { ActionEnvironment } from "./ActionEnvironment.js";
|
|
5
|
+
import { ActiveStep, capture, close, countAnnotation, detail, goLive, heading, open, opening } from "./internal/stepLog.js";
|
|
4
6
|
|
|
5
7
|
// src/ActionLogger.ts
|
|
8
|
+
/** How long `command` keeps reading after the child exits. */
|
|
9
|
+
const COMMAND_DRAIN = Duration.seconds(10);
|
|
6
10
|
/**
|
|
7
11
|
* Render a log message, which arrives as an array of the values passed to
|
|
8
12
|
* `Effect.log*`.
|
|
@@ -86,25 +90,13 @@ const renderLogger = Logger.make((options) => renderEntry(options.logLevel, opti
|
|
|
86
90
|
/** {@link renderLogger} written through core `Console`. */
|
|
87
91
|
const commandLogger = Logger.withConsoleLog(renderLogger);
|
|
88
92
|
/**
|
|
89
|
-
* The buffer the current fiber is writing into, or `null` when not buffering.
|
|
90
|
-
*
|
|
91
|
-
* @remarks
|
|
92
|
-
* A `Context.Reference` rather than a module-level "current buffer": two steps
|
|
93
|
-
* running concurrently each keep their own transcript, and neither has to
|
|
94
|
-
* restore anything. A save/restore global is LIFO-correct only while the two
|
|
95
|
-
* buffers nest, which concurrent steps do not.
|
|
96
|
-
*
|
|
97
|
-
* @internal
|
|
98
|
-
*/
|
|
99
|
-
const ActiveBuffer = Context.Reference("@effected/github-actions/ActiveBuffer", { defaultValue: () => null });
|
|
100
|
-
/**
|
|
101
93
|
* How many log groups are open around the current fiber.
|
|
102
94
|
*
|
|
103
95
|
* @remarks
|
|
104
96
|
* The runner does not nest groups: a second `::group::` implicitly ends the
|
|
105
97
|
* first, leaving an empty outer header and a stray `::endgroup::`. So only
|
|
106
98
|
* depth 0 writes the group commands, and a nested call writes a plain header
|
|
107
|
-
* line instead. Fiber-scoped
|
|
99
|
+
* line instead. Fiber-scoped so that a
|
|
108
100
|
* `Context.Reference` is provided around the body, so it unwinds on every
|
|
109
101
|
* exit path with nothing to restore.
|
|
110
102
|
*
|
|
@@ -117,65 +109,152 @@ const ActiveBuffer = Context.Reference("@effected/github-actions/ActiveBuffer",
|
|
|
117
109
|
* @internal
|
|
118
110
|
*/
|
|
119
111
|
const GroupDepth = Context.Reference(WorkflowCommand.groupDepthKey, { defaultValue: () => 0 });
|
|
112
|
+
const singleLine = (text) => text.replace(/\r\n|\r|\n/g, " ");
|
|
113
|
+
/** The `▸ <name>` line a nested group writes in place of a second `::group::`, neutralized because a name is caller text. */
|
|
114
|
+
const nestedHeader = (name) => CommandNeutralizer.text(`▸ ${singleLine(name)}`);
|
|
115
|
+
/** The first line of a failure's message, for the result line. */
|
|
116
|
+
const failureMessage = (cause) => {
|
|
117
|
+
const squashed = Cause.squash(cause);
|
|
118
|
+
return (squashed instanceof Error ? squashed.message : typeof squashed === "string" ? squashed : Inspectable.toStringUnknown(squashed, 0)).split(/\r\n|\r|\n/)[0] ?? "";
|
|
119
|
+
};
|
|
120
|
+
/** A caller's formatter, total: a throw falls back to the default text rather than skipping the step's close. */
|
|
121
|
+
const format = (formatter, value, fallback) => {
|
|
122
|
+
if (formatter === void 0) return fallback();
|
|
123
|
+
try {
|
|
124
|
+
return formatter(value);
|
|
125
|
+
} catch {
|
|
126
|
+
return fallback();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
120
129
|
/**
|
|
121
|
-
*
|
|
122
|
-
* and
|
|
130
|
+
* How a step's exit reads on its result line. Total: it runs inside the step's exit handler, where a throw would skip
|
|
131
|
+
* the close and leave a live run streaming.
|
|
132
|
+
*/
|
|
133
|
+
const stepOutcome = (name, exit, options) => {
|
|
134
|
+
if (Exit.isSuccess(exit)) return {
|
|
135
|
+
_tag: "Success",
|
|
136
|
+
text: format(options?.summary, exit.value, () => name)
|
|
137
|
+
};
|
|
138
|
+
if (Cause.hasInterruptsOnly(exit.cause)) return { _tag: "Interrupted" };
|
|
139
|
+
return {
|
|
140
|
+
_tag: "Failure",
|
|
141
|
+
text: format(options?.failure, exit.cause, () => `${name} · ${failureMessage(exit.cause)}`)
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* The logger a step runs under: warnings and errors go out live and count against the step and every step around it;
|
|
146
|
+
* everything below `Warn` is the step's detail.
|
|
123
147
|
*
|
|
124
148
|
* @remarks
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* neutralized, because a group name is caller text and a `::` or `##[` in it
|
|
128
|
-
* would otherwise be a command.
|
|
149
|
+
* A warning is written through the run's console, the one the step opened under, not the fiber's: inside the step the
|
|
150
|
+
* fiber's console is the capturing one, which would count the annotation a second time.
|
|
129
151
|
*/
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (state.entries.length === 0) return Effect.void;
|
|
138
|
-
const body = [
|
|
139
|
-
`--- Buffered output for "${state.label}" ---`,
|
|
140
|
-
...state.entries,
|
|
141
|
-
`--- End buffered output for "${state.label}" ---`
|
|
142
|
-
];
|
|
143
|
-
state.entries.length = 0;
|
|
144
|
-
return Effect.forEach(body, (line) => Console.log(CommandNeutralizer.text(line)), { discard: true });
|
|
152
|
+
const stepLogger = (frame) => Logger.make((options) => {
|
|
153
|
+
if (LogLevel.isGreaterThanOrEqualTo(options.logLevel, "Warn")) {
|
|
154
|
+
countAnnotation(frame, LogLevel.isGreaterThanOrEqualTo(options.logLevel, "Error") ? "error" : "warning");
|
|
155
|
+
frame.run.console.log(renderLogger.log(options));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
detail(frame, formatMessage(options.message));
|
|
145
159
|
});
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
160
|
+
/** The recorded step the current fiber is inside, or `null`. */
|
|
161
|
+
const RecordingParent = Context.Reference("@effected/github-actions/RecordingParent", { defaultValue: () => null });
|
|
162
|
+
/** A recorded entry as the public shape, without the bookkeeping, copied so later steps cannot change it. */
|
|
163
|
+
const snapshot = (entry) => entry.kind === "phase" ? {
|
|
164
|
+
kind: "phase",
|
|
165
|
+
title: entry.title
|
|
166
|
+
} : {
|
|
167
|
+
kind: "step",
|
|
168
|
+
name: entry.name,
|
|
169
|
+
outcome: entry.outcome,
|
|
170
|
+
summary: entry.summary,
|
|
171
|
+
detail: [...entry.detail],
|
|
172
|
+
steps: entry.steps.map(snapshot)
|
|
173
|
+
};
|
|
174
|
+
/** The recording double's members: they record the structure and write nothing. */
|
|
175
|
+
const recordingShape = (roots) => ({
|
|
176
|
+
phase: (title, effect) => Effect.andThen(Effect.flatMap(RecordingParent, (parent) => Effect.sync(() => void (parent === null ? roots : parent.steps).push({
|
|
177
|
+
kind: "phase",
|
|
178
|
+
title
|
|
179
|
+
}))), effect),
|
|
180
|
+
step: (name, effect, options) => Effect.flatMap(RecordingParent, (parent) => {
|
|
181
|
+
const node = {
|
|
182
|
+
kind: "step",
|
|
183
|
+
name,
|
|
184
|
+
outcome: "success",
|
|
185
|
+
summary: name,
|
|
186
|
+
detail: [],
|
|
187
|
+
steps: [],
|
|
188
|
+
noisy: false,
|
|
189
|
+
parent
|
|
155
190
|
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
191
|
+
(parent === null ? roots : parent.steps).push(node);
|
|
192
|
+
const logger = Logger.make((entry) => {
|
|
193
|
+
if (LogLevel.isGreaterThanOrEqualTo(entry.logLevel, "Warn")) {
|
|
194
|
+
for (let current = node; current !== null; current = current.parent) current.noisy = true;
|
|
159
195
|
return;
|
|
160
196
|
}
|
|
161
|
-
|
|
197
|
+
node.detail.push(...formatMessage(entry.message).split(/\r\n|\r|\n/));
|
|
162
198
|
});
|
|
163
|
-
return
|
|
199
|
+
return effect.pipe(Effect.provideService(References.MinimumLogLevel, "All"), Effect.provideService(Logger.CurrentLoggers, /* @__PURE__ */ new Set([logger])), Effect.provideService(RecordingParent, node), Effect.onExit((exit) => Effect.sync(() => {
|
|
200
|
+
const outcome = stepOutcome(name, exit, options);
|
|
201
|
+
if (outcome._tag === "Interrupted") {
|
|
202
|
+
node.outcome = "interrupted";
|
|
203
|
+
node.summary = `${name} · interrupted`;
|
|
204
|
+
} else {
|
|
205
|
+
node.summary = outcome.text;
|
|
206
|
+
node.outcome = outcome._tag === "Failure" ? "failure" : node.noisy ? "warning" : "success";
|
|
207
|
+
}
|
|
208
|
+
if (outcome._tag !== "Success") for (let current = parent; current !== null; current = current.parent) current.noisy = true;
|
|
209
|
+
})));
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
/** A command as one displayable line, secrets redacted. */
|
|
213
|
+
const commandLine = (command) => command._tag === "StandardCommand" ? CommandLine.display([command.command, ...command.args]) : `${commandLine(command.left)} | ${commandLine(command.right)}`;
|
|
214
|
+
/** The window a step declares by default. */
|
|
215
|
+
const DEFAULT_WINDOW = "30 seconds";
|
|
216
|
+
const make = Effect.gen(function* () {
|
|
217
|
+
const env = yield* ActionEnvironment;
|
|
218
|
+
/** The runs streaming live, shared by every step this logger opens, for the `[<name>]` prefix. */
|
|
219
|
+
const streaming = /* @__PURE__ */ new Set();
|
|
220
|
+
/** An outermost step's window: zero under runner debug or an ambient `Debug` minimum, else the declared one. */
|
|
221
|
+
const windowFor = (declared, minimum) => Effect.gen(function* () {
|
|
222
|
+
return (yield* env.isDebug) || LogLevel.isLessThanOrEqualTo(minimum, "Debug") ? Duration.zero : Duration.fromInputUnsafe(declared ?? DEFAULT_WINDOW);
|
|
164
223
|
});
|
|
224
|
+
/**
|
|
225
|
+
* Start an outermost step's window: live at once for a zero window, else a timer that switches it live when the
|
|
226
|
+
* window passes. The timer is interrupted when the step ends; a timer that fires as the step closes finds the run
|
|
227
|
+
* closed and does nothing.
|
|
228
|
+
*/
|
|
229
|
+
const armWindow = (frame, declared) => Effect.flatMap(windowFor(declared, frame.run.minimum), (window) => Duration.isZero(window) ? Effect.as(Effect.sync(() => goLive(frame.run, opening(frame.name, void 0))), void 0) : Effect.forkChild(Effect.andThen(Effect.sleep(window), Effect.sync(() => goLive(frame.run, opening(frame.name, Duration.format(window)))))));
|
|
230
|
+
/** A `▸ <name>` header: a line of the open step's detail, or written out when no step is open. */
|
|
231
|
+
const writeHeader = (name) => Effect.flatMap(ActiveStep, (frame) => frame === null ? Console.log(nestedHeader(name)) : Effect.sync(() => detail(frame, `▸ ${singleLine(name)}`)));
|
|
232
|
+
const phase = (title, effect) => Effect.andThen(Effect.flatMap(ActiveStep, (frame) => frame === null ? Console.log(CommandNeutralizer.text(heading(title))) : Effect.sync(() => detail(frame, heading(title)))), effect);
|
|
233
|
+
const step = (name, effect, options) => Effect.uninterruptibleMask((restore) => Effect.gen(function* () {
|
|
234
|
+
const active = yield* ActiveStep;
|
|
235
|
+
const parent = active !== null && active.run.mode !== "closed" ? active : null;
|
|
236
|
+
const depth = yield* GroupDepth;
|
|
237
|
+
const console = active === null ? yield* Console.Console : active.run.console;
|
|
238
|
+
const canFold = active === null ? depth === 0 : active.run.canFold;
|
|
239
|
+
const minimum = active === null ? yield* References.MinimumLogLevel : active.run.minimum;
|
|
240
|
+
const started = yield* Clock.monotonicTimeNanos;
|
|
241
|
+
const frame = open(name, parent, console, canFold, streaming, minimum);
|
|
242
|
+
const timer = parent === null ? yield* armWindow(frame, options?.window) : void 0;
|
|
243
|
+
return yield* restore(effect).pipe(Effect.provideService(References.MinimumLogLevel, "All"), Effect.provideService(Logger.CurrentLoggers, /* @__PURE__ */ new Set([stepLogger(frame)])), Effect.provideService(ActiveStep, frame), Effect.provideService(GroupDepth, depth + 1), Effect.provideService(Console.Console, capture(frame)), Effect.onExit((exit) => Effect.andThen(timer === void 0 ? Effect.void : Fiber.interrupt(timer), Effect.flatMap(Clock.monotonicTimeNanos, (ended) => Effect.sync(() => close(frame, stepOutcome(name, exit, options), Number(ended - started) / 1e6))))));
|
|
244
|
+
}));
|
|
165
245
|
return {
|
|
166
246
|
group: (name, effect) => Effect.flatMap(GroupDepth, (depth) => {
|
|
167
|
-
const body = Effect.
|
|
168
|
-
return depth === 0 ? Effect.acquireUseRelease(Console.log(WorkflowCommand.group(name)), () => body, () => Console.log(WorkflowCommand.endGroup())) : Effect.andThen(
|
|
247
|
+
const body = Effect.provideService(effect, GroupDepth, depth + 1);
|
|
248
|
+
return depth === 0 ? Effect.acquireUseRelease(Console.log(WorkflowCommand.group(name)), () => body, () => Console.log(WorkflowCommand.endGroup())) : Effect.andThen(writeHeader(name), body);
|
|
169
249
|
}),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
withStep: (name, effect, options) => withBuffer(name, Effect.tapCause(effect, () => Console.log(CommandNeutralizer.text(`❌ ${name}`))), { onSuccess: "discard" }).pipe(Effect.tap(() => Effect.logInfo(options?.summary ?? `✅ ${name}`))),
|
|
250
|
+
phase,
|
|
251
|
+
step,
|
|
173
252
|
notice: (message, properties = {}) => Console.log(WorkflowCommand.notice(message, properties)),
|
|
174
253
|
annotated: (properties, effect) => Effect.annotateLogs(effect, annotationRecord(properties))
|
|
175
254
|
};
|
|
176
255
|
});
|
|
177
256
|
/**
|
|
178
|
-
* Groups,
|
|
257
|
+
* Groups, phases, steps, notices — and the `Logger` that renders
|
|
179
258
|
* every `Effect.log*` in the kit as a workflow command.
|
|
180
259
|
*
|
|
181
260
|
* @remarks
|
|
@@ -191,7 +270,7 @@ const make = Effect.gen(function* () {
|
|
|
191
270
|
*
|
|
192
271
|
* const program = Effect.gen(function* () {
|
|
193
272
|
* const logger = yield* ActionLogger;
|
|
194
|
-
* yield* logger.
|
|
273
|
+
* yield* logger.phase("Install", logger.step("pnpm", Effect.logInfo("resolving")));
|
|
195
274
|
* });
|
|
196
275
|
* ```
|
|
197
276
|
*
|
|
@@ -199,7 +278,7 @@ const make = Effect.gen(function* () {
|
|
|
199
278
|
*/
|
|
200
279
|
var ActionLogger = class ActionLogger extends Context.Service()("@effected/github-actions/ActionLogger") {
|
|
201
280
|
/**
|
|
202
|
-
* The service: groups,
|
|
281
|
+
* The service: groups, phases, steps, notices and annotations.
|
|
203
282
|
*
|
|
204
283
|
* @remarks
|
|
205
284
|
* This installs no `Logger`. Without {@link ActionLogger.layerLogger} (or `Action.run`, which installs it) Effect's
|
|
@@ -234,19 +313,73 @@ var ActionLogger = class ActionLogger extends Context.Service()("@effected/githu
|
|
|
234
313
|
* **A recorded exception to the die-on-unstubbed rule**, alongside
|
|
235
314
|
* {@link ActionEnvironment.makeTest}. A logger that dies when a suite logs
|
|
236
315
|
* would make every double unusable, and silence is the honest default for a
|
|
237
|
-
* service whose whole job is output. Group,
|
|
238
|
-
* effect through unchanged, so the double does not model group nesting
|
|
239
|
-
* a test of
|
|
316
|
+
* service whose whole job is output. Group, phase and step wrappers pass their
|
|
317
|
+
* effect through unchanged, so the double does not model group nesting or
|
|
318
|
+
* the step log: a test of that output needs the live {@link ActionLogger.layer}
|
|
319
|
+
* or {@link ActionLogger.recording}.
|
|
240
320
|
*/
|
|
241
321
|
static makeTest = (overrides = {}) => ({
|
|
242
322
|
group: (_name, effect) => effect,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
withStep: (_name, effect) => effect,
|
|
323
|
+
phase: (_title, effect) => effect,
|
|
324
|
+
step: (_name, effect) => effect,
|
|
246
325
|
notice: () => Effect.void,
|
|
247
326
|
annotated: (_properties, effect) => effect,
|
|
248
327
|
...overrides
|
|
249
328
|
});
|
|
329
|
+
/**
|
|
330
|
+
* A double that records the step log's structure so a test can assert it.
|
|
331
|
+
*
|
|
332
|
+
* @remarks
|
|
333
|
+
* `entries()` returns the phases and steps opened so far, each step with its detail (every line below `Warn`),
|
|
334
|
+
* outcome, result text and nested steps. The step log itself writes nothing to the console. A raw `Console` write
|
|
335
|
+
* inside a recorded step is not detail and still prints, so test `Console` or `@effected/cli-kit` output against
|
|
336
|
+
* the live layer with `TestConsole`. The other members behave as in {@link ActionLogger.makeTest}.
|
|
337
|
+
*/
|
|
338
|
+
static recording = () => {
|
|
339
|
+
const roots = [];
|
|
340
|
+
return {
|
|
341
|
+
layer: Layer.succeed(ActionLogger, ActionLogger.makeTest(recordingShape(roots))),
|
|
342
|
+
entries: () => roots.map(snapshot)
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* Run a child process, writing its command line, its output and its exit code as the current step's detail.
|
|
347
|
+
*
|
|
348
|
+
* @remarks
|
|
349
|
+
* Writes `$ <display>` (the command line, secrets redacted, unless `display` is given), then each stdout and stderr
|
|
350
|
+
* line as it arrives, then `exit <code>`. Both streams are read concurrently, so a child that fills one pipe cannot
|
|
351
|
+
* deadlock the other. Every line is detail, so the step's held, live and prefix rules apply; stderr lines are
|
|
352
|
+
* detail too, not warnings. Outside any step the lines print live. Resolves with the exit code, whatever it is, and
|
|
353
|
+
* the collected stdout.
|
|
354
|
+
*
|
|
355
|
+
* Reading stops 10 seconds after the child exits, as `@actions/exec` does: a background grandchild that inherited
|
|
356
|
+
* the child's stdout or stderr would otherwise hold the pipe open, and the call with it, for as long as it lives.
|
|
357
|
+
* What it wrote after that is not read.
|
|
358
|
+
*
|
|
359
|
+
* Stdout is decoded as UTF-8 text and logged line by line, so this suits a child whose stdout is text; a binary
|
|
360
|
+
* stdout needs the raw `ChildProcessSpawner` handle.
|
|
361
|
+
*
|
|
362
|
+
* Fails with `PlatformError` when the spawn fails, or when reading the child's output or its exit status fails after
|
|
363
|
+
* it started. A non-zero exit is never an error.
|
|
364
|
+
*/
|
|
365
|
+
static command = (command, options) => Effect.scoped(Effect.gen(function* () {
|
|
366
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
367
|
+
yield* Effect.logInfo(`$ ${options?.display ?? commandLine(command)}`);
|
|
368
|
+
const handle = yield* spawner.spawn(command);
|
|
369
|
+
let stdout = "";
|
|
370
|
+
const logLines = (stream) => stream.pipe(Stream.splitLines, Stream.runForEach((line) => Effect.logInfo(line)));
|
|
371
|
+
const exited = yield* Deferred.make();
|
|
372
|
+
const readers = Effect.all([logLines(Stream.decodeText(handle.stdout).pipe(Stream.tap((chunk) => Effect.sync(() => {
|
|
373
|
+
stdout += chunk;
|
|
374
|
+
})))), logLines(Stream.decodeText(handle.stderr))], { concurrency: "unbounded" });
|
|
375
|
+
const [, code] = yield* Effect.all([Effect.raceFirst(readers, Effect.andThen(Deferred.await(exited), Effect.sleep(COMMAND_DRAIN))), Effect.tap(handle.exitCode, () => Deferred.succeed(exited, void 0))], { concurrency: "unbounded" });
|
|
376
|
+
const exitCode = Number(code);
|
|
377
|
+
yield* Effect.logInfo(`exit ${exitCode}`);
|
|
378
|
+
return {
|
|
379
|
+
exitCode,
|
|
380
|
+
stdout
|
|
381
|
+
};
|
|
382
|
+
}));
|
|
250
383
|
/** {@link ActionLogger.makeTest} behind `Layer.succeed`. */
|
|
251
384
|
static layerTest = (overrides = {}) => Layer.succeed(ActionLogger, ActionLogger.makeTest(overrides));
|
|
252
385
|
/**
|
package/ActionManifest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { inputVariable } from "./ActionInput.js";
|
|
2
|
-
import { Effect, FileSystem, Result, Schema, SchemaTransformation } from "effect";
|
|
3
1
|
import { Yaml } from "@effected/yaml";
|
|
2
|
+
import { Effect, FileSystem, Result, Schema, SchemaTransformation } from "effect";
|
|
3
|
+
import { inputVariable } from "./ActionInput.js";
|
|
4
4
|
|
|
5
5
|
// src/ActionManifest.ts
|
|
6
6
|
/**
|
package/ActionOutputs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { CommandNeutralizer, WorkflowCommand } from "@effected/github-commands";
|
|
2
|
+
import { Console, Context, Effect, FileSystem, Layer, Schema } from "effect";
|
|
1
3
|
import { ActionEnvironment } from "./ActionEnvironment.js";
|
|
2
4
|
import { heredocBlock, isUsableName } from "./internal/runnerFile.js";
|
|
3
5
|
import { unstubbed } from "./internal/unstubbed.js";
|
|
4
|
-
import { CommandNeutralizer, WorkflowCommand } from "@effected/github-commands";
|
|
5
|
-
import { Console, Context, Effect, FileSystem, Layer, Schema } from "effect";
|
|
6
6
|
|
|
7
7
|
// src/ActionOutputs.ts
|
|
8
8
|
/**
|
package/ActionState.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Context, Effect, FileSystem, Layer, Option, Schema } from "effect";
|
|
1
2
|
import { ActionEnvironment } from "./ActionEnvironment.js";
|
|
2
3
|
import { ActionOutputs } from "./ActionOutputs.js";
|
|
3
4
|
import { heredocBlock, isUsableName } from "./internal/runnerFile.js";
|
|
4
5
|
import { unstubbed } from "./internal/unstubbed.js";
|
|
5
|
-
import { Context, Effect, FileSystem, Layer, Option, Schema } from "effect";
|
|
6
6
|
|
|
7
7
|
// src/ActionState.ts
|
|
8
8
|
/**
|
package/ActionsIdentityToken.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OidcTokenIssuer } from "./OidcTokenIssuer.js";
|
|
2
|
-
import { Effect, Layer } from "effect";
|
|
3
1
|
import { IdentityToken, IdentityTokenError } from "@effected/oidc";
|
|
2
|
+
import { Effect, Layer } from "effect";
|
|
3
|
+
import { OidcTokenIssuer } from "./OidcTokenIssuer.js";
|
|
4
4
|
|
|
5
5
|
// src/ActionsIdentityToken.ts
|
|
6
6
|
/**
|
package/ActionsProvenance.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { SlsaProvenance } from "@effected/sbom";
|
|
2
|
+
import { Effect, Option } from "effect";
|
|
1
3
|
import { ActionEnvironment } from "./ActionEnvironment.js";
|
|
2
4
|
import { OidcTokenIssuer } from "./OidcTokenIssuer.js";
|
|
3
|
-
import { Effect, Option } from "effect";
|
|
4
|
-
import { SlsaProvenance } from "@effected/sbom";
|
|
5
5
|
|
|
6
6
|
// src/ActionsProvenance.ts
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { workloadCredential } from "@effected/npm";
|
|
2
|
+
import { Effect } from "effect";
|
|
1
3
|
import { OidcTokenIssuer } from "./OidcTokenIssuer.js";
|
|
2
4
|
import { Secret } from "./Secret.js";
|
|
3
|
-
import { Effect } from "effect";
|
|
4
|
-
import { workloadCredential } from "@effected/npm";
|
|
5
5
|
|
|
6
6
|
// src/ActionsRegistryCredential.ts
|
|
7
7
|
/**
|
package/Artifact.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Context, DateTime, Duration, Effect, FileSystem, Layer, Option, Path, Result, Schema } from "effect";
|
|
2
|
+
import { HttpClient } from "effect/http";
|
|
3
|
+
import { ChildProcessSpawner } from "effect/process";
|
|
1
4
|
import { ActionEnvironment } from "./ActionEnvironment.js";
|
|
2
5
|
import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
|
|
3
6
|
import { unzipCommand, zipCommand, zipManifest } from "./internal/archiveCommands.js";
|
|
@@ -7,9 +10,6 @@ import { isWindowsRunner } from "./internal/runner.js";
|
|
|
7
10
|
import { spawnOnce } from "./internal/spawn.js";
|
|
8
11
|
import { CONFLICT, field, isOk, stringField, twirpCall, twirpFailureFields } from "./internal/twirp.js";
|
|
9
12
|
import { unstubbed } from "./internal/unstubbed.js";
|
|
10
|
-
import { Context, DateTime, Duration, Effect, FileSystem, Layer, Option, Path, Result, Schema } from "effect";
|
|
11
|
-
import { HttpClient } from "effect/http";
|
|
12
|
-
import { ChildProcessSpawner } from "effect/process";
|
|
13
13
|
|
|
14
14
|
// src/Artifact.ts
|
|
15
15
|
/**
|
package/BlobStore.githubCache.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Effect, Layer, Option } from "effect";
|
|
2
|
+
import { HttpClient } from "effect/http";
|
|
1
3
|
import { ActionEnvironment } from "./ActionEnvironment.js";
|
|
2
4
|
import { BlobEnvelope } from "./BlobEnvelope.js";
|
|
3
5
|
import { BlobStore, BlobStoreError } from "./BlobStore.js";
|
|
@@ -6,8 +8,6 @@ import { httpDataTransfer } from "./internal/blobTransport.js";
|
|
|
6
8
|
import { CACHE_SERVICE, finalizeUpload, lookupDownload, reserveUpload } from "./internal/cacheService.js";
|
|
7
9
|
import { sha256Hex } from "./internal/digest.js";
|
|
8
10
|
import { twirpCall, twirpFailureFields } from "./internal/twirp.js";
|
|
9
|
-
import { Effect, Layer, Option } from "effect";
|
|
10
|
-
import { HttpClient } from "effect/http";
|
|
11
11
|
|
|
12
12
|
// src/BlobStore.githubCache.ts
|
|
13
13
|
/**
|
package/BlobStore.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { HttpRedaction, SigV4 } from "@effected/crypto";
|
|
2
|
+
import { Context, DateTime, Effect, Layer, Option, Schema } from "effect";
|
|
3
|
+
import { Digest, Mac } from "effect/crypto";
|
|
4
|
+
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
1
5
|
import { BlobEnvelope } from "./BlobEnvelope.js";
|
|
2
6
|
import { unstubbed } from "./internal/unstubbed.js";
|
|
3
7
|
import { Secret } from "./Secret.js";
|
|
4
|
-
import { Context, DateTime, Effect, Layer, Option, Schema } from "effect";
|
|
5
|
-
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
6
|
-
import { HttpRedaction, SigV4 } from "@effected/crypto";
|
|
7
|
-
import { Digest, Mac } from "effect/crypto";
|
|
8
8
|
|
|
9
9
|
// src/BlobStore.ts
|
|
10
10
|
/**
|
package/CacheKey.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { sha256, sha256Hex } from "./internal/digest.js";
|
|
2
|
-
import { Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
3
1
|
import { GlobSet } from "@effected/glob";
|
|
4
2
|
import { descend } from "@effected/walker";
|
|
3
|
+
import { Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
4
|
+
import { sha256, sha256Hex } from "./internal/digest.js";
|
|
5
5
|
|
|
6
6
|
// src/CacheKey.ts
|
|
7
7
|
/**
|
package/CheckDocument.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Clock, Context, Duration, Effect, Latch, Layer, Ref, Schema, Semaphore } from "effect";
|
|
1
2
|
import { CheckState } from "./CheckState.js";
|
|
2
3
|
import { unstubbed } from "./internal/unstubbed.js";
|
|
3
4
|
import { ManagedDocument } from "./ManagedDocument.js";
|
|
4
|
-
import { Clock, Context, Duration, Effect, Latch, Layer, Ref, Schema, Semaphore } from "effect";
|
|
5
5
|
|
|
6
6
|
// src/CheckDocument.ts
|
|
7
7
|
/**
|