Skip to content

Commit d2bdb28

Browse files
committed
create toolsnaps
1 parent 6c1d24a commit d2bdb28

File tree

7 files changed

+355
-0
lines changed

7 files changed

+355
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"annotations": {
3+
"readOnlyHint": true,
4+
"title": "Get workflow run"
5+
},
6+
"description": "Get details of a specific workflow run",
7+
"inputSchema": {
8+
"type": "object",
9+
"required": [
10+
"owner",
11+
"repo",
12+
"run_id"
13+
],
14+
"properties": {
15+
"owner": {
16+
"type": "string",
17+
"description": "Repository owner"
18+
},
19+
"repo": {
20+
"type": "string",
21+
"description": "Repository name"
22+
},
23+
"run_id": {
24+
"type": "number",
25+
"description": "The unique identifier of the workflow run"
26+
}
27+
}
28+
},
29+
"name": "get_workflow_run"
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"annotations": {
3+
"readOnlyHint": true,
4+
"title": "Get workflow run logs"
5+
},
6+
"description": "Download logs for a specific workflow run (EXPENSIVE: downloads ALL logs as ZIP. Consider using get_job_logs with failed_only=true for debugging failed jobs)",
7+
"inputSchema": {
8+
"type": "object",
9+
"required": [
10+
"owner",
11+
"repo",
12+
"run_id"
13+
],
14+
"properties": {
15+
"owner": {
16+
"type": "string",
17+
"description": "Repository owner"
18+
},
19+
"repo": {
20+
"type": "string",
21+
"description": "Repository name"
22+
},
23+
"run_id": {
24+
"type": "number",
25+
"description": "The unique identifier of the workflow run"
26+
}
27+
}
28+
},
29+
"name": "get_workflow_run_logs"
30+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"annotations": {
3+
"readOnlyHint": true,
4+
"title": "List workflow jobs"
5+
},
6+
"description": "List jobs for a specific workflow run",
7+
"inputSchema": {
8+
"type": "object",
9+
"required": [
10+
"owner",
11+
"repo",
12+
"run_id"
13+
],
14+
"properties": {
15+
"filter": {
16+
"type": "string",
17+
"description": "Filters jobs by their completed_at timestamp",
18+
"enum": [
19+
"latest",
20+
"all"
21+
]
22+
},
23+
"owner": {
24+
"type": "string",
25+
"description": "Repository owner"
26+
},
27+
"page": {
28+
"type": "number",
29+
"description": "Page number for pagination (min 1)",
30+
"minimum": 1
31+
},
32+
"perPage": {
33+
"type": "number",
34+
"description": "Results per page for pagination (min 1, max 100)",
35+
"minimum": 1,
36+
"maximum": 100
37+
},
38+
"repo": {
39+
"type": "string",
40+
"description": "Repository name"
41+
},
42+
"run_id": {
43+
"type": "number",
44+
"description": "The unique identifier of the workflow run"
45+
}
46+
}
47+
},
48+
"name": "list_workflow_jobs"
49+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"annotations": {
3+
"readOnlyHint": true,
4+
"title": "List workflow runs"
5+
},
6+
"description": "List workflow runs for a specific workflow",
7+
"inputSchema": {
8+
"type": "object",
9+
"required": [
10+
"owner",
11+
"repo",
12+
"workflow_id"
13+
],
14+
"properties": {
15+
"actor": {
16+
"type": "string",
17+
"description": "Returns someone's workflow runs. Use the login for the user who created the workflow run."
18+
},
19+
"branch": {
20+
"type": "string",
21+
"description": "Returns workflow runs associated with a branch. Use the name of the branch."
22+
},
23+
"event": {
24+
"type": "string",
25+
"description": "Returns workflow runs for a specific event type",
26+
"enum": [
27+
"branch_protection_rule",
28+
"check_run",
29+
"check_suite",
30+
"create",
31+
"delete",
32+
"deployment",
33+
"deployment_status",
34+
"discussion",
35+
"discussion_comment",
36+
"fork",
37+
"gollum",
38+
"issue_comment",
39+
"issues",
40+
"label",
41+
"merge_group",
42+
"milestone",
43+
"page_build",
44+
"public",
45+
"pull_request",
46+
"pull_request_review",
47+
"pull_request_review_comment",
48+
"pull_request_target",
49+
"push",
50+
"registry_package",
51+
"release",
52+
"repository_dispatch",
53+
"schedule",
54+
"status",
55+
"watch",
56+
"workflow_call",
57+
"workflow_dispatch",
58+
"workflow_run"
59+
]
60+
},
61+
"owner": {
62+
"type": "string",
63+
"description": "Repository owner"
64+
},
65+
"page": {
66+
"type": "number",
67+
"description": "Page number for pagination (min 1)",
68+
"minimum": 1
69+
},
70+
"perPage": {
71+
"type": "number",
72+
"description": "Results per page for pagination (min 1, max 100)",
73+
"minimum": 1,
74+
"maximum": 100
75+
},
76+
"repo": {
77+
"type": "string",
78+
"description": "Repository name"
79+
},
80+
"status": {
81+
"type": "string",
82+
"description": "Returns workflow runs with the check run status",
83+
"enum": [
84+
"queued",
85+
"in_progress",
86+
"completed",
87+
"requested",
88+
"waiting"
89+
]
90+
},
91+
"workflow_id": {
92+
"type": "string",
93+
"description": "The workflow ID or workflow file name"
94+
}
95+
}
96+
},
97+
"name": "list_workflow_runs"
98+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"annotations": {
3+
"title": "Rerun failed jobs"
4+
},
5+
"description": "Re-run only the failed jobs in a workflow run",
6+
"inputSchema": {
7+
"type": "object",
8+
"required": [
9+
"owner",
10+
"repo",
11+
"run_id"
12+
],
13+
"properties": {
14+
"owner": {
15+
"type": "string",
16+
"description": "Repository owner"
17+
},
18+
"repo": {
19+
"type": "string",
20+
"description": "Repository name"
21+
},
22+
"run_id": {
23+
"type": "number",
24+
"description": "The unique identifier of the workflow run"
25+
}
26+
}
27+
},
28+
"name": "rerun_failed_jobs"
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"annotations": {
3+
"title": "Rerun workflow run"
4+
},
5+
"description": "Re-run an entire workflow run",
6+
"inputSchema": {
7+
"type": "object",
8+
"required": [
9+
"owner",
10+
"repo",
11+
"run_id"
12+
],
13+
"properties": {
14+
"owner": {
15+
"type": "string",
16+
"description": "Repository owner"
17+
},
18+
"repo": {
19+
"type": "string",
20+
"description": "Repository name"
21+
},
22+
"run_id": {
23+
"type": "number",
24+
"description": "The unique identifier of the workflow run"
25+
}
26+
}
27+
},
28+
"name": "rerun_workflow_run"
29+
}

pkg/github/actions_test.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,3 +1350,93 @@ func Test_MemoryUsage_SlidingWindow_vs_NoWindow(t *testing.T) {
13501350
t.Logf("Sliding window: %s", profile1.String())
13511351
t.Logf("No window: %s", profile2.String())
13521352
}
1353+
1354+
func Test_ListWorkflowRuns(t *testing.T) {
1355+
// Verify tool definition once
1356+
mockClient := github.NewClient(nil)
1357+
tool, _ := ListWorkflowRuns(stubGetClientFn(mockClient), translations.NullTranslationHelper)
1358+
require.NoError(t, toolsnaps.Test(tool.Name, tool))
1359+
1360+
assert.Equal(t, "list_workflow_runs", tool.Name)
1361+
assert.NotEmpty(t, tool.Description)
1362+
inputSchema := tool.InputSchema.(*jsonschema.Schema)
1363+
assert.Contains(t, inputSchema.Properties, "owner")
1364+
assert.Contains(t, inputSchema.Properties, "repo")
1365+
assert.Contains(t, inputSchema.Properties, "workflow_id")
1366+
assert.ElementsMatch(t, inputSchema.Required, []string{"owner", "repo", "workflow_id"})
1367+
}
1368+
1369+
func Test_GetWorkflowRun(t *testing.T) {
1370+
// Verify tool definition once
1371+
mockClient := github.NewClient(nil)
1372+
tool, _ := GetWorkflowRun(stubGetClientFn(mockClient), translations.NullTranslationHelper)
1373+
require.NoError(t, toolsnaps.Test(tool.Name, tool))
1374+
1375+
assert.Equal(t, "get_workflow_run", tool.Name)
1376+
assert.NotEmpty(t, tool.Description)
1377+
inputSchema := tool.InputSchema.(*jsonschema.Schema)
1378+
assert.Contains(t, inputSchema.Properties, "owner")
1379+
assert.Contains(t, inputSchema.Properties, "repo")
1380+
assert.Contains(t, inputSchema.Properties, "run_id")
1381+
assert.ElementsMatch(t, inputSchema.Required, []string{"owner", "repo", "run_id"})
1382+
}
1383+
1384+
func Test_GetWorkflowRunLogs(t *testing.T) {
1385+
// Verify tool definition once
1386+
mockClient := github.NewClient(nil)
1387+
tool, _ := GetWorkflowRunLogs(stubGetClientFn(mockClient), translations.NullTranslationHelper)
1388+
require.NoError(t, toolsnaps.Test(tool.Name, tool))
1389+
1390+
assert.Equal(t, "get_workflow_run_logs", tool.Name)
1391+
assert.NotEmpty(t, tool.Description)
1392+
inputSchema := tool.InputSchema.(*jsonschema.Schema)
1393+
assert.Contains(t, inputSchema.Properties, "owner")
1394+
assert.Contains(t, inputSchema.Properties, "repo")
1395+
assert.Contains(t, inputSchema.Properties, "run_id")
1396+
assert.ElementsMatch(t, inputSchema.Required, []string{"owner", "repo", "run_id"})
1397+
}
1398+
1399+
func Test_ListWorkflowJobs(t *testing.T) {
1400+
// Verify tool definition once
1401+
mockClient := github.NewClient(nil)
1402+
tool, _ := ListWorkflowJobs(stubGetClientFn(mockClient), translations.NullTranslationHelper)
1403+
require.NoError(t, toolsnaps.Test(tool.Name, tool))
1404+
1405+
assert.Equal(t, "list_workflow_jobs", tool.Name)
1406+
assert.NotEmpty(t, tool.Description)
1407+
inputSchema := tool.InputSchema.(*jsonschema.Schema)
1408+
assert.Contains(t, inputSchema.Properties, "owner")
1409+
assert.Contains(t, inputSchema.Properties, "repo")
1410+
assert.Contains(t, inputSchema.Properties, "run_id")
1411+
assert.ElementsMatch(t, inputSchema.Required, []string{"owner", "repo", "run_id"})
1412+
}
1413+
1414+
func Test_RerunWorkflowRun(t *testing.T) {
1415+
// Verify tool definition once
1416+
mockClient := github.NewClient(nil)
1417+
tool, _ := RerunWorkflowRun(stubGetClientFn(mockClient), translations.NullTranslationHelper)
1418+
require.NoError(t, toolsnaps.Test(tool.Name, tool))
1419+
1420+
assert.Equal(t, "rerun_workflow_run", tool.Name)
1421+
assert.NotEmpty(t, tool.Description)
1422+
inputSchema := tool.InputSchema.(*jsonschema.Schema)
1423+
assert.Contains(t, inputSchema.Properties, "owner")
1424+
assert.Contains(t, inputSchema.Properties, "repo")
1425+
assert.Contains(t, inputSchema.Properties, "run_id")
1426+
assert.ElementsMatch(t, inputSchema.Required, []string{"owner", "repo", "run_id"})
1427+
}
1428+
1429+
func Test_RerunFailedJobs(t *testing.T) {
1430+
// Verify tool definition once
1431+
mockClient := github.NewClient(nil)
1432+
tool, _ := RerunFailedJobs(stubGetClientFn(mockClient), translations.NullTranslationHelper)
1433+
require.NoError(t, toolsnaps.Test(tool.Name, tool))
1434+
1435+
assert.Equal(t, "rerun_failed_jobs", tool.Name)
1436+
assert.NotEmpty(t, tool.Description)
1437+
inputSchema := tool.InputSchema.(*jsonschema.Schema)
1438+
assert.Contains(t, inputSchema.Properties, "owner")
1439+
assert.Contains(t, inputSchema.Properties, "repo")
1440+
assert.Contains(t, inputSchema.Properties, "run_id")
1441+
assert.ElementsMatch(t, inputSchema.Required, []string{"owner", "repo", "run_id"})
1442+
}

0 commit comments

Comments
 (0)