Skip to content

Commit 53f43bc

Browse files
authored
Forward publication base to WP Codebox (#159)
1 parent 5302ef4 commit 53f43bc

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/maintain-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ jobs:
233233
--arg repo "$GITHUB_REPOSITORY_NAME" \
234234
--arg branch "$INPUT_DOCS_BRANCH" \
235235
--arg baseRef "$INPUT_BASE_REF" \
236-
'{enabled:true,repo:$repo,clone_url:("https://github.com/" + $repo + ".git"),branch:$branch,branch_prefix:$branch,from:("origin/" + $baseRef)}')"
236+
'{enabled:true,repo:$repo,clone_url:("https://github.com/" + $repo + ".git"),branch:$branch,branch_prefix:$branch,base:$baseRef,from:("origin/" + $baseRef)}')"
237237
expected_artifacts="$(printf '%s' "$artifact_declarations" | jq -c 'map(.name)')"
238238
output_projections="$(jq -cn --arg path 'metadata.runner_workspace_publication.url' --argjson required "$success_requires_pr" '{docs_agent_publication:{path:$path,required:$required}}')"
239239

tests/validate-wp-codebox-run-agent-task-contract.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,18 @@
357357
$assert( array( 'job' => 'prepare', 'output' => 'success_requires_pr' ) === ( $caller_outputs['success_requires_pr'] ?? null ), 'Docs Agent must expose the selected publication policy to consumers.' );
358358
$assert( str_contains( $workflow, 'successRequiresPr:$successRequiresPr' ), 'Docs Agent recipe must retain the selected publication policy.' );
359359
$assert( str_contains( $workflow, '--arg validationDependencies "$INPUT_VALIDATION_DEPENDENCIES"' ), 'Docs Agent recipe must retain caller-owned validation dependencies.' );
360+
$assert( str_contains( $workflow, '{enabled:true,repo:$repo,clone_url:("https://github.com/" + $repo + ".git"),branch:$branch,branch_prefix:$branch,base:$baseRef,from:("origin/" + $baseRef)}' ), 'Docs Agent runner workspace publication must forward base_ref as base and preserve origin-qualified from.' );
361+
$runner_workspace_json = shell_exec( "jq -cn --arg repo 'Automattic/example' --arg branch 'docs-agent/docs-upkeep' --arg baseRef 'trunk' '{enabled:true,repo:\$repo,clone_url:(\"https://github.com/\" + \$repo + \".git\"),branch:\$branch,branch_prefix:\$branch,base:\$baseRef,from:(\"origin/\" + \$baseRef)}'" );
362+
$runner_workspace = json_decode( (string) $runner_workspace_json, true );
363+
$assert( array(
364+
'enabled' => true,
365+
'repo' => 'Automattic/example',
366+
'clone_url' => 'https://github.com/Automattic/example.git',
367+
'branch' => 'docs-agent/docs-upkeep',
368+
'branch_prefix' => 'docs-agent/docs-upkeep',
369+
'base' => 'trunk',
370+
'from' => 'origin/trunk',
371+
) === $runner_workspace, 'Docs Agent must emit trunk as publication base and origin/trunk as runner workspace from.' );
360372

361373
preg_match( "/artifact_declarations='(?<json>\[.*?\])'\n/s", $workflow, $artifact_declarations_match );
362374
$assert( isset( $artifact_declarations_match['json'] ), 'Docs Agent must define typed artifact declarations.' );

0 commit comments

Comments
 (0)