@effected/github-actions 0.26.0 → 0.27.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.
package/ActionLogger.js CHANGED
@@ -98,7 +98,7 @@ const commandLogger = Logger.withConsoleLog(renderLogger);
98
98
  */
99
99
  const ActiveBuffer = Context.Reference("@effected/github-actions/ActiveBuffer", { defaultValue: () => null });
100
100
  /**
101
- * How many {@link ActionLoggerShape.group} calls the current fiber is inside.
101
+ * How many log groups are open around the current fiber.
102
102
  *
103
103
  * @remarks
104
104
  * The runner does not nest groups: a second `::group::` implicitly ends the
@@ -108,11 +108,18 @@ const ActiveBuffer = Context.Reference("@effected/github-actions/ActiveBuffer",
108
108
  * `Context.Reference` is provided around the body, so it unwinds on every
109
109
  * exit path with nothing to restore.
110
110
  *
111
+ * Keyed by `WorkflowCommand.groupDepthKey`, the kit-wide key for this count,
112
+ * rather than a key of this package's own: Effect looks a reference up by its
113
+ * key, so `@effected/cli`'s `Render.context`, which builds its own reference
114
+ * from the same key, sees the depth this member provides, and a document it
115
+ * renders inside a group opens no second one.
116
+ *
111
117
  * @internal
112
118
  */
113
- const GroupDepth = Context.Reference("@effected/github-actions/GroupDepth", { defaultValue: () => 0 });
119
+ const GroupDepth = Context.Reference(WorkflowCommand.groupDepthKey, { defaultValue: () => 0 });
114
120
  /**
115
- * The line a nested group writes in place of a second `::group::`.
121
+ * The `▸ <name>` line a nested group writes in place of a second `::group::`,
122
+ * and the line {@link ActionLoggerShape.heading} writes.
116
123
  *
117
124
  * @remarks
118
125
  * Line breaks collapse to spaces so the header stays one line — the
@@ -160,6 +167,7 @@ const make = Effect.gen(function* () {
160
167
  const body = Effect.tapCause(Effect.provideService(effect, GroupDepth, depth + 1), () => flushActive);
161
168
  return depth === 0 ? Effect.acquireUseRelease(Console.log(WorkflowCommand.group(name)), () => body, () => Console.log(WorkflowCommand.endGroup())) : Effect.andThen(Console.log(nestedHeader(name)), body);
162
169
  }),
170
+ heading: (name, effect) => Effect.andThen(Console.log(nestedHeader(name)), effect),
163
171
  withBuffer,
164
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}`))),
165
173
  notice: (message, properties = {}) => Console.log(WorkflowCommand.notice(message, properties)),
@@ -226,12 +234,13 @@ var ActionLogger = class ActionLogger extends Context.Service()("@effected/githu
226
234
  * **A recorded exception to the die-on-unstubbed rule**, alongside
227
235
  * {@link ActionEnvironment.makeTest}. A logger that dies when a suite logs
228
236
  * would make every double unusable, and silence is the honest default for a
229
- * service whose whole job is output. Group and buffer wrappers pass their
237
+ * service whose whole job is output. Group, heading and buffer wrappers pass their
230
238
  * effect through unchanged, so the double does not model group nesting:
231
239
  * a test of nested-group output needs the live {@link ActionLogger.layer}.
232
240
  */
233
241
  static makeTest = (overrides = {}) => ({
234
242
  group: (_name, effect) => effect,
243
+ heading: (_name, effect) => effect,
235
244
  withBuffer: (_label, effect) => effect,
236
245
  withStep: (_name, effect) => effect,
237
246
  notice: () => Effect.void,
@@ -1,5 +1,5 @@
1
- import { OidcTokenIssuer } from "./OidcTokenIssuer.js";
2
1
  import { Secret } from "./Secret.js";
2
+ import { OidcTokenIssuer } from "./OidcTokenIssuer.js";
3
3
  import { Effect } from "effect";
4
4
  import { workloadCredential } from "@effected/npm";
5
5
 
@@ -1,5 +1,7 @@
1
1
  import { ActionEnvironment } from "./ActionEnvironment.js";
2
2
  import { unstubbed } from "./internal/unstubbed.js";
3
+ import { ActionOutputs } from "./ActionOutputs.js";
4
+ import { Secret } from "./Secret.js";
3
5
  import { Context, Effect, Layer, Redacted, Schema } from "effect";
4
6
  import { HttpClient, HttpClientRequest } from "effect/http";
5
7
  import { Oidc } from "@effected/oidc";
@@ -81,12 +83,13 @@ const unsignedJwt = (header, payload) => {
81
83
  const make = Effect.gen(function* () {
82
84
  const env = yield* ActionEnvironment;
83
85
  const http = yield* HttpClient.HttpClient;
86
+ const outputs = yield* ActionOutputs;
84
87
  const required = (name) => env.get(name).pipe(Effect.mapError(() => new OidcTokenError({
85
88
  reason: "unavailable",
86
89
  detail: name
87
90
  })));
88
91
  /**
89
- * The raw JWT, before it is wrapped.
92
+ * The raw JWT, masked, before it is wrapped.
90
93
  *
91
94
  * @remarks
92
95
  * `claims` reads this rather than unwrapping what `token` returns, so
@@ -94,6 +97,11 @@ const make = Effect.gen(function* () {
94
97
  * declassification invariant is that `Secret.ts` is the only place a secret
95
98
  * becomes a string, and a wrap-then-immediately-unwrap here would be a
96
99
  * genuine exception to it rather than a cosmetic one.
100
+ *
101
+ * This is the one place every issued token passes, so it is where the token
102
+ * is registered with the runner's log filter: `token` and `claims` both get
103
+ * it, once per token, before anything downstream can decode, fail on or
104
+ * declassify it. The `ActionOutputs` is the one the layer was built with.
97
105
  */
98
106
  const issue = Effect.fn("OidcTokenIssuer.token")(function* (audience) {
99
107
  const bearer = yield* required(REQUEST_TOKEN);
@@ -107,10 +115,12 @@ const make = Effect.gen(function* () {
107
115
  reason: "requestFailed",
108
116
  status: response.status
109
117
  }));
110
- return (yield* HttpClientResponse.schemaBodyJson(TokenEnvelope)(response).pipe(Effect.mapError((cause) => new OidcTokenError({
118
+ const envelope = yield* HttpClientResponse.schemaBodyJson(TokenEnvelope)(response).pipe(Effect.mapError((cause) => new OidcTokenError({
111
119
  reason: "malformedResponse",
112
120
  cause
113
- })))).value;
121
+ })));
122
+ yield* Secret.mask(Redacted.make(envelope.value)).pipe(Effect.provideService(ActionOutputs, outputs));
123
+ return envelope.value;
114
124
  });
115
125
  return {
116
126
  token: (audience) => Effect.map(issue(audience), Redacted.make),
@@ -150,6 +160,13 @@ var OidcTokenIssuer = class OidcTokenIssuer extends Context.Service()("@effected
150
160
  * @remarks
151
161
  * Fails with {@link OidcTokenError} (`unavailable`) at use when the workflow
152
162
  * lacks `permissions: id-token: write`.
163
+ *
164
+ * Requires {@link ActionOutputs} because every token it issues is masked
165
+ * through it at issuance (see {@link OidcTokenIssuerShape.token}). Under
166
+ * `ActionRuntime.layer` that is already at hand; a worker that composes
167
+ * `ActionOutputs.layerDetached` gets an issuer whose mask is the documented
168
+ * no-op, which is the right thing there and no substitute for minting in
169
+ * the parent.
153
170
  */
154
171
  static layer = Layer.effect(this, make);
155
172
  /**
package/index.d.ts CHANGED
@@ -293,8 +293,8 @@ interface WithStepOptions {
293
293
  readonly summary?: string;
294
294
  }
295
295
  /**
296
- * The members of the {@link ActionLogger} service: log groups, buffered steps,
297
- * notices and source annotations.
296
+ * The members of the {@link ActionLogger} service: log groups and headings,
297
+ * buffered steps, notices and source annotations.
298
298
  *
299
299
  * @public
300
300
  */
@@ -323,15 +323,40 @@ interface ActionLoggerShape {
323
323
  * 2. **A fiber forked inside a group keeps the depth it was forked at.** A
324
324
  * `forkChild` joined inside the group nests correctly; a detached fiber
325
325
  * that outlives the group still writes headers rather than a group.
326
- * 3. **Only groups opened here are counted.** A raw
327
- * `WorkflowCommand.group(...)`, a document rendered by `@effected/cli`'s
328
- * `Render.githubLog` with a top-level collapsible, or a consumer's own
329
- * wrapper opens a group this member cannot see, and a group opened
330
- * inside one still nests at the runner.
326
+ * 3. **Only a writer that reads the shared depth is counted.** The depth
327
+ * lives in the fiber-local keyed by `WorkflowCommand.groupDepthKey`
328
+ * (from `@effected/github-commands`), which `@effected/cli` reads too:
329
+ * `Render.context` built inside a group carries it as
330
+ * `RenderContext.groupDepth`, so `Doc.print` and `Render.githubLog`
331
+ * render a top-level collapsible as plain text there rather than as a
332
+ * second group. A raw `WorkflowCommand.group(...)`, or a consumer's
333
+ * own wrapper that does not read the key, opens a group this member
334
+ * cannot see, and a group opened inside one still nests at the runner.
331
335
  * 4. **The test doubles do not model nesting.** `makeTest`, `layerTest` and
332
336
  * `layerSilent` pass the effect through unchanged.
333
337
  */
334
338
  readonly group: <A, E, R>(name: string, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
339
+ /**
340
+ * Run an effect under a `▸ <name>` header line, without opening a group.
341
+ *
342
+ * @remarks
343
+ * The phase-level banner: the same one-line, neutralized header a nested
344
+ * {@link ActionLoggerShape.group} writes, then the body, with no
345
+ * `::group::` and no change to the depth. So the groups inside it stay
346
+ * top level and each renders as its own collapsible section in the runner
347
+ * log, which a `group` wrapper cannot give them: the runner does not nest
348
+ * groups, and a wrapper that opened one would swallow every inner group
349
+ * into a header line. Reach for this when a phase encloses groups, and for
350
+ * `group` when it encloses only lines.
351
+ *
352
+ * The header goes out through `Console`, like a group command, so it is
353
+ * never captured into, or discarded with, an enclosing `withBuffer` or
354
+ * `withStep` transcript. Nothing is written when the body ends, and a
355
+ * failure flushes no buffer here: the groups inside do that for their own
356
+ * sections. Called inside an open group it is simply a header line in that
357
+ * group. The test doubles pass the body through unchanged.
358
+ */
359
+ readonly heading: <A, E, R>(name: string, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
335
360
  /**
336
361
  * Run an effect with its verbose output captured and replayed on exit.
337
362
  *
@@ -466,7 +491,7 @@ export declare class ActionLogger extends ActionLogger_base {
466
491
  * **A recorded exception to the die-on-unstubbed rule**, alongside
467
492
  * {@link ActionEnvironment.makeTest}. A logger that dies when a suite logs
468
493
  * would make every double unusable, and silence is the honest default for a
469
- * service whose whole job is output. Group and buffer wrappers pass their
494
+ * service whose whole job is output. Group, heading and buffer wrappers pass their
470
495
  * effect through unchanged, so the double does not model group nesting:
471
496
  * a test of nested-group output needs the live {@link ActionLogger.layer}.
472
497
  */
@@ -2000,6 +2025,17 @@ interface OidcTokenIssuerShape {
2000
2025
  * Omitting the audience sends no `audience` parameter at all, matching
2001
2026
  * `@actions/core.getIDToken` — the runner's default audience is not the empty
2002
2027
  * string.
2028
+ *
2029
+ * **The live issuer masks the token at issuance.** Every token it fetches is
2030
+ * registered with the runner's log filter (`Secret.mask`, one `::add-mask::`)
2031
+ * before it is returned, so a consumer that declassifies and logs it, or
2032
+ * serializes an error carrying it, prints a redaction rather than the JWT.
2033
+ * Masking is the issuer's job because it is the one place every token
2034
+ * passes; a consumer masking again is harmless. The caveat `Secret.mask`
2035
+ * documents applies: in a **detached worker** the mask line itself is the
2036
+ * leak, since no runner parses that process's stdout, so mint in the parent
2037
+ * and compose `ActionOutputs.layerDetached` in the worker, under which the
2038
+ * mask is a no-op. The doubles mask nothing: they issue no real token.
2003
2039
  */
2004
2040
  readonly token: (audience?: string) => Effect.Effect<Redacted.Redacted<string>, OidcTokenError>;
2005
2041
  /**
@@ -2028,6 +2064,12 @@ interface OidcTokenIssuerShape {
2028
2064
  * {@link OidcTokenIssuer.layerFor} answers with real, decodable claims, so
2029
2065
  * a test cannot silently skip the path under test because the double
2030
2066
  * returned a token that is not a JWT.
2067
+ *
2068
+ * The token this fetches to decode is masked too, exactly as
2069
+ * {@link OidcTokenIssuerShape.token}'s is, though it never leaves: the raw
2070
+ * JWT exists in this process for the decode, and a decode failure's cause can
2071
+ * carry what it failed on, so the mask costs one command and closes that
2072
+ * path. There is one mask site, where the token is issued, for both members.
2031
2073
  */
2032
2074
  readonly claims: (audience?: string) => Effect.Effect<ActionsOidcClaims, OidcTokenError>;
2033
2075
  }
@@ -2077,8 +2119,15 @@ export declare class OidcTokenIssuer extends OidcTokenIssuer_base {
2077
2119
  * @remarks
2078
2120
  * Fails with {@link OidcTokenError} (`unavailable`) at use when the workflow
2079
2121
  * lacks `permissions: id-token: write`.
2122
+ *
2123
+ * Requires {@link ActionOutputs} because every token it issues is masked
2124
+ * through it at issuance (see {@link OidcTokenIssuerShape.token}). Under
2125
+ * `ActionRuntime.layer` that is already at hand; a worker that composes
2126
+ * `ActionOutputs.layerDetached` gets an issuer whose mask is the documented
2127
+ * no-op, which is the right thing there and no substitute for minting in
2128
+ * the parent.
2080
2129
  */
2081
- static readonly layer: Layer.Layer<OidcTokenIssuer, never, ActionEnvironment | HttpClient.HttpClient>;
2130
+ static readonly layer: Layer.Layer<OidcTokenIssuer, never, ActionEnvironment | HttpClient.HttpClient | ActionOutputs>;
2082
2131
  /**
2083
2132
  * An **unsigned** JWT carrying these claims.
2084
2133
  *
package/index.js CHANGED
@@ -6,10 +6,10 @@ import { ActionState, ActionStateError } from "./ActionState.js";
6
6
  import { Action, ActionRuntime, describeCause } from "./Action.js";
7
7
  import { BlobTransferError } from "./BlobTransfer.js";
8
8
  import { ActionCache, ActionCacheError } from "./ActionCache.js";
9
+ import { Secret } from "./Secret.js";
9
10
  import { OidcTokenError, OidcTokenIssuer } from "./OidcTokenIssuer.js";
10
11
  import { ActionsIdentityToken } from "./ActionsIdentityToken.js";
11
12
  import { ActionsProvenance } from "./ActionsProvenance.js";
12
- import { Secret } from "./Secret.js";
13
13
  import { ActionsRegistryCredential } from "./ActionsRegistryCredential.js";
14
14
  import { Artifact, ArtifactError } from "./Artifact.js";
15
15
  import { BlobEnvelope, BlobMetadataDecodeError, BlobMetadataEncodeError, NotABlobEnvelopeError, TruncatedBlobEnvelopeError, UnsupportedBlobEnvelopeVersionError } from "./BlobEnvelope.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/github-actions",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
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": [
@@ -40,15 +40,15 @@
40
40
  "dependencies": {
41
41
  "@azure/storage-blob": "^12.33.0",
42
42
  "@effected/crypto": "^0.1.1",
43
- "@effected/github": "^0.23.1",
44
- "@effected/github-commands": "^0.6.1",
43
+ "@effected/github": "^0.24.0",
44
+ "@effected/github-commands": "^0.6.2",
45
45
  "@effected/glob": "^0.14.0",
46
46
  "@effected/jwt": "^0.6.0",
47
- "@effected/markdown": "^0.21.0",
48
- "@effected/npm": "^0.26.0",
47
+ "@effected/markdown": "^0.22.0",
48
+ "@effected/npm": "^0.26.1",
49
49
  "@effected/oidc": "^0.1.2",
50
- "@effected/sbom": "^0.15.1",
51
- "@effected/semver": "^0.16.0",
50
+ "@effected/sbom": "^0.16.0",
51
+ "@effected/semver": "^0.17.0",
52
52
  "@effected/templates": "^0.14.1",
53
53
  "@effected/walker": "^0.19.0"
54
54
  },