Skip to content

Commit 7d9eed5

Browse files
Merge branch 'main' into patch-1
2 parents d90b9e3 + 73a8f98 commit 7d9eed5

File tree

5 files changed

+57
-27
lines changed

5 files changed

+57
-27
lines changed

.github/workflows/license-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- name: Check if already commented
6464
if: steps.changes.outcome == 'failure' && steps.push.outcome == 'failure'
6565
id: check_comment
66-
uses: actions/github-script@v7
66+
uses: actions/github-script@v8
6767
with:
6868
script: |
6969
const { data: comments } = await github.rest.issues.listComments({
@@ -81,7 +81,7 @@ jobs:
8181
8282
- name: Comment with instructions if cannot push
8383
if: steps.changes.outcome == 'failure' && steps.push.outcome == 'failure' && steps.check_comment.outputs.already_commented == 'false'
84-
uses: actions/github-script@v7
84+
uses: actions/github-script@v8
8585
with:
8686
script: |
8787
await github.rest.issues.createComment({

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ The following sets of tools are available:
510510
- `repo`: Repository name (string, required)
511511
- `resource_id`: The unique identifier of the resource. This will vary based on the "method" provided, so ensure you provide the correct ID:
512512
- Do not provide any resource ID for 'list_workflows' method.
513-
- Provide a workflow ID or workflow file name (e.g. ci.yaml) for 'list_workflow_runs' method.
513+
- Provide a workflow ID or workflow file name (e.g. ci.yaml) for 'list_workflow_runs' method, or omit to list all workflow runs in the repository.
514514
- Provide a workflow run ID for 'list_workflow_jobs' and 'list_workflow_run_artifacts' methods.
515515
(string, optional)
516516
- `workflow_jobs_filter`: Filters for workflow jobs. **ONLY** used when method is 'list_workflow_jobs' (object, optional)

pkg/github/__toolsnaps__/actions_list.snap

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
"description": "Tools for listing GitHub Actions resources.\nUse this tool to list workflows in a repository, or list workflow runs, jobs, and artifacts for a specific workflow or workflow run.\n",
77
"inputSchema": {
88
"type": "object",
9-
"required": [
10-
"method",
11-
"owner",
12-
"repo"
13-
],
149
"properties": {
1510
"method": {
1611
"type": "string",
@@ -43,11 +38,10 @@
4338
},
4439
"resource_id": {
4540
"type": "string",
46-
"description": "The unique identifier of the resource. This will vary based on the \"method\" provided, so ensure you provide the correct ID:\n- Do not provide any resource ID for 'list_workflows' method.\n- Provide a workflow ID or workflow file name (e.g. ci.yaml) for 'list_workflow_runs' method.\n- Provide a workflow run ID for 'list_workflow_jobs' and 'list_workflow_run_artifacts' methods.\n"
41+
"description": "The unique identifier of the resource. This will vary based on the \"method\" provided, so ensure you provide the correct ID:\n- Do not provide any resource ID for 'list_workflows' method.\n- Provide a workflow ID or workflow file name (e.g. ci.yaml) for 'list_workflow_runs' method, or omit to list all workflow runs in the repository.\n- Provide a workflow run ID for 'list_workflow_jobs' and 'list_workflow_run_artifacts' methods.\n"
4742
},
4843
"workflow_jobs_filter": {
4944
"type": "object",
50-
"description": "Filters for workflow jobs. **ONLY** used when method is 'list_workflow_jobs'",
5145
"properties": {
5246
"filter": {
5347
"type": "string",
@@ -57,11 +51,11 @@
5751
"all"
5852
]
5953
}
60-
}
54+
},
55+
"description": "Filters for workflow jobs. **ONLY** used when method is 'list_workflow_jobs'"
6156
},
6257
"workflow_runs_filter": {
6358
"type": "object",
64-
"description": "Filters for workflow runs. **ONLY** used when method is 'list_workflow_runs'",
6559
"properties": {
6660
"actor": {
6761
"type": "string",
@@ -120,9 +114,15 @@
120114
"waiting"
121115
]
122116
}
123-
}
117+
},
118+
"description": "Filters for workflow runs. **ONLY** used when method is 'list_workflow_runs'"
124119
}
125-
}
120+
},
121+
"required": [
122+
"method",
123+
"owner",
124+
"repo"
125+
]
126126
},
127127
"name": "actions_list"
128128
}

pkg/github/actions.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ Use this tool to list workflows in a repository, or list workflow runs, jobs, an
14631463
Type: "string",
14641464
Description: `The unique identifier of the resource. This will vary based on the "method" provided, so ensure you provide the correct ID:
14651465
- Do not provide any resource ID for 'list_workflows' method.
1466-
- Provide a workflow ID or workflow file name (e.g. ci.yaml) for 'list_workflow_runs' method.
1466+
- Provide a workflow ID or workflow file name (e.g. ci.yaml) for 'list_workflow_runs' method, or omit to list all workflow runs in the repository.
14671467
- Provide a workflow run ID for 'list_workflow_jobs' and 'list_workflow_run_artifacts' methods.
14681468
`,
14691469
},
@@ -1586,18 +1586,18 @@ Use this tool to list workflows in a repository, or list workflow runs, jobs, an
15861586
switch method {
15871587
case actionsMethodListWorkflows:
15881588
// Do nothing, no resource ID needed
1589+
case actionsMethodListWorkflowRuns:
1590+
// resource_id is optional for list_workflow_runs
1591+
// If not provided, list all workflow runs in the repository
15891592
default:
15901593
if resourceID == "" {
15911594
return utils.NewToolResultError(fmt.Sprintf("missing required parameter for method %s: resource_id", method)), nil, nil
15921595
}
15931596

1594-
// For list_workflow_runs, resource_id could be a filename or numeric ID
1595-
// For other actions, resource ID must be an integer
1596-
if method != actionsMethodListWorkflowRuns {
1597-
resourceIDInt, parseErr = strconv.ParseInt(resourceID, 10, 64)
1598-
if parseErr != nil {
1599-
return utils.NewToolResultError(fmt.Sprintf("invalid resource_id, must be an integer for method %s: %v", method, parseErr)), nil, nil
1600-
}
1597+
// resource ID must be an integer for jobs and artifacts
1598+
resourceIDInt, parseErr = strconv.ParseInt(resourceID, 10, 64)
1599+
if parseErr != nil {
1600+
return utils.NewToolResultError(fmt.Sprintf("invalid resource_id, must be an integer for method %s: %v", method, parseErr)), nil, nil
16011601
}
16021602
}
16031603

@@ -2063,7 +2063,9 @@ func listWorkflowRuns(ctx context.Context, client *github.Client, args map[strin
20632063
var workflowRuns *github.WorkflowRuns
20642064
var resp *github.Response
20652065

2066-
if workflowIDInt, parseErr := strconv.ParseInt(resourceID, 10, 64); parseErr == nil {
2066+
if resourceID == "" {
2067+
workflowRuns, resp, err = client.Actions.ListRepositoryWorkflowRuns(ctx, owner, repo, listWorkflowRunsOptions)
2068+
} else if workflowIDInt, parseErr := strconv.ParseInt(resourceID, 10, 64); parseErr == nil {
20672069
workflowRuns, resp, err = client.Actions.ListWorkflowRunsByID(ctx, owner, repo, workflowIDInt, listWorkflowRunsOptions)
20682070
} else {
20692071
workflowRuns, resp, err = client.Actions.ListWorkflowRunsByFileName(ctx, owner, repo, resourceID, listWorkflowRunsOptions)

pkg/github/actions_test.go

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,8 +1997,33 @@ func Test_ActionsList_ListWorkflowRuns(t *testing.T) {
19971997
assert.NotNil(t, response.TotalCount)
19981998
})
19991999

2000-
t.Run("missing resource_id for list_workflow_runs", func(t *testing.T) {
2001-
mockedClient := mock.NewMockedHTTPClient()
2000+
t.Run("list all workflow runs without resource_id", func(t *testing.T) {
2001+
mockedClient := mock.NewMockedHTTPClient(
2002+
mock.WithRequestMatchHandler(
2003+
mock.GetReposActionsRunsByOwnerByRepo,
2004+
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
2005+
runs := &github.WorkflowRuns{
2006+
TotalCount: github.Ptr(2),
2007+
WorkflowRuns: []*github.WorkflowRun{
2008+
{
2009+
ID: github.Ptr(int64(123)),
2010+
Name: github.Ptr("CI"),
2011+
Status: github.Ptr("completed"),
2012+
Conclusion: github.Ptr("success"),
2013+
},
2014+
{
2015+
ID: github.Ptr(int64(456)),
2016+
Name: github.Ptr("Deploy"),
2017+
Status: github.Ptr("in_progress"),
2018+
Conclusion: nil,
2019+
},
2020+
},
2021+
}
2022+
w.WriteHeader(http.StatusOK)
2023+
_ = json.NewEncoder(w).Encode(runs)
2024+
}),
2025+
),
2026+
)
20022027

20032028
client := github.NewClient(mockedClient)
20042029
deps := BaseDeps{
@@ -2014,10 +2039,13 @@ func Test_ActionsList_ListWorkflowRuns(t *testing.T) {
20142039
result, err := handler(ContextWithDeps(context.Background(), deps), &request)
20152040

20162041
require.NoError(t, err)
2017-
require.True(t, result.IsError)
2042+
require.False(t, result.IsError)
20182043

20192044
textContent := getTextResult(t, result)
2020-
assert.Contains(t, textContent.Text, "missing required parameter")
2045+
var response github.WorkflowRuns
2046+
err = json.Unmarshal([]byte(textContent.Text), &response)
2047+
require.NoError(t, err)
2048+
assert.Equal(t, 2, *response.TotalCount)
20212049
})
20222050
}
20232051

0 commit comments

Comments
 (0)