mirror of
https://github.com/go-gitea/gitea.git
synced 2025-11-06 16:40:31 +01:00
Remove 'latest' support from run ID parameter for consistency with other workflow APIs
This commit is contained in:
parent
ef7f7e2a5c
commit
b8ab9115f8
@ -94,8 +94,8 @@ func RerunWorkflowRun(ctx *context.APIContext) {
|
||||
// required: true
|
||||
// - name: run
|
||||
// in: path
|
||||
// description: run ID or "latest"
|
||||
// type: string
|
||||
// description: run ID
|
||||
// type: integer
|
||||
// required: true
|
||||
// responses:
|
||||
// "200":
|
||||
@ -169,8 +169,8 @@ func CancelWorkflowRun(ctx *context.APIContext) {
|
||||
// required: true
|
||||
// - name: run
|
||||
// in: path
|
||||
// description: run ID or "latest"
|
||||
// type: string
|
||||
// description: run ID
|
||||
// type: integer
|
||||
// required: true
|
||||
// responses:
|
||||
// "200":
|
||||
@ -265,8 +265,8 @@ func ApproveWorkflowRun(ctx *context.APIContext) {
|
||||
// required: true
|
||||
// - name: run
|
||||
// in: path
|
||||
// description: run ID or "latest"
|
||||
// type: string
|
||||
// description: run ID
|
||||
// type: integer
|
||||
// required: true
|
||||
// responses:
|
||||
// "200":
|
||||
@ -358,8 +358,8 @@ func RerunWorkflowJob(ctx *context.APIContext) {
|
||||
// required: true
|
||||
// - name: run
|
||||
// in: path
|
||||
// description: run ID or "latest"
|
||||
// type: string
|
||||
// description: run ID
|
||||
// type: integer
|
||||
// required: true
|
||||
// - name: job_id
|
||||
// in: path
|
||||
@ -442,19 +442,6 @@ func RerunWorkflowJob(ctx *context.APIContext) {
|
||||
|
||||
// Helper functions
|
||||
func getRunID(ctx *context.APIContext) (int64, *actions_model.ActionRun, error) {
|
||||
// if run param is "latest", get the latest run
|
||||
if ctx.PathParam("run") == "latest" {
|
||||
run, err := actions_model.GetLatestRun(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
if run == nil {
|
||||
return 0, nil, util.ErrNotExist
|
||||
}
|
||||
return run.ID, run, nil
|
||||
}
|
||||
|
||||
// Otherwise get run by ID
|
||||
runID := ctx.PathParamInt64("run")
|
||||
run, has, err := db.GetByID[actions_model.ActionRun](ctx, runID)
|
||||
if err != nil {
|
||||
@ -584,8 +571,8 @@ func GetWorkflowRunLogs(ctx *context.APIContext) {
|
||||
// required: true
|
||||
// - name: run
|
||||
// in: path
|
||||
// description: run ID or "latest"
|
||||
// type: string
|
||||
// description: run ID
|
||||
// type: integer
|
||||
// required: true
|
||||
// responses:
|
||||
// "200":
|
||||
@ -631,8 +618,8 @@ func GetWorkflowJobLogs(ctx *context.APIContext) {
|
||||
// required: true
|
||||
// - name: run
|
||||
// in: path
|
||||
// description: run ID or "latest"
|
||||
// type: string
|
||||
// description: run ID
|
||||
// type: integer
|
||||
// required: true
|
||||
// - name: job_id
|
||||
// in: path
|
||||
@ -703,8 +690,8 @@ func GetWorkflowRunLogsStream(ctx *context.APIContext) {
|
||||
// required: true
|
||||
// - name: run
|
||||
// in: path
|
||||
// description: run ID or "latest"
|
||||
// type: string
|
||||
// description: run ID
|
||||
// type: integer
|
||||
// required: true
|
||||
// - name: job
|
||||
// in: query
|
||||
|
||||
28
templates/swagger/v1_json.tmpl
generated
28
templates/swagger/v1_json.tmpl
generated
@ -5292,8 +5292,8 @@
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "run ID or \"latest\"",
|
||||
"type": "integer",
|
||||
"description": "run ID",
|
||||
"name": "run",
|
||||
"in": "path",
|
||||
"required": true
|
||||
@ -5393,8 +5393,8 @@
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "run ID or \"latest\"",
|
||||
"type": "integer",
|
||||
"description": "run ID",
|
||||
"name": "run",
|
||||
"in": "path",
|
||||
"required": true
|
||||
@ -5506,8 +5506,8 @@
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "run ID or \"latest\"",
|
||||
"type": "integer",
|
||||
"description": "run ID",
|
||||
"name": "run",
|
||||
"in": "path",
|
||||
"required": true
|
||||
@ -5556,8 +5556,8 @@
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "run ID or \"latest\"",
|
||||
"type": "integer",
|
||||
"description": "run ID",
|
||||
"name": "run",
|
||||
"in": "path",
|
||||
"required": true
|
||||
@ -5612,8 +5612,8 @@
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "run ID or \"latest\"",
|
||||
"type": "integer",
|
||||
"description": "run ID",
|
||||
"name": "run",
|
||||
"in": "path",
|
||||
"required": true
|
||||
@ -5656,8 +5656,8 @@
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "run ID or \"latest\"",
|
||||
"type": "integer",
|
||||
"description": "run ID",
|
||||
"name": "run",
|
||||
"in": "path",
|
||||
"required": true
|
||||
@ -5770,8 +5770,8 @@
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "run ID or \"latest\"",
|
||||
"type": "integer",
|
||||
"description": "run ID",
|
||||
"name": "run",
|
||||
"in": "path",
|
||||
"required": true
|
||||
|
||||
@ -154,10 +154,7 @@ func TestAPIActionsRerunWorkflowRun(t *testing.T) {
|
||||
AddTokenAuth(token)
|
||||
MakeRequest(t, req, http.StatusNotFound)
|
||||
|
||||
// Test rerun with "latest" parameter
|
||||
req = NewRequest(t, "POST", fmt.Sprintf("/api/v1/repos/%s/actions/runs/latest/rerun", repo.FullName())).
|
||||
AddTokenAuth(token)
|
||||
MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
}
|
||||
|
||||
func TestAPIActionsRerunWorkflowRunPermissions(t *testing.T) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user