|
| 1 | +import fs from "node:fs" |
| 2 | +import path from "node:path" |
| 3 | +import { fileURLToPath } from "node:url" |
| 4 | + |
| 5 | +const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..") |
| 6 | +const releaseCommand = fs.readFileSync(path.join(repositoryRoot, ".roo/commands/release.md"), "utf8") |
| 7 | +const topLevelSteps = [...releaseCommand.matchAll(/^(\d+)\. .+$/gm)] |
| 8 | +const finalStepStart = topLevelSteps.find((step) => step[1] === "15")?.index ?? -1 |
| 9 | +const finalStep = releaseCommand.slice(finalStepStart) |
| 10 | + |
| 11 | +describe("stable release command documentation handoff", () => { |
| 12 | + it("keeps the docs PR as final step 15 after publication and the release merge queue", () => { |
| 13 | + expect(topLevelSteps.map((step) => Number(step[1])).at(-1)).toBe(15) |
| 14 | + expect(finalStepStart).toBeGreaterThan(releaseCommand.indexOf("14. After a successful deployment")) |
| 15 | + expect(finalStep).toMatch(/only after[\s\S]*marketplace workflow[\s\S]*exact stable tag[\s\S]*succeeded/i) |
| 16 | + expect(finalStep).toMatch(/GitHub release exists/i) |
| 17 | + expect(finalStep).toMatch(/step 14[\s\S]*merge queue/i) |
| 18 | + expect(finalStep).toMatch(/final stable extension release step/i) |
| 19 | + expect(finalStep).toMatch(/does not apply to nightly, CLI, npm, or types releases/i) |
| 20 | + }) |
| 21 | + |
| 22 | + it("targets a separate Zoo-Code-Docs PR with the required branch and PR conventions", () => { |
| 23 | + expect(finalStep).toContain("Zoo-Code-Org/Zoo-Code-Docs") |
| 24 | + expect(finalStep).toContain("docs/release-v[version]") |
| 25 | + expect(finalStep).toContain("docs(release): document v[version]") |
| 26 | + expect(finalStep).toContain("[Docs] Update documentation for Zoo Code v[version]") |
| 27 | + expect(finalStep).toMatch(/base `main`/i) |
| 28 | + expect(finalStep).toMatch(/separate docs PR[\s\S]*will not be auto-merged/i) |
| 29 | + expect(finalStep).toMatch(/Never enable auto-merge/i) |
| 30 | + }) |
| 31 | + |
| 32 | + it("requires release notes, navigation registration, and evergreen documentation review", () => { |
| 33 | + expect(finalStep).toContain("docs/update-notes/v[version].md") |
| 34 | + expect(finalStep).toContain("docs/update-notes/index.md") |
| 35 | + expect(finalStep).toContain("sidebars.ts") |
| 36 | + expect(finalStep).toMatch(/newest-first/i) |
| 37 | + expect(finalStep).toMatch(/per-PR documentation impact matrix/i) |
| 38 | + expect(finalStep).toMatch(/every user-visible change/i) |
| 39 | + expect(finalStep).toMatch(/canonical evergreen provider, feature, tool, and getting-started pages/i) |
| 40 | + expect(finalStep).toMatch(/implementation-only exclusion/i) |
| 41 | + expect(finalStep).toMatch(/no-change rationale/i) |
| 42 | + }) |
| 43 | + |
| 44 | + it("synchronizes the sole docs package version without tags or lockfile drift", () => { |
| 45 | + expect(finalStep).toContain('pnpm version "$VERSION" --no-git-tag-version --allow-same-version') |
| 46 | + expect(finalStep).toMatch(/sole package version in `package\.json`/i) |
| 47 | + expect(finalStep).toMatch(/no tag/i) |
| 48 | + expect(finalStep).toMatch(/no incidental `pnpm-lock\.yaml` change/i) |
| 49 | + expect(finalStep).toMatch(/never downgrade/i) |
| 50 | + }) |
| 51 | + |
| 52 | + it("protects existing checkouts and establishes an exact clean origin/main base", () => { |
| 53 | + expect(finalStep).toContain("../Zoo-Code-Docs") |
| 54 | + expect(finalStep).toContain("https://github.com/Zoo-Code-Org/Zoo-Code-Docs.git") |
| 55 | + expect(finalStep).toMatch(/clean temporary directory/i) |
| 56 | + expect(finalStep).toMatch(/read `AGENTS\.md` and `\.roorules`/i) |
| 57 | + expect(finalStep).toMatch(/abort if the worktree is dirty/i) |
| 58 | + expect(finalStep).toMatch(/verify `origin`[\s\S]*default branch is `main`/i) |
| 59 | + expect(finalStep).toContain("git merge --ff-only origin/main") |
| 60 | + expect(finalStep).toMatch(/Never stash or reset[\s\S]*never change remotes/i) |
| 61 | + }) |
| 62 | + |
| 63 | + it("handles merged, open, and branch-only prior attempts without unsafe pushes", () => { |
| 64 | + expect(finalStep).toMatch( |
| 65 | + /query the local branch, the remote branch, and all matching open, closed, and merged PRs/i, |
| 66 | + ) |
| 67 | + expect(finalStep).toMatch(/matching merged PR[\s\S]*complete/i) |
| 68 | + expect(finalStep).toMatch(/Reuse and validate a matching open PR/i) |
| 69 | + expect(finalStep).toMatch(/branch without a PR only when[\s\S]*expected release-docs work/i) |
| 70 | + expect(finalStep).toMatch(/closed-unmerged PR[\s\S]*wrong repository or base[\s\S]*divergence/i) |
| 71 | + expect(finalStep).toMatch(/Never force-push blindly/i) |
| 72 | + expect(finalStep).toMatch(/stop on any remote race/i) |
| 73 | + }) |
| 74 | + |
| 75 | + it("runs every docs validation and blocks on newly introduced content warnings", () => { |
| 76 | + const validationCommands = [ |
| 77 | + "mise install", |
| 78 | + "pnpm install --frozen-lockfile", |
| 79 | + "pnpm run check-types", |
| 80 | + "pnpm run lint", |
| 81 | + "pnpm run lint:unused", |
| 82 | + "pnpm run build", |
| 83 | + "git diff --check", |
| 84 | + ] |
| 85 | + |
| 86 | + for (const command of validationCommands) expect(finalStep).toContain(command) |
| 87 | + expect(finalStep).toMatch(/Inspect build warnings explicitly/i) |
| 88 | + expect(finalStep).toMatch( |
| 89 | + /Block the PR on newly introduced broken-link, document, MDX, sidebar, or content warnings/i, |
| 90 | + ) |
| 91 | + expect(finalStep).toMatch(/changed and staged scope[\s\S]*no generated output/i) |
| 92 | + }) |
| 93 | + |
| 94 | + it("verifies local auth and permissions without assuming cross-repository token access", () => { |
| 95 | + expect(finalStep).toContain("gh auth status") |
| 96 | + expect(finalStep).toMatch(/access and push permission/i) |
| 97 | + expect(finalStep).toMatch(/Do not assume or claim that `GITHUB_TOKEN` has cross-repository access/i) |
| 98 | + }) |
| 99 | + |
| 100 | + it("retains source metadata and specifies partial-failure and final reporting", () => { |
| 101 | + expect(finalStep).toMatch(/exact Zoo Code changelog section/i) |
| 102 | + expect(finalStep).toMatch(/complete merged-PR inventory/i) |
| 103 | + expect(finalStep).toMatch( |
| 104 | + /release PR URL[\s\S]*GitHub release URL[\s\S]*workflow URL[\s\S]*publication timestamp/i, |
| 105 | + ) |
| 106 | + expect(finalStep).toMatch(/Docs failure cannot roll back or invalidate the published extension/i) |
| 107 | + expect(finalStep).toContain("Zoo Code v[version] is already published and docs PR completion is pending.") |
| 108 | + expect(finalStep).toMatch(/failed checkpoint, checkout path, branch, PR URL\/state[\s\S]*safe recovery action/i) |
| 109 | + expect(finalStep).toMatch(/final release report[\s\S]*release\/tag\/workflow URLs/i) |
| 110 | + expect(finalStep).toMatch(/docs PR URL\/state[\s\S]*docs branch and commit SHA/i) |
| 111 | + expect(finalStep).toMatch(/release-note\/index\/sidebar status[\s\S]*evergreen documentation status/i) |
| 112 | + expect(finalStep).toMatch(/confirmation that the separate docs PR was not auto-merged/i) |
| 113 | + }) |
| 114 | +}) |
0 commit comments