Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support assigning copilot to issues#418

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall 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
115 changes: 110 additions & 5 deletionse2e/e2e_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"os"
"os/exec"
"slices"
Expand DownExpand Up@@ -210,7 +211,6 @@ func TestGetMe(t *testing.T) {
t.Parallel()

mcpClient := setupMCPClient(t)

ctx := context.Background()

// When we call the "get_me" tool
Expand DownExpand Up@@ -795,14 +795,13 @@ func TestDirectoryDeletion(t *testing.T) {
}

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

if getE2EHost() != "" && getE2EHost() != "https://github.com" {
t.Skip("Skipping test because the host does not support copilot reviews")
}

t.Parallel()

mcpClient := setupMCPClient(t)

ctx := context.Background()

// First, who am I
Expand DownExpand Up@@ -943,6 +942,112 @@ func TestRequestCopilotReview(t *testing.T) {
require.Equal(t, "Bot", *reviewRequests.Users[0].Type, "expected review request to be for Bot")
}

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

if getE2EHost() != "" && getE2EHost() != "https://github.com" {
t.Skip("Skipping test because the host does not support copilot being assigned to issues")
}

mcpClient := setupMCPClient(t)
ctx := context.Background()

// First, who am I
getMeRequest := mcp.CallToolRequest{}
getMeRequest.Params.Name = "get_me"

t.Log("Getting current user...")
resp, err := mcpClient.CallTool(ctx, getMeRequest)
require.NoError(t, err, "expected to call 'get_me' tool successfully")
require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp))

require.False(t, resp.IsError, "expected result not to be an error")
require.Len(t, resp.Content, 1, "expected content to have one item")

textContent, ok := resp.Content[0].(mcp.TextContent)
require.True(t, ok, "expected content to be of type TextContent")

var trimmedGetMeText struct {
Login string `json:"login"`
}
err = json.Unmarshal([]byte(textContent.Text), &trimmedGetMeText)
require.NoError(t, err, "expected to unmarshal text content successfully")

currentOwner := trimmedGetMeText.Login

// Then create a repository with a README (via autoInit)
repoName := fmt.Sprintf("github-mcp-server-e2e-%s-%d", t.Name(), time.Now().UnixMilli())
createRepoRequest := mcp.CallToolRequest{}
createRepoRequest.Params.Name = "create_repository"
createRepoRequest.Params.Arguments = map[string]any{
"name": repoName,
"private": true,
"autoInit": true,
}

t.Logf("Creating repository %s/%s...", currentOwner, repoName)
_, err = mcpClient.CallTool(ctx, createRepoRequest)
require.NoError(t, err, "expected to call 'create_repository' tool successfully")
require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp))

// Cleanup the repository after the test
t.Cleanup(func() {
// MCP Server doesn't support deletions, but we can use the GitHub Client
ghClient := getRESTClient(t)
t.Logf("Deleting repository %s/%s...", currentOwner, repoName)
_, err := ghClient.Repositories.Delete(context.Background(), currentOwner, repoName)
require.NoError(t, err, "expected to delete repository successfully")
})

// Create an issue
createIssueRequest := mcp.CallToolRequest{}
createIssueRequest.Params.Name = "create_issue"
createIssueRequest.Params.Arguments = map[string]any{
"owner": currentOwner,
"repo": repoName,
"title": "Test issue to assign copilot to",
}

t.Logf("Creating issue in %s/%s...", currentOwner, repoName)
resp, err = mcpClient.CallTool(ctx, createIssueRequest)
require.NoError(t, err, "expected to call 'create_issue' tool successfully")
require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp))

// Assign copilot to the issue
assignCopilotRequest := mcp.CallToolRequest{}
assignCopilotRequest.Params.Name = "assign_copilot_to_issue"
assignCopilotRequest.Params.Arguments = map[string]any{
"owner": currentOwner,
"repo": repoName,
"issueNumber": 1,
}

t.Logf("Assigning copilot to issue in %s/%s...", currentOwner, repoName)
resp, err = mcpClient.CallTool(ctx, assignCopilotRequest)
require.NoError(t, err, "expected to call 'assign_copilot_to_issue' tool successfully")

textContent, ok = resp.Content[0].(mcp.TextContent)
require.True(t, ok, "expected content to be of type TextContent")

possibleExpectedFailure := "copilot isn't available as an assignee for this issue. Please inform the user to visit https://docs.github.com/en/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-tasks/about-assigning-tasks-to-copilot for more information."
if resp.IsError && textContent.Text == possibleExpectedFailure {
t.Skip("skipping because copilot wasn't available as an assignee on this issue, it's likely that the owner doesn't have copilot enabled in their settings")
}

require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp))

require.Equal(t, "successfully assigned copilot to issue", textContent.Text)

// Check that copilot is assigned to the issue
// MCP Server doesn't support getting assignees yet
ghClient := getRESTClient(t)
assignees, response, err := ghClient.Issues.Get(context.Background(), currentOwner, repoName, 1)
require.NoError(t, err, "expected to get issue successfully")
require.Equal(t, http.StatusOK, response.StatusCode, "expected to get issue successfully")
require.Len(t, assignees.Assignees, 1, "expected to find one assignee")
require.Equal(t, "Copilot", *assignees.Assignees[0].Login, "expected copilot to be assigned to the issue")
}

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

Expand DownExpand Up@@ -1145,7 +1250,7 @@ func TestPullRequestReviewCommentSubmit(t *testing.T) {

t.Logf("Creating repository %s/%s...", currentOwner, repoName)
_, err = mcpClient.CallTool(ctx, createRepoRequest)
require.NoError(t, err, "expected to call 'get_me' tool successfully")
require.NoError(t, err, "expected to call 'create_repository' tool successfully")
require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp))

// Cleanup the repository after the test
Expand Down
21 changes: 19 additions & 2 deletionsinternal/githubv4mock/objects_are_equal_values.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
// The contents of this file are taken from https://github.com/stretchr/testify/blob/016e2e9c269209287f33ec203f340a9a723fe22c/assert/assertions.go#L166
// because I do not want to take a dependency on the entire testify module just to use this equality check.
//
// There is a modification in objectsAreEqual to check that typed nils are equal, even if their types are different.
//
// The original license, copied from https://github.com/stretchr/testify/blob/016e2e9c269209287f33ec203f340a9a723fe22c/LICENSE
//
// MIT License
Expand DownExpand Up@@ -69,8 +71,10 @@ func objectsAreEqualValues(expected, actual any) bool {
//
// This function does no assertion of any kind.
func objectsAreEqual(expected, actual any) bool {
if expected == nil || actual == nil {
return expected == actual
// There is a modification in objectsAreEqual to check that typed nils are equal, even if their types are different.
// This is required because when a nil is provided as a variable, the type is not known.
if isNil(expected) && isNil(actual) {
return true
}

exp, ok := expected.([]byte)
Expand All@@ -94,3 +98,16 @@ func objectsAreEqual(expected, actual any) bool {
func isNumericType(t reflect.Type) bool {
return t.Kind() >= reflect.Int && t.Kind() <= reflect.Complex128
}

func isNil(i any) bool {
if i == nil {
return true
}
v := reflect.ValueOf(i)
switch v.Kind() {
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Slice:
return v.IsNil()
default:
return false
}
}
4 changes: 4 additions & 0 deletionsinternal/githubv4mock/objects_are_equal_values_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
// The contents of this file are taken from https://github.com/stretchr/testify/blob/016e2e9c269209287f33ec203f340a9a723fe22c/assert/assertions_test.go#L140-L174
//
// There is a modification to test objectsAreEqualValues to check that typed nils are equal, even if their types are different.

// The original license, copied from https://github.com/stretchr/testify/blob/016e2e9c269209287f33ec203f340a9a723fe22c/LICENSE
//
// MIT License
Expand DownExpand Up@@ -55,6 +57,8 @@ func TestObjectsAreEqualValues(t *testing.T) {
{3.14, complex128(1e+100 + 1e+100i), false},
{complex128(1e+10 + 1e+10i), complex64(1e+10 + 1e+10i), true},
{complex64(1e+10 + 1e+10i), complex128(1e+10 + 1e+10i), true},
{(*string)(nil), nil, true}, // typed nil vs untyped nil
{(*string)(nil), (*int)(nil), true}, // different typed nils
}

for _, c := range cases {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp