-
Notifications
You must be signed in to change notification settings - Fork 367
[copilot] add comment to parent issue when creating a new issue #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
111a767
Initial plan
Copilot b3b9186
Implement subissue functionality in create_issue.js script
Copilot 108a42a
Use GraphQL to create proper sub-issue relationships instead of text …
Copilot 2a84325
Revert "Use GraphQL to create proper sub-issue relationships instead …
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| package workflow | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| // TestCreateIssueSubissueFeature tests that the create_issue.js script includes subissue functionality | ||
| func TestCreateIssueSubissueFeature(t *testing.T) { | ||
| // Test that the script contains the subissue detection logic | ||
| if !strings.Contains(createIssueScript, "context.payload?.issue?.number") { | ||
| t.Error("Expected create_issue.js to check for parent issue context") | ||
| } | ||
|
|
||
| // Test that the script modifies the body when in issue context | ||
| if !strings.Contains(createIssueScript, "Related to #${parentIssueNumber}") { | ||
| t.Error("Expected create_issue.js to add parent issue reference to body") | ||
| } | ||
|
|
||
| // Test that the script creates a comment on the parent issue | ||
| if !strings.Contains(createIssueScript, "github.rest.issues.createComment") { | ||
| t.Error("Expected create_issue.js to create comment on parent issue") | ||
| } | ||
|
|
||
| // Test that the script has proper error handling for comment creation | ||
| if !strings.Contains(createIssueScript, "Warning: Could not add comment to parent issue") { | ||
| t.Error("Expected create_issue.js to have error handling for parent issue comment") | ||
| } | ||
|
|
||
| // Test console logging for debugging | ||
| if !strings.Contains(createIssueScript, "Detected issue context, parent issue") { | ||
| t.Error("Expected create_issue.js to log when issue context is detected") | ||
| } | ||
| } | ||
|
|
||
| // TestCreateIssueWorkflowCompilation tests that workflows with output.issue still compile correctly | ||
| func TestCreateIssueWorkflowCompilationWithSubissue(t *testing.T) { | ||
| // Create temporary directory for test files | ||
| tmpDir, err := os.MkdirTemp("", "subissue-test") | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| defer os.RemoveAll(tmpDir) | ||
|
|
||
| testContent := `--- | ||
| name: Test Subissue Feature | ||
| on: | ||
| issues: | ||
| types: [opened] | ||
| permissions: | ||
| contents: read | ||
| engine: claude | ||
| output: | ||
| issue: | ||
| title-prefix: "[test] " | ||
| labels: [automation, test] | ||
| --- | ||
|
|
||
| # Test Workflow | ||
|
|
||
| This is a test workflow that should create an issue with subissue functionality. | ||
| Write output to ${{ env.GITHUB_AW_OUTPUT }}.` | ||
|
|
||
| testFile := filepath.Join(tmpDir, "test-subissue.md") | ||
| if err := os.WriteFile(testFile, []byte(testContent), 0644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| compiler := NewCompiler(false, "", "test") | ||
| err = compiler.CompileWorkflow(testFile) | ||
| if err != nil { | ||
| t.Fatalf("Failed to compile workflow with output.issue: %v", err) | ||
| } | ||
|
|
||
| // Read the generated lock file to verify content | ||
| lockFile := filepath.Join(tmpDir, "test-subissue.lock.yml") | ||
| lockContentBytes, err := os.ReadFile(lockFile) | ||
| if err != nil { | ||
| t.Fatalf("Failed to read lock file: %v", err) | ||
| } | ||
| lockContent := string(lockContentBytes) | ||
|
|
||
| // Verify the compiled workflow includes the subissue functionality | ||
| if !strings.Contains(lockContent, "context.payload?.issue?.number") { | ||
| t.Error("Expected compiled workflow to include subissue detection") | ||
| } | ||
|
|
||
| if !strings.Contains(lockContent, "Created related issue: #${issue.number}") { | ||
| t.Error("Expected compiled workflow to include parent issue comment") | ||
| } | ||
|
|
||
| // Verify it still has the standard create_output_issue job structure | ||
| if !strings.Contains(lockContent, "create_output_issue:") { | ||
| t.Error("Expected create_output_issue job to be present") | ||
| } | ||
|
|
||
| if !strings.Contains(lockContent, "permissions:\n contents: read\n issues: write") { | ||
| t.Error("Expected correct permissions in create_output_issue job") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.