Skip to content

Commit 2e26a61

Browse files
authored
Require PRs for manual docs maintenance (#109)
1 parent 58630e6 commit 2e26a61

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
- uses: actions/checkout@v4
2020
with:
2121
repository: Automattic/docs-agent
22-
ref: 5344a4bfbda4a0553cc92636258e46a715b1c72d
22+
ref: 397f32e5c82f662199f2c3555e32804ed0365d7f
2323
path: .producer/docs-agent
2424
- uses: actions/checkout@v4
2525
with:
2626
repository: Automattic/wp-codebox
27-
ref: 54c2f9a7bc3cd1fe20055d496c83efcfb99afb41
27+
ref: a2b02cd99ba645ba2250bf58c943bdd1eb13e690
2828
path: .producer/wp-codebox
2929
- uses: pnpm/action-setup@v4
3030
with:

.github/workflows/developer-docs-agent.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ concurrency:
2727
jobs:
2828
developer-docs-agent:
2929
name: Maintain Developer Docs
30-
uses: Automattic/docs-agent/.github/workflows/maintain-docs.yml@main
30+
uses: Automattic/docs-agent/.github/workflows/maintain-docs.yml@397f32e5c82f662199f2c3555e32804ed0365d7f
3131
with:
3232
audience: technical
3333
run_kind: ${{ github.event.inputs.run_kind || 'maintenance' }}
34+
require_pr: ${{ github.event_name == 'workflow_dispatch' }}
3435
base_ref: trunk
3536
docs_branch: docs-agent/build-with-wordpress-developer-docs
3637
writable_paths: README.md,docs/**,plugins/**/README.md

tests/docs-agent-workflows.test.mjs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { readFile } from "node:fs/promises"
44
import { resolve } from "node:path"
55

66
const root = resolve(new URL("..", import.meta.url).pathname)
7-
const docsAgentRevision = "5344a4bfbda4a0553cc92636258e46a715b1c72d"
8-
const wpCodeboxRevision = "54c2f9a7bc3cd1fe20055d496c83efcfb99afb41"
7+
const docsAgentRevision = "397f32e5c82f662199f2c3555e32804ed0365d7f"
8+
const docsAgentPackageRevision = "7b2df969c34de112ec7ad13189ba94226a7f76f3"
9+
const wpCodeboxRevision = "a2b02cd99ba645ba2250bf58c943bdd1eb13e690"
10+
const wpCodeboxWorkflowRef = "v0.12.23"
911
const docsAgentDir = process.env.DOCS_AGENT_DIR
1012
const wpCodeboxDir = process.env.WP_CODEBOX_DIR
1113

@@ -21,8 +23,8 @@ assert.equal(revision(wpCodeboxDir), wpCodeboxRevision, "WP Codebox checkout mus
2123
const docsAgentWorkflow = await readFile(resolve(docsAgentDir, ".github/workflows/maintain-docs.yml"), "utf8")
2224
const wpCodeboxContract = await readJson(wpCodeboxDir, "contracts/run-agent-task-reusable-workflow-interface.v1.json")
2325
assert.equal(wpCodeboxContract.schema, "wp-codebox/reusable-workflow-interface/v1")
24-
assert.match(docsAgentWorkflow, new RegExp(`uses: Automattic/wp-codebox/.github/workflows/run-agent-task.yml@${wpCodeboxRevision}`))
25-
assert.match(docsAgentWorkflow, /DOCS_AGENT_REVISION: \$\{\{ github\.job_workflow_sha \}\}/)
26+
assert.match(docsAgentWorkflow, new RegExp(`uses: Automattic/wp-codebox/.github/workflows/run-agent-task.yml@${wpCodeboxWorkflowRef}`))
27+
assert.match(docsAgentWorkflow, new RegExp(`DOCS_AGENT_PACKAGE_REVISION: ${docsAgentPackageRevision}`))
2628
assert.match(docsAgentWorkflow, /OPENAI_API_KEY: \$\{\{ secrets\.OPENAI_API_KEY \}\}/)
2729
assert.match(docsAgentWorkflow, /ACCESS_TOKEN: \$\{\{ github\.token \}\}/)
2830
assert.match(docsAgentWorkflow, /EXTERNAL_PACKAGE_SOURCE_POLICY: \$\{\{ secrets\.EXTERNAL_PACKAGE_SOURCE_POLICY \}\}/)
@@ -42,12 +44,14 @@ const workflows = [
4244
path: ".github/workflows/developer-docs-agent.yml",
4345
audience: "technical",
4446
runKind: true,
47+
revision: docsAgentRevision,
4548
writablePaths: "README.md,docs/**,plugins/**/README.md",
4649
},
4750
{
4851
path: ".github/workflows/skills-agent.yml",
4952
audience: "skills",
5053
runKind: false,
54+
revision: "main",
5155
writablePaths: "skills/**,plugins/**/skills/**,plugins/**/README.md",
5256
},
5357
]
@@ -61,7 +65,7 @@ for (const workflow of workflows) {
6165
const usedInputs = [...withBlock.matchAll(/^ ([a-z_]+):/gm)].map((match) => match[1])
6266
const usedSecrets = [...secretsBlock.matchAll(/^ ([A-Z_]+):/gm)].map((match) => match[1])
6367

64-
assert.match(source, /uses: Automattic\/docs-agent\/.github\/workflows\/maintain-docs.yml@main/)
68+
assert.match(source, new RegExp(`uses: Automattic/docs-agent/.github/workflows/maintain-docs.yml@${workflow.revision}`))
6569
assert.deepEqual(usedInputs, [...new Set(usedInputs)], `${workflow.path} must not declare an input twice`)
6670
assert.ok(usedInputs.every((input) => docsAgentInputs.includes(input) || input === "validation_dependencies"), `${workflow.path} uses an input absent from the Docs Agent schema`)
6771
assert.deepEqual(usedSecrets, ["OPENAI_API_KEY", "EXTERNAL_PACKAGE_SOURCE_POLICY"], `${workflow.path} must forward the Docs Agent secrets`)
@@ -89,8 +93,10 @@ for (const workflow of workflows) {
8993
assert.ok(dispatchInputs, "Developer Docs workflow must offer a manual run mode")
9094
assert.match(dispatchInputs, / run_kind:\n description: Documentation run mode\n required: false\n default: maintenance\n type: choice\n options:\n - maintenance\n - bootstrap/)
9195
assert.match(source, /run_kind: \$\{\{ github\.event\.inputs\.run_kind \|\| 'maintenance' \}\}/)
96+
assert.match(source, /require_pr: \$\{\{ github\.event_name == 'workflow_dispatch' \}\}/)
9297
} else {
9398
assert.doesNotMatch(source, /^ run_kind:/m)
99+
assert.doesNotMatch(source, /^ require_pr:/m)
94100
}
95101
}
96102

0 commit comments

Comments
 (0)