Skip to content

Commit 6ecdc21

Browse files
committed
fix test
1 parent 2603e5a commit 6ecdc21

4 files changed

Lines changed: 144 additions & 34 deletions

File tree

pkg/cli/commands.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3490,9 +3490,12 @@ permissions:
34903490
issues: write
34913491
pull-requests: write
34923492
3493-
# Tools - what APIs and tools can the AI use?
3494-
output:
3493+
# Outputs - what APIs and tools can the AI use?
3494+
safe-outputs:
34953495
create-issue:
3496+
# create-pull-request:
3497+
# add-issue-comment:
3498+
# add-issue-labels:
34963499
34973500
---
34983501

pkg/parser/schemas/main_workflow_schema.json

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -984,22 +984,30 @@
984984
}
985985
},
986986
"create-issue": {
987-
"type": "object",
988-
"description": "Configuration for creating GitHub issues from agentic workflow output",
989-
"properties": {
990-
"title-prefix": {
991-
"type": "string",
992-
"description": "Optional prefix for the issue title"
987+
"oneOf": [
988+
{
989+
"type": "object",
990+
"description": "Configuration for creating GitHub issues from agentic workflow output",
991+
"properties": {
992+
"title-prefix": {
993+
"type": "string",
994+
"description": "Optional prefix for the issue title"
995+
},
996+
"labels": {
997+
"type": "array",
998+
"description": "Optional list of labels to attach to the issue",
999+
"items": {
1000+
"type": "string"
1001+
}
1002+
}
1003+
},
1004+
"additionalProperties": false
9931005
},
994-
"labels": {
995-
"type": "array",
996-
"description": "Optional list of labels to attach to the issue",
997-
"items": {
998-
"type": "string"
999-
}
1006+
{
1007+
"type": "null",
1008+
"description": "Enable issue creation with default configuration"
10001009
}
1001-
},
1002-
"additionalProperties": false
1010+
]
10031011
},
10041012
"add-issue-comment": {
10051013
"oneOf": [
@@ -1015,26 +1023,34 @@
10151023
]
10161024
},
10171025
"create-pull-request": {
1018-
"type": "object",
1019-
"description": "Configuration for creating GitHub pull requests from agentic workflow output",
1020-
"properties": {
1021-
"title-prefix": {
1022-
"type": "string",
1023-
"description": "Optional prefix for the pull request title"
1024-
},
1025-
"labels": {
1026-
"type": "array",
1027-
"description": "Optional list of labels to attach to the pull request",
1028-
"items": {
1029-
"type": "string"
1030-
}
1026+
"oneOf": [
1027+
{
1028+
"type": "object",
1029+
"description": "Configuration for creating GitHub pull requests from agentic workflow output",
1030+
"properties": {
1031+
"title-prefix": {
1032+
"type": "string",
1033+
"description": "Optional prefix for the pull request title"
1034+
},
1035+
"labels": {
1036+
"type": "array",
1037+
"description": "Optional list of labels to attach to the pull request",
1038+
"items": {
1039+
"type": "string"
1040+
}
1041+
},
1042+
"draft": {
1043+
"type": "boolean",
1044+
"description": "Whether to create pull request as draft (defaults to true)"
1045+
}
1046+
},
1047+
"additionalProperties": false
10311048
},
1032-
"draft": {
1033-
"type": "boolean",
1034-
"description": "Whether to create pull request as draft (defaults to true)"
1049+
{
1050+
"type": "null",
1051+
"description": "Enable pull request creation with default configuration"
10351052
}
1036-
},
1037-
"additionalProperties": false
1053+
]
10381054
},
10391055
"add-issue-labels": {
10401056
"oneOf": [

pkg/workflow/compiler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,6 +2311,9 @@ func (c *Compiler) extractSafeOutputsConfig(frontmatter map[string]any) *SafeOut
23112311
}
23122312

23132313
config.CreateIssue = issueConfig
2314+
} else if issue == nil {
2315+
// Handle null case: create empty config
2316+
config.CreateIssue = &CreateIssueConfig{}
23142317
}
23152318
}
23162319

@@ -2358,6 +2361,9 @@ func (c *Compiler) extractSafeOutputsConfig(frontmatter map[string]any) *SafeOut
23582361
}
23592362

23602363
config.CreatePullRequest = pullRequestConfig
2364+
} else if pullRequest == nil {
2365+
// Handle null case: create empty config
2366+
config.CreatePullRequest = &CreatePullRequestConfig{}
23612367
}
23622368
}
23632369

pkg/workflow/output_test.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,91 @@ This workflow has no output configuration.
115115
}
116116
}
117117

118+
func TestOutputConfigNull(t *testing.T) {
119+
// Create temporary directory for test files
120+
tmpDir, err := os.MkdirTemp("", "output-config-null-test")
121+
if err != nil {
122+
t.Fatal(err)
123+
}
124+
defer os.RemoveAll(tmpDir)
125+
126+
// Test case with null values for create-issue and create-pull-request
127+
testContent := `---
128+
on: push
129+
permissions:
130+
contents: read
131+
issues: write
132+
pull-requests: write
133+
engine: claude
134+
safe-outputs:
135+
create-issue:
136+
create-pull-request:
137+
add-issue-comment:
138+
add-issue-labels:
139+
---
140+
141+
# Test Null Output Configuration
142+
143+
This workflow tests the null output configuration parsing.
144+
`
145+
146+
testFile := filepath.Join(tmpDir, "test-null-output-config.md")
147+
if err := os.WriteFile(testFile, []byte(testContent), 0644); err != nil {
148+
t.Fatal(err)
149+
}
150+
151+
compiler := NewCompiler(false, "", "test")
152+
153+
// Parse the workflow data
154+
workflowData, err := compiler.parseWorkflowFile(testFile)
155+
if err != nil {
156+
t.Fatalf("Unexpected error parsing workflow with null output config: %v", err)
157+
}
158+
159+
// Verify output configuration is parsed correctly
160+
if workflowData.SafeOutputs == nil {
161+
t.Fatal("Expected output configuration to be parsed")
162+
}
163+
164+
// Verify create-issue configuration is parsed with empty values
165+
if workflowData.SafeOutputs.CreateIssue == nil {
166+
t.Fatal("Expected create-issue configuration to be parsed with null value")
167+
}
168+
if workflowData.SafeOutputs.CreateIssue.TitlePrefix != "" {
169+
t.Errorf("Expected empty title prefix for null create-issue, got '%s'", workflowData.SafeOutputs.CreateIssue.TitlePrefix)
170+
}
171+
if len(workflowData.SafeOutputs.CreateIssue.Labels) != 0 {
172+
t.Errorf("Expected empty labels for null create-issue, got %v", workflowData.SafeOutputs.CreateIssue.Labels)
173+
}
174+
175+
// Verify create-pull-request configuration is parsed with empty values
176+
if workflowData.SafeOutputs.CreatePullRequest == nil {
177+
t.Fatal("Expected create-pull-request configuration to be parsed with null value")
178+
}
179+
if workflowData.SafeOutputs.CreatePullRequest.TitlePrefix != "" {
180+
t.Errorf("Expected empty title prefix for null create-pull-request, got '%s'", workflowData.SafeOutputs.CreatePullRequest.TitlePrefix)
181+
}
182+
if len(workflowData.SafeOutputs.CreatePullRequest.Labels) != 0 {
183+
t.Errorf("Expected empty labels for null create-pull-request, got %v", workflowData.SafeOutputs.CreatePullRequest.Labels)
184+
}
185+
186+
// Verify add-issue-comment configuration is parsed with empty values
187+
if workflowData.SafeOutputs.AddIssueComment == nil {
188+
t.Fatal("Expected add-issue-comment configuration to be parsed with null value")
189+
}
190+
191+
// Verify add-issue-labels configuration is parsed with empty values
192+
if workflowData.SafeOutputs.AddIssueLabels == nil {
193+
t.Fatal("Expected add-issue-labels configuration to be parsed with null value")
194+
}
195+
if len(workflowData.SafeOutputs.AddIssueLabels.Allowed) != 0 {
196+
t.Errorf("Expected empty allowed labels for null add-issue-labels, got %v", workflowData.SafeOutputs.AddIssueLabels.Allowed)
197+
}
198+
if workflowData.SafeOutputs.AddIssueLabels.MaxCount != nil {
199+
t.Errorf("Expected nil MaxCount for null add-issue-labels, got %v", *workflowData.SafeOutputs.AddIssueLabels.MaxCount)
200+
}
201+
}
202+
118203
func TestOutputIssueJobGeneration(t *testing.T) {
119204
// Create temporary directory for test files
120205
tmpDir, err := os.MkdirTemp("", "output-issue-job-test")

0 commit comments

Comments
 (0)