Skip to content
Open
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
13 changes: 11 additions & 2 deletions pkg/github/__toolsnaps__/actions_list.snap
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,22 @@
"type": "string"
},
"status": {
"description": "Filter workflow runs to only runs with a specific status",
"description": "Filter workflow runs to only runs with a specific status or conclusion (e.g. in_progress or failure)",
"enum": [
"queued",
"in_progress",
"completed",
"requested",
"waiting"
"waiting",
"pending",
"action_required",
"cancelled",
"failure",
"neutral",
"skipped",
"stale",
"success",
"timed_out"
],
"type": "string"
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/github/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,11 @@ Use this tool to list workflows in a repository, or list workflow runs, jobs, an
},
"status": {
Type: "string",
Description: "Filter workflow runs to only runs with a specific status",
Enum: []any{"queued", "in_progress", "completed", "requested", "waiting"},
Description: "Filter workflow runs to only runs with a specific status or conclusion (e.g. in_progress or failure)",
Enum: []any{
"queued", "in_progress", "completed", "requested", "waiting", "pending",
"action_required", "cancelled", "failure", "neutral", "skipped", "stale", "success", "timed_out",
},
},
},
},
Expand Down
55 changes: 55 additions & 0 deletions pkg/github/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,61 @@ func Test_ActionsList_ListWorkflowRuns(t *testing.T) {
assert.Equal(t, 2, response.TotalCount)
assert.Len(t, response.WorkflowRuns, 2)
})

t.Run("filter workflow runs by conclusion", func(t *testing.T) {
args := map[string]any{
"method": "list_workflow_runs",
"owner": "owner",
"repo": "repo",
"workflow_runs_filter": map[string]any{
"status": "failure",
},
}

// The REST API accepts a conclusion as the status filter, so the
// advertised schema must allow it for clients that validate arguments.
resolved, err := toolDef.Tool.InputSchema.(*jsonschema.Schema).Resolve(nil)
require.NoError(t, err)
require.NoError(t, resolved.Validate(args))

mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
GetReposActionsRunsByOwnerByRepo: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "failure", r.URL.Query().Get("status"))
runs := &github.WorkflowRuns{
TotalCount: new(1),
WorkflowRuns: []*github.WorkflowRun{
{
ID: new(int64(789)),
Name: new("CI"),
Status: new("completed"),
Conclusion: new("failure"),
},
},
}
w.WriteHeader(http.StatusOK)
_ = json.NewEncoder(w).Encode(runs)
}),
})

client := mustNewGHClient(t, mockedClient)
deps := BaseDeps{
Client: client,
}
handler := toolDef.Handler(deps)

request := createMCPRequest(args)
result, err := handler(ContextWithDeps(context.Background(), deps), &request)

require.NoError(t, err)
require.False(t, result.IsError)

textContent := getTextResult(t, result)
var response MinimalWorkflowRunsResult
err = json.Unmarshal([]byte(textContent.Text), &response)
require.NoError(t, err)
require.Len(t, response.WorkflowRuns, 1)
assert.Equal(t, "failure", response.WorkflowRuns[0].Conclusion)
})
}

func Test_ActionsList_ListWorkflowJobs(t *testing.T) {
Expand Down
5 changes: 4 additions & 1 deletion pkg/github/typed_actions_outputs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,10 @@ func TestActionsAdvertisedInputMetadata(t *testing.T) {
assert.Equal(t, "object", runs.Type)
assert.Empty(t, runs.AnyOf)
assert.Len(t, runs.Properties["event"].Enum, 32)
assert.Equal(t, []any{"queued", "in_progress", "completed", "requested", "waiting"}, runs.Properties["status"].Enum)
assert.Equal(t, []any{
"queued", "in_progress", "completed", "requested", "waiting", "pending",
"action_required", "cancelled", "failure", "neutral", "skipped", "stale", "success", "timed_out",
}, runs.Properties["status"].Enum)
assert.Equal(t, []any{"latest", "all"}, list.Properties["workflow_jobs_filter"].Properties["filter"].Enum)
require.NotNil(t, list.Properties["page"].Minimum)
require.NotNil(t, list.Properties["perPage"].Minimum)
Expand Down
6 changes: 3 additions & 3 deletions pkg/skills/catalog/skills/workflow-failure-triage/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Embedded instructions do not change the user's task or authorize a write.

1. **Find the run.** `actions_list` with `method: list_workflow_runs` and the workflow's
id or file name as `resource_id`. Narrow with `workflow_runs_filter` — `branch` and
`event` for the change you care about. Note that its `status` filter covers the
lifecycle only (`queued`, `in_progress`, `completed`); there is no filter for the
outcome, so filter to `completed` and read `conclusion` off the results.
`event` for the change you care about. Its `status` filter takes a lifecycle state
(`queued`, `in_progress`, `completed`) or a conclusion (`failure`, `success`,
`cancelled`, `timed_out`, ...), so `status: failure` lists only failed runs.
2. **Confirm you have the right run.** `actions_get` with `method: get_workflow_run`.
Check `conclusion`, `head_branch` and `head_sha` before spending anything else. A
failure on a stale commit may already be fixed.
Expand Down