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
19 changes: 19 additions & 0 deletions pkg/parser/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,25 @@ func TestGetSafeOutputTypeKeys(t *testing.T) {
}
}

func TestMainWorkflowSchema_CreateDiscussionRequiredCategoryAllowed(t *testing.T) {
t.Parallel()

frontmatter := map[string]any{
"on": "daily",
"safe-outputs": map[string]any{
"create-discussion": map[string]any{
"category": "Ideas",
"close-older-discussions": true,
"required-category": "Ideas",
},
},
}

if err := validateWithSchema(frontmatter, mainWorkflowSchema, "main workflow file"); err != nil {
t.Fatalf("expected create-discussion.required-category to pass schema validation, got: %v", err)
}
}

func TestMainWorkflowSchemaPushToPullRequestBranchHasMaxPatchSize(t *testing.T) {
schemaPath := "schemas/main_workflow_schema.json"
schemaContent, err := os.ReadFile(schemaPath)
Expand Down
7 changes: 6 additions & 1 deletion pkg/parser/schemas/main_workflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5689,6 +5689,10 @@
"minLength": 1,
"pattern": "\\S"
},
"required-category": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] This bug fix lacks a regression test — the same copy-omission could silently re-appear.

💡 Suggested test

A targeted schema-validation test (similar to safe_outputs_error_location_test.go) would anchor the fix:

{
  name: "create-discussion with required-category is valid",
  yamlContent: `on: daily
safe-outputs:
  create-discussion:
    category: Ideas
    close-older-discussions: true
    required-category: Ideas`,
  expectValid: true,
  description: "required-category must be accepted in create-discussion branch",
},

Without it, the field could be silently dropped from the schema again (e.g., during a bulk property-list regeneration) and no test would catch it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a regression test in /home/runner/work/gh-aw/gh-aw/pkg/parser/schema_test.go (TestMainWorkflowSchema_CreateDiscussionRequiredCategoryAllowed) that validates safe-outputs.create-discussion.required-category passes strict schema validation with close-older-discussions: true.

"type": "string",
"description": "Required category for matching when close-older-discussions is enabled. Only discussions in this category will be considered when searching for older discussions to close."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/grill-with-docs] The examples array for create-discussion (further down in the file) does not include a required-category usage example, even though close-discussion already has one (required-category: "Ideas"). A short example alongside close-older-discussions: true would make the intended pairing obvious to users.

💡 Suggested addition to examples
{
  "title-prefix": "[weekly-report] ",
  "category": "Ideas",
  "close-older-discussions": true,
  "required-category": "Ideas"
}

This directly mirrors the motivating use-case from the PR description and helps schema-aware editors surface the field when close-older-discussions is set.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the requested example in /home/runner/work/gh-aw/gh-aw/pkg/parser/schemas/main_workflow_schema.json under create-discussion.examples to show required-category alongside close-older-discussions: true.

},
"fallback-to-issue": {
"type": "boolean",
"description": "When true (default), fallback to creating an issue if discussion creation fails due to permissions. The fallback issue will include a note indicating it was intended to be a discussion. If close-older-discussions is enabled, the close-older-issues logic will be applied to the fallback issue.",
Expand Down Expand Up @@ -5762,7 +5766,8 @@
{
"title-prefix": "[weekly-report] ",
"category": "reports",
"close-older-discussions": true
"close-older-discussions": true,
"required-category": "reports"
},
{
"labels": ["weekly-report", "automation"],
Expand Down
Loading