@effected/github-actions 0.34.0 → 0.36.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.
Files changed (46) hide show
  1. package/Action.js +10 -10
  2. package/ActionCache.js +17 -40
  3. package/ActionEnvironment.js +1 -1
  4. package/ActionInput.js +1 -1
  5. package/ActionLogger.js +197 -64
  6. package/ActionManifest.js +2 -2
  7. package/ActionOutputs.js +2 -2
  8. package/ActionState.js +1 -1
  9. package/ActionsIdentityToken.js +2 -2
  10. package/ActionsProvenance.js +2 -2
  11. package/ActionsRegistryCredential.js +2 -2
  12. package/Artifact.js +16 -39
  13. package/BlobStore.githubCache.js +16 -42
  14. package/BlobStore.js +4 -4
  15. package/CacheKey.js +2 -2
  16. package/CheckDocument.js +1 -1
  17. package/Checkout.js +361 -0
  18. package/DetachedProcess.js +4 -4
  19. package/DryRun.js +1 -1
  20. package/GitHubMarkdown.js +1 -1
  21. package/GitHubToken.js +2 -2
  22. package/ManagedDocument.js +1 -1
  23. package/OidcTokenIssuer.js +7 -7
  24. package/PackageManagerInstaller.js +3 -3
  25. package/README.md +4 -3
  26. package/Secret.js +1 -1
  27. package/ToolInstaller.js +4 -4
  28. package/index.d.ts +602 -119
  29. package/index.js +3 -2
  30. package/internal/actionsResults.js +1 -1
  31. package/internal/blobCause.js +2 -80
  32. package/internal/blobTransport.js +172 -0
  33. package/internal/cacheService.js +1 -1
  34. package/internal/checkout/asciiTrim.js +18 -0
  35. package/internal/checkout/credentials.js +563 -0
  36. package/internal/checkout/directory.js +119 -0
  37. package/internal/checkout/inputs.js +130 -0
  38. package/internal/checkout/refs.js +143 -0
  39. package/internal/checkout/settings.js +144 -0
  40. package/internal/checkout/source.js +418 -0
  41. package/internal/checkout/unsafePullRequest.js +62 -0
  42. package/internal/digest.js +1 -1
  43. package/internal/pnpmExe.js +1 -1
  44. package/internal/stepLog.js +225 -0
  45. package/internal/twirp.js +1 -1
  46. package/package.json +6 -6
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
  /**
@@ -19,9 +19,9 @@ import { FetchHttpClient } from "effect/http";
19
19
  * a GitHub Action is a Node process on a GitHub-provided runner.
20
20
  *
21
21
  * **The cache, artifact and blob services are deliberately NOT in here.** They
22
- * are the only modules that import `@azure/storage-blob`, and folding them into
23
- * the default runtime would put a blob-storage client in the bundle of every
24
- * action that merely sets an output. Their requirements are all satisfied by
22
+ * carry the Twirp results protocols and the blob transport, and folding them
23
+ * into the default runtime would put both in the bundle of every action that
24
+ * merely sets an output. Their requirements are all satisfied by
25
25
  * this layer, so taking one costs a caller exactly one line:
26
26
  * `Action.run(program, { layer: ActionCache.layer })`.
27
27
  *
@@ -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.withBuffer` is opt-in and flushes on every
113
- * exit path including a defect, so the buffering is where the caller can
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,18 +1,16 @@
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
- import { BlobTransferError } from "./BlobTransfer.js";
3
6
  import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
4
- import { blobCause } from "./internal/blobCause.js";
7
+ import { httpFileTransfer } from "./internal/blobTransport.js";
5
8
  import { CACHE_SERVICE, finalizeUpload, lookupDownload, reserveUpload } from "./internal/cacheService.js";
6
9
  import { sha256Hex } from "./internal/digest.js";
7
10
  import { isWindowsRunner } from "./internal/runner.js";
8
11
  import { spawnOnce } from "./internal/spawn.js";
9
12
  import { twirpCall, twirpFailureFields } from "./internal/twirp.js";
10
13
  import { unstubbed } from "./internal/unstubbed.js";
11
- import { Context, Effect, FileSystem, Layer, Option, Path, Schema } from "effect";
12
- import { HttpClient } from "effect/http";
13
- import { BlobClient, BlockBlobClient } from "@azure/storage-blob";
14
- import { GlobPattern, GlobSet } from "@effected/glob";
15
- import { ChildProcess, ChildProcessSpawner } from "effect/process";
16
14
 
17
15
  // src/ActionCache.ts
18
16
  /**
@@ -82,36 +80,6 @@ const versionOf = (paths) => sha256Hex([
82
80
  "gzip",
83
81
  "1.0"
84
82
  ].join("|"));
85
- /**
86
- * The Azure half, duplicated on purpose.
87
- *
88
- * @remarks
89
- * `@azure/storage-blob` may be imported here, by `Artifact` and by
90
- * `BlobStore.githubCache`, and nowhere else — hoisting these two calls into a
91
- * shared `internal/` helper is exactly how a heavy import leaks into the graph
92
- * of a module that only sets an output. `__test__/reachability.test.ts`
93
- * measures that these are the only three.
94
- */
95
- const azure = {
96
- uploadFile: (url, file) => Effect.tryPromise({
97
- try: () => new BlockBlobClient(url).uploadFile(file, {
98
- blockSize: 67108864,
99
- concurrency: 8,
100
- maxSingleShotSize: 134217728
101
- }),
102
- catch: (cause) => new BlobTransferError({
103
- reason: "uploadFailed",
104
- cause: blobCause(cause)
105
- })
106
- }).pipe(Effect.asVoid),
107
- downloadToFile: (url, file) => Effect.tryPromise({
108
- try: () => new BlobClient(url).downloadToFile(file),
109
- catch: (cause) => new BlobTransferError({
110
- reason: "downloadFailed",
111
- cause: blobCause(cause)
112
- })
113
- }).pipe(Effect.asVoid)
114
- };
115
83
  /** The primary key and the ladder to fall back through. */
116
84
  const ladder = (key, restoreKeys) => typeof key === "string" ? {
117
85
  primary: key,
@@ -120,9 +88,10 @@ const ladder = (key, restoreKeys) => typeof key === "string" ? {
120
88
  primary: key.key,
121
89
  fallbacks: restoreKeys ?? key.restoreKeys
122
90
  };
123
- const make = (transfer) => Effect.gen(function* () {
91
+ const make = (custom) => Effect.gen(function* () {
124
92
  const http = yield* HttpClient.HttpClient;
125
93
  const fs = yield* FileSystem.FileSystem;
94
+ const transfer = custom ?? httpFileTransfer(http, fs);
126
95
  const path = yield* Path.Path;
127
96
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
128
97
  const env = yield* ActionEnvironment;
@@ -353,8 +322,16 @@ const dies = unstubbed("ActionCache.makeTest");
353
322
  * @public
354
323
  */
355
324
  var ActionCache = class ActionCache extends Context.Service()("@effected/github-actions/ActionCache") {
356
- /** The cache, over the real Azure client and the real `tar`. */
357
- static layer = Layer.effect(this, make(azure));
325
+ /**
326
+ * The cache, over the `HttpClient` blob transport and the real `tar`.
327
+ *
328
+ * @remarks
329
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
330
+ * the caller's client, not a bundled SDK or a platform client of this
331
+ * package's own. Also requires `FileSystem`, `Path`, `ChildProcessSpawner`
332
+ * and `ActionEnvironment`.
333
+ */
334
+ static layer = Layer.effect(this, make());
358
335
  /**
359
336
  * The cache, over a supplied transport.
360
337
  *
@@ -1,5 +1,5 @@
1
- import { decodeJson } from "./internal/json.js";
2
1
  import { Context, Effect, FileSystem, Layer, Option, Schema } from "effect";
2
+ import { decodeJson } from "./internal/json.js";
3
3
 
4
4
  // src/ActionEnvironment.ts
5
5
  /**
package/ActionInput.js CHANGED
@@ -1,5 +1,5 @@
1
- import { decodeJson } from "./internal/json.js";
2
1
  import { Config, ConfigProvider, Context, Effect, Schema, SchemaIssue } from "effect";
2
+ import { decodeJson } from "./internal/json.js";
3
3
 
4
4
  // src/ActionInput.ts
5
5
  /**
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 for the same reason as {@link ActiveBuffer}: a
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
- * The `▸ <name>` line a nested group writes in place of a second `::group::`,
122
- * and the line {@link ActionLoggerShape.heading} writes.
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
- * Line breaks collapse to spaces so the header stays one line — the
126
- * top-level form escapes them into one command — and the result is
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 nestedHeader = (name) => CommandNeutralizer.text(`▸ ${name.replace(/\r\n|\r|\n/g, " ")}`);
131
- /** Drop a transcript without writing it, so a green step stays quiet. */
132
- const discard = (state) => Effect.sync(() => {
133
- state.entries.length = 0;
134
- });
135
- /** Write a transcript out and clear it, so a second flush is a no-op. */
136
- const flush = (state) => Effect.suspend(() => {
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
- const make = Effect.gen(function* () {
147
- const env = yield* ActionEnvironment;
148
- const flushActive = Effect.flatMap(ActiveBuffer, (state) => state === null ? Effect.void : flush(state));
149
- const withBuffer = (label, effect, options) => Effect.gen(function* () {
150
- const minimum = yield* References.MinimumLogLevel;
151
- if ((yield* env.isDebug) || LogLevel.isLessThanOrEqualTo(minimum, "Debug")) return yield* effect;
152
- const state = {
153
- label,
154
- entries: []
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
- const buffering = Logger.make((options) => {
157
- if (LogLevel.isGreaterThanOrEqualTo(options.logLevel, "Warn")) {
158
- commandLogger.log(options);
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
- state.entries.push(formatMessage(options.message));
197
+ node.detail.push(...formatMessage(entry.message).split(/\r\n|\r|\n/));
162
198
  });
163
- return yield* effect.pipe(Effect.provideService(References.MinimumLogLevel, "All"), Effect.provideService(Logger.CurrentLoggers, /* @__PURE__ */ new Set([buffering])), Effect.provideService(ActiveBuffer, state), Effect.onExit((exit) => Exit.isSuccess(exit) && options?.onSuccess === "discard" ? discard(state) : flush(state)));
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.tapCause(Effect.provideService(effect, GroupDepth, depth + 1), () => flushActive);
168
- return depth === 0 ? Effect.acquireUseRelease(Console.log(WorkflowCommand.group(name)), () => body, () => Console.log(WorkflowCommand.endGroup())) : Effect.andThen(Console.log(nestedHeader(name)), body);
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
- heading: (name, effect) => Effect.andThen(Console.log(nestedHeader(name)), effect),
171
- withBuffer,
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, buffered step transcripts, notices — and the `Logger` that renders
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.group("install", logger.withBuffer("pnpm", Effect.logInfo("resolving")));
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, the buffered step renderer, notices and annotations.
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, heading and buffer wrappers pass their
238
- * effect through unchanged, so the double does not model group nesting:
239
- * a test of nested-group output needs the live {@link ActionLogger.layer}.
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
- heading: (_name, effect) => effect,
244
- withBuffer: (_label, effect) => effect,
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
  /**
@@ -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
  /**
@@ -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,17 +1,15 @@
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
- import { BlobTransferError } from "./BlobTransfer.js";
3
5
  import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
4
6
  import { unzipCommand, zipCommand, zipManifest } from "./internal/archiveCommands.js";
5
- import { blobCause } from "./internal/blobCause.js";
7
+ import { httpFileTransfer } from "./internal/blobTransport.js";
6
8
  import { digestFileHex } from "./internal/digest.js";
7
9
  import { isWindowsRunner } from "./internal/runner.js";
8
10
  import { spawnOnce } from "./internal/spawn.js";
9
11
  import { CONFLICT, field, isOk, stringField, twirpCall, twirpFailureFields } from "./internal/twirp.js";
10
12
  import { unstubbed } from "./internal/unstubbed.js";
11
- import { Context, DateTime, Duration, Effect, FileSystem, Layer, Option, Path, Result, Schema } from "effect";
12
- import { HttpClient } from "effect/http";
13
- import { BlobClient, BlockBlobClient } from "@azure/storage-blob";
14
- import { ChildProcessSpawner } from "effect/process";
15
13
 
16
14
  // src/Artifact.ts
17
15
  /**
@@ -76,36 +74,6 @@ const SERVICE = "github.actions.results.api.v1.ArtifactService";
76
74
  * create the backend rejects.
77
75
  */
78
76
  const ARTIFACT_VERSION = 7;
79
- /**
80
- * The Azure half, duplicated on purpose.
81
- *
82
- * @remarks
83
- * `@azure/storage-blob` may be imported here, by `ActionCache` and by
84
- * `BlobStore.githubCache`, and nowhere else. Hoisting these two calls into a
85
- * shared `internal/` helper is exactly how a heavy import leaks into the graph
86
- * of a module that only sets an output; `__test__/reachability.test.ts`
87
- * measures that these are the only three.
88
- */
89
- const azure = {
90
- uploadFile: (url, file) => Effect.tryPromise({
91
- try: () => new BlockBlobClient(url).uploadFile(file, {
92
- blockSize: 67108864,
93
- concurrency: 8,
94
- maxSingleShotSize: 134217728
95
- }),
96
- catch: (cause) => new BlobTransferError({
97
- reason: "uploadFailed",
98
- cause: blobCause(cause)
99
- })
100
- }).pipe(Effect.asVoid),
101
- downloadToFile: (url, file) => Effect.tryPromise({
102
- try: () => new BlobClient(url).downloadToFile(file),
103
- catch: (cause) => new BlobTransferError({
104
- reason: "downloadFailed",
105
- cause: blobCause(cause)
106
- })
107
- }).pipe(Effect.asVoid)
108
- };
109
77
  /** One row of a `ListArtifacts` answer, read under either field spelling. */
110
78
  const toItem = (row) => {
111
79
  const createdAt = stringField(row, "createdAt");
@@ -116,9 +84,10 @@ const toItem = (row) => {
116
84
  ...createdAt === void 0 ? {} : { createdAt }
117
85
  };
118
86
  };
119
- const make = (transfer) => Effect.gen(function* () {
87
+ const make = (custom) => Effect.gen(function* () {
120
88
  const http = yield* HttpClient.HttpClient;
121
89
  const fs = yield* FileSystem.FileSystem;
90
+ const transfer = custom ?? httpFileTransfer(http, fs);
122
91
  const path = yield* Path.Path;
123
92
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
124
93
  const env = yield* ActionEnvironment;
@@ -373,8 +342,16 @@ const dies = unstubbed("Artifact.makeTest");
373
342
  * @public
374
343
  */
375
344
  var Artifact = class Artifact extends Context.Service()("@effected/github-actions/Artifact") {
376
- /** The service, over the real Azure client and the real `zip`. */
377
- static layer = Layer.effect(this, make(azure));
345
+ /**
346
+ * The service, over the `HttpClient` blob transport and the real `zip`.
347
+ *
348
+ * @remarks
349
+ * Requires `HttpClient` in `R`: the signed-url upload and download go through
350
+ * the caller's client, not a bundled SDK or a platform client of this
351
+ * package's own. Also requires `FileSystem`, `Path`, `ChildProcessSpawner`
352
+ * and `ActionEnvironment`.
353
+ */
354
+ static layer = Layer.effect(this, make());
378
355
  /**
379
356
  * The service, over a supplied transport.
380
357
  *