-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add API endpoints for getting action jobs status #26673
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
48 commits
Select commit
Hold shift + click to select a range
b8a61a6
Add API endpoints for getting action jobs status
chesteripz 8b5443a
Fix template
chesteripz 6870e1a
Use the run index instead, since it's the number used in FE
chesteripz 8f787df
Update copyright message
chesteripz 246873a
Update routers/api/v1/api.go
chesteripz 5ebefc8
align with GitHub Actions
chesteripz fdfc2f4
Merge branch 'api-repo-actions' of github.com:chesteripz/gitea into a…
chesteripz 38d1197
Merge branch 'main' of github.com:go-gitea/gitea into api-repo-actions
chesteripz 5625bc5
Update Swagger template
chesteripz 80a2c8e
Merge remote-tracking branch 'origin/main' into api-repo-actions
chesteripz 1ba5701
Fix var-naming
chesteripz 4d9a231
Fix template
chesteripz a9cdb7e
Fix template
chesteripz 6928b37
Update template using generate swagger
chesteripz 7617e9e
Merge branch 'main' into api-repo-actions
chesteripz 083d718
Merge branch 'main' into api-repo-actions
chesteripz a348da4
Update modules/structs/repo_actions.go
chesteripz b94cbda
Update modules/structs/repo_actions.go
chesteripz 878eeed
Update modules/structs/repo_actions.go
chesteripz 5ababc5
Merge branch 'main' into api-repo-actions
chesteripz e61a33e
Merge branch 'main' into api-repo-actions
chesteripz a0be04f
Merge branch 'main' into api-repo-actions
chesteripz e05fc9a
Fix broken json after resolving merge conflict
chesteripz 2c8249b
More fixes after mreging from main
chesteripz 1028eef
move to db.find
chesteripz 4310284
Reducing queries
chesteripz ad16583
Add error res to swagger
chesteripz ae25e04
:Merge branch 'main' of github.com:go-gitea/gitea into api-repo-actions
chesteripz 3477737
Use GetListOptions() and panic()
chesteripz 0aabe97
Merge branch 'main' of github.com:go-gitea/gitea into api-repo-actions
chesteripz 0e61648
Merge branch 'main' into api-repo-actions
chesteripz 87ef8b7
Fix list options
chesteripz 8d45013
Merge branch 'main' into api-repo-actions
chesteripz e0e0941
Fix URL
chesteripz 5f26e8a
Fix format
chesteripz 2d53041
Return err in ToActionTask
chesteripz f954f20
Update modules/structs/repo_actions.go
chesteripz 86493c2
Fix as suggested
chesteripz e7bcc1b
Merge branch 'main' of github.com:go-gitea/gitea into api-repo-actions
chesteripz 04abcc7
Fix letter case
chesteripz fc3dc33
Fix template
chesteripz 105f20c
Merge branch 'main' into api-repo-actions
GiteaBot d574b18
Merge branch 'main' into api-repo-actions
GiteaBot 0735ccf
Merge branch 'main' into api-repo-actions
GiteaBot c1acd7d
Merge branch 'main' into api-repo-actions
GiteaBot 28b0c4e
Merge branch 'main' into api-repo-actions
GiteaBot 0922a5a
Merge branch 'main' into api-repo-actions
GiteaBot c9ae661
Merge branch 'main' into api-repo-actions
GiteaBot 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
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,34 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package structs | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
// ActionTask represents a ActionTask | ||
type ActionTask struct { | ||
ID int64 `json:"id"` | ||
Name string `json:"name"` | ||
HeadBranch string `json:"head_branch"` | ||
HeadSHA string `json:"head_sha"` | ||
RunNumber int64 `json:"run_number"` | ||
Event string `json:"event"` | ||
DisplayTitle string `json:"display_title"` | ||
Status string `json:"status"` | ||
WorkflowID string `json:"workflow_id"` | ||
URL string `json:"url"` | ||
// swagger:strfmt date-time | ||
CreatedAt time.Time `json:"created_at"` | ||
// swagger:strfmt date-time | ||
UpdatedAt time.Time `json:"updated_at"` | ||
// swagger:strfmt date-time | ||
RunStartedAt time.Time `json:"run_started_at"` | ||
} | ||
|
||
// ActionTaskResponse returns a ActionTask | ||
type ActionTaskResponse struct { | ||
Entries []*ActionTask `json:"workflow_runs"` | ||
TotalCount int64 `json:"total_count"` | ||
} |
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
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,80 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package repo | ||
|
||
import ( | ||
"net/http" | ||
|
||
actions_model "code.gitea.io/gitea/models/actions" | ||
"code.gitea.io/gitea/models/db" | ||
api "code.gitea.io/gitea/modules/structs" | ||
"code.gitea.io/gitea/routers/api/v1/utils" | ||
"code.gitea.io/gitea/services/context" | ||
"code.gitea.io/gitea/services/convert" | ||
) | ||
|
||
// ListActionTasks list all the actions of a repository | ||
func ListActionTasks(ctx *context.APIContext) { | ||
// swagger:operation GET /repos/{owner}/{repo}/actions/tasks repository ListActionTasks | ||
// --- | ||
// summary: List a repository's action tasks | ||
// produces: | ||
// - application/json | ||
// parameters: | ||
// - name: owner | ||
// in: path | ||
// description: owner of the repo | ||
// type: string | ||
// required: true | ||
// - name: repo | ||
// in: path | ||
// description: name of the repo | ||
// type: string | ||
// required: true | ||
// - name: page | ||
// in: query | ||
// description: page number of results to return (1-based) | ||
// type: integer | ||
// - name: limit | ||
// in: query | ||
// description: page size of results, default maximum page size is 50 | ||
// type: integer | ||
// responses: | ||
// "200": | ||
// "$ref": "#/responses/TasksList" | ||
chesteripz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// "400": | ||
// "$ref": "#/responses/error" | ||
// "403": | ||
// "$ref": "#/responses/forbidden" | ||
// "404": | ||
// "$ref": "#/responses/notFound" | ||
// "409": | ||
// "$ref": "#/responses/conflict" | ||
// "422": | ||
// "$ref": "#/responses/validationError" | ||
lunny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
tasks, total, err := db.FindAndCount[actions_model.ActionTask](ctx, &actions_model.FindTaskOptions{ | ||
ListOptions: utils.GetListOptions(ctx), | ||
RepoID: ctx.Repo.Repository.ID, | ||
}) | ||
if err != nil { | ||
ctx.Error(http.StatusInternalServerError, "ListActionTasks", err) | ||
return | ||
} | ||
|
||
res := new(api.ActionTaskResponse) | ||
res.TotalCount = total | ||
|
||
res.Entries = make([]*api.ActionTask, len(tasks)) | ||
for i := range tasks { | ||
convertedTask, err := convert.ToActionTask(ctx, tasks[i]) | ||
if err != nil { | ||
ctx.Error(http.StatusInternalServerError, "ToActionTask", err) | ||
return | ||
} | ||
res.Entries[i] = convertedTask | ||
} | ||
|
||
ctx.JSON(http.StatusOK, &res) | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.