Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/changeset.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions .github/workflows/smoke-claude.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion actions/setup/js/safe_output_type_validator.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ function executeCustomValidation(item, customValidation, lineNum, itemType) {
// Parse custom validation rule
if (customValidation.startsWith("requiresOneOf:")) {
const fields = customValidation.slice("requiresOneOf:".length).split(",");
const hasValidField = fields.some(field => item[field] !== undefined);
const hasValidField = fields.some(field => item[field] !== undefined && item[field] !== false);
if (!hasValidField) {
return {
isValid: false,
Expand Down
27 changes: 27 additions & 0 deletions actions/setup/js/safe_output_type_validator.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ const SAMPLE_VALIDATION_CONFIG = {
issue_number: { issueOrPRNumber: true },
},
},
update_pull_request: {
defaultMax: 1,
customValidation: "requiresOneOf:title,body,update_branch",
fields: {
title: { type: "string", sanitize: true, maxLength: 256 },
body: { type: "string", sanitize: true, maxLength: 65000 },
update_branch: { type: "boolean" },
pull_request_number: { issueOrPRNumber: true },
},
},
assign_to_agent: {
defaultMax: 1,
customValidation: "requiresOneOf:issue_number,pull_number",
Expand Down Expand Up @@ -399,6 +409,23 @@ describe("safe_output_type_validator", () => {
expect(result.error).toContain("issue_number");
expect(result.error).toContain("pull_number");
});

it("should fail for update_pull_request when update_branch is false and no title/body is provided", async () => {
const { validateItem } = await import("./safe_output_type_validator.cjs");

const result = validateItem({ type: "update_pull_request", update_branch: false }, "update_pull_request", 1);

expect(result.isValid).toBe(false);
expect(result.error).toContain("requires at least one of");
});

it("should pass for update_pull_request when update_branch is true", async () => {
const { validateItem } = await import("./safe_output_type_validator.cjs");

const result = validateItem({ type: "update_pull_request", update_branch: true }, "update_pull_request", 1);

expect(result.isValid).toBe(true);
});
});

describe("custom validation: startLineLessOrEqualLine", () => {
Expand Down
4 changes: 4 additions & 0 deletions actions/setup/js/safe_outputs_tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,10 @@
"enum": ["replace", "append", "prepend"],
"description": "How to update the PR body: 'replace' (default - completely overwrite), 'append' (add to end with separator), or 'prepend' (add to start with separator). Title is always replaced."
},
"update_branch": {
"type": "boolean",
"description": "When true, update the pull request branch with the latest base branch changes before applying other updates. Defaults to false."
},
"pull_request_number": {
"type": ["number", "string"],
"description": "Pull request number to update. This is the numeric ID from the GitHub URL (e.g., 234 in github.com/owner/repo/pull/234). Required when the workflow target is '*' (any PR)."
Expand Down
2 changes: 2 additions & 0 deletions actions/setup/js/types/safe-outputs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ interface UpdatePullRequestItem extends BaseSafeOutputItem {
body?: string;
/** Update operation for body: 'replace' (default), 'append', or 'prepend' */
operation?: "replace" | "append" | "prepend";
/** When true, updates the pull request branch with the latest base branch changes before other updates */
update_branch?: boolean;
/** Optional pull request number for target "*" */
pull_request_number?: number | string;
/** Whether the PR should be a draft (true) or ready for review (false) */
Expand Down
Loading
Loading