|
| 1 | +import { readFileSync } from "node:fs"; |
| 2 | +import { describe, expect, it } from "vitest"; |
| 3 | +import { parse } from "yaml"; |
| 4 | + |
| 5 | +const WORKFLOW = ".github/workflows/openclaw-performance.yml"; |
| 6 | + |
| 7 | +type WorkflowStep = { |
| 8 | +name?: string; |
| 9 | +run?: string; |
| 10 | +env?: Record<string, string>; |
| 11 | +}; |
| 12 | + |
| 13 | +type WorkflowJob = { |
| 14 | +steps?: WorkflowStep[]; |
| 15 | +}; |
| 16 | + |
| 17 | +type Workflow = { |
| 18 | +jobs?: Record<string, WorkflowJob>; |
| 19 | +}; |
| 20 | + |
| 21 | +function readWorkflow(): Workflow { |
| 22 | +return parse(readFileSync(WORKFLOW, "utf8")) as Workflow; |
| 23 | +} |
| 24 | + |
| 25 | +function findStep(name: string): WorkflowStep { |
| 26 | +const steps = readWorkflow().jobs?.kova?.steps ?? []; |
| 27 | +const step = steps.find((candidate) => candidate.name === name); |
| 28 | +expect(step).toBeDefined(); |
| 29 | +return step as WorkflowStep; |
| 30 | +} |
| 31 | + |
| 32 | +describe("OpenClaw performance workflow", () => { |
| 33 | +it("uses the clawgrit reports token for every report repo push path", () => { |
| 34 | +const prepare = findStep("Prepare clawgrit reports checkout"); |
| 35 | +const publish = findStep("Publish to clawgrit reports"); |
| 36 | + |
| 37 | +expect(prepare.env?.CLAWGRIT_REPORTS_TOKEN).toBe("${{ secrets.CLAWGRIT_REPORTS_TOKEN }}"); |
| 38 | +expect(publish.env?.CLAWGRIT_REPORTS_TOKEN).toBe("${{ secrets.CLAWGRIT_REPORTS_TOKEN }}"); |
| 39 | +expect(prepare.run).toContain( |
| 40 | +'remote add origin "https://x-access-token:${CLAWGRIT_REPORTS_TOKEN}@github.com/openclaw/clawgrit-reports.git"', |
| 41 | +); |
| 42 | +expect(publish.run).toContain( |
| 43 | +'remote set-url origin "https://x-access-token:${CLAWGRIT_REPORTS_TOKEN}@github.com/openclaw/clawgrit-reports.git"', |
| 44 | +); |
| 45 | +expect(publish.run).toContain('git -C "$reports_root" push origin HEAD:main'); |
| 46 | +}); |
| 47 | +}); |