Skip to content

Commit 15bf213

Browse files
jottakkacursoragent
andcommitted
ci: verify toolkit docs before publishing
Run the generator's isolated type-check and test suite before publishing, and support manual verification branches without production review noise. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 6c13a5f commit 15bf213

4 files changed

Lines changed: 32 additions & 10 deletions

File tree

.github/workflows/generate-toolkit-docs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This workflow regenerates toolkit JSON and opens a PR with the changes. It can b
44

55
## What it does
66

7-
1. Builds the toolkit docs generator.
8-
2. Generates toolkit JSON in `toolkit-docs-generator/data/toolkits` using the Engine tool metadata and summary endpoints.
7+
1. Type-checks and tests the toolkit docs generator.
8+
2. Generates toolkit JSON in `toolkit-docs-generator/data/toolkits` using the Engine tool metadata endpoint.
99
3. Syncs integrations sidebar navigation from the generated JSON.
1010
4. Creates or updates a PR on the stable `automation/toolkit-docs` branch if any files changed. Later runs overwrite that open PR with the latest generated docs.
1111

.github/workflows/generate-toolkit-docs.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Generate toolkit docs
22
# Description: Generate toolkit JSON from Engine API, then sync sidebar navigation.
33
# Flow:
4-
# 1) Build the toolkit docs generator
4+
# 1) Type-check and test the toolkit docs generator
55
# 2) Generate toolkit JSON into toolkit-docs-generator/data/toolkits
66
# 3) Sync integrations sidebar _meta.tsx from toolkit-docs-generator/data/toolkits
77
# 4) Create or update a PR if changes were produced
@@ -10,6 +10,11 @@ on:
1010
repository_dispatch:
1111
types: [porter_deploy_succeeded]
1212
workflow_dispatch:
13+
inputs:
14+
pr_branch:
15+
description: "Optional isolated branch for a verification PR"
16+
required: false
17+
type: string
1318
# 11:00 UTC = 3 AM PST / 4 AM PDT — late enough that DST drift doesn't matter.
1419
schedule:
1520
- cron: "0 11 * * *"
@@ -48,9 +53,8 @@ jobs:
4853
- name: Install dependencies
4954
run: pnpm install --frozen-lockfile
5055

51-
- name: Build toolkit docs generator
52-
run: pnpm build
53-
working-directory: toolkit-docs-generator
56+
- name: Validate toolkit docs generator
57+
run: pnpm run toolkit-docs:check
5458

5559
- name: Generate toolkit docs
5660
run: |
@@ -96,22 +100,24 @@ jobs:
96100
with:
97101
token: ${{ secrets.DOCS_PUBLISHABLE_GH_TOKEN }}
98102
commit-message: "[AUTO] Adding MCP Servers docs update"
99-
title: "[AUTO] Adding MCP Servers docs update"
103+
title: ${{ inputs.pr_branch && '[TEST] Generated toolkit docs verification' || '[AUTO] Adding MCP Servers docs update' }}
100104
body: |
101-
This PR was generated after a Porter deploy succeeded.
105+
This PR was generated by the toolkit docs workflow.
102106
103107
- Trigger: ${{ github.event_name }}
108+
- Source ref: ${{ github.ref_name }}
104109
- Deploy env: ${{ github.event.client_payload.env || 'unknown' }}
105110
- Deploy SHA: ${{ github.event.client_payload.deploy_sha || 'unknown' }}
106111
- Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
107112
# Stable branch so later runs update the open auto-PR instead of
108113
# opening a new one each time. create-pull-request force-pushes the
109114
# latest generated docs onto this branch.
110-
branch: automation/toolkit-docs
115+
base: ${{ inputs.pr_branch && github.ref_name || github.event.repository.default_branch || 'main' }}
116+
branch: ${{ inputs.pr_branch || 'automation/toolkit-docs' }}
111117
delete-branch: true
112118

113119
- name: Request team review
114-
if: steps.cpr.outputs.pull-request-number != ''
120+
if: steps.cpr.outputs.pull-request-number != '' && (github.event_name != 'workflow_dispatch' || inputs.pr_branch == '')
115121
continue-on-error: true
116122
run: gh pr edit ${{ steps.cpr.outputs.pull-request-number }} --add-reviewer ArcadeAI/engineering-tools-and-dx
117123
env:

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"lint": "pnpm exec ultracite check",
1111
"format": "pnpm exec ultracite fix",
1212
"prepare": "husky install",
13+
"toolkit-docs:typecheck": "tsc --noEmit --project toolkit-docs-generator/tsconfig.json",
14+
"toolkit-docs:test": "vitest run --root toolkit-docs-generator --config vitest.config.ts",
15+
"toolkit-docs:check": "pnpm run toolkit-docs:typecheck && pnpm run toolkit-docs:test",
1316
"translate": "pnpm dlx tsx scripts/i18n-sync/index.ts && pnpm format",
1417
"llmstxt": "pnpm dlx tsx scripts/generate-llmstxt.ts",
1518
"test": "vitest --run",

toolkit-docs-generator/tests/workflows/generate-toolkit-docs.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ test("porter workflow includes required triggers", () => {
2020
});
2121

2222
test("porter workflow generates docs and opens a PR", () => {
23+
expect(workflowContents).toContain("pnpm run toolkit-docs:check");
24+
expect(workflowContents).not.toContain("run: pnpm build");
25+
expect(workflowContents).not.toContain("name: Build toolkit docs generator");
2326
expect(workflowContents).toContain("pnpm dlx tsx src/cli/index.ts generate");
2427
expect(workflowContents).toContain("--skip-unchanged");
2528
expect(workflowContents).toContain("--require-complete");
@@ -60,3 +63,13 @@ test("workflow dispatch keeps default full-run behavior", () => {
6063
expect(workflowContents).not.toContain("inputs.providers");
6164
expect(workflowContents).not.toContain("PROVIDERS_INPUT=");
6265
});
66+
67+
test("workflow dispatch can create an isolated verification PR", () => {
68+
expect(workflowContents).toContain("pr_branch:");
69+
expect(workflowContents).toContain(
70+
"inputs.pr_branch || 'automation/toolkit-docs'"
71+
);
72+
expect(workflowContents).toContain(
73+
"inputs.pr_branch && github.ref_name || github.event.repository.default_branch || 'main'"
74+
);
75+
});

0 commit comments

Comments
 (0)