|
| 1 | +import { readFileSync } from "node:fs"; |
1 | 2 | import { describe, expect, it } from "vitest"; |
| 3 | +import { parse } from "yaml"; |
2 | 4 | import { |
3 | 5 | clawHubIdentityFromEnvironment, |
4 | 6 | createClawHubParentAuthorization, |
@@ -44,6 +46,26 @@ function transactions(count = 1) { |
44 | 46 | } |
45 | 47 |
|
46 | 48 | describe("ClawHub parent publication authorization", () => { |
| 49 | + it("publishes source metadata for the exact candidate sealed into authorization", () => { |
| 50 | + const workflow = parse( |
| 51 | + readFileSync(".github/workflows/plugin-clawhub-release.yml", "utf8"), |
| 52 | + ) as { |
| 53 | + jobs: Record< |
| 54 | + string, |
| 55 | + { steps?: { env?: Record<string, string> }[]; with?: Record<string, string> } |
| 56 | + >; |
| 57 | + }; |
| 58 | + const candidate = workflow.jobs.seal_clawhub_transactions?.steps?.find( |
| 59 | + (step) => step.env?.TARGET_SHA, |
| 60 | + )?.env?.TARGET_SHA; |
| 61 | + expect(candidate).toBe("${{ needs.preview_plugins_clawhub.outputs.ref_revision }}"); |
| 62 | + // ClawHub compares both source fields with the candidate SHA in the publish token. |
| 63 | + expect(workflow.jobs.publish_plugins_clawhub?.with).toMatchObject({ |
| 64 | + source_commit: candidate, |
| 65 | + source_ref: candidate, |
| 66 | + }); |
| 67 | + }); |
| 68 | + |
47 | 69 | it("binds the full release roster beyond 8 KiB without mixing parent and child refs", () => { |
48 | 70 | const sealed = transactions(89); |
49 | 71 | const receipt = createClawHubParentAuthorization(sealed, "automated-awaited"); |
|
0 commit comments