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
|
// required: true
|
||||||
// - name: run
|
// - name: run
|
||||||
// in: path
|
// in: path
|
||||||
// description: run ID or "latest"
|
// description: run ID
|
||||||
// type: string
|
// type: integer
|
||||||
// required: true
|
// required: true
|
||||||
// responses:
|
// responses:
|
||||||
// "200":
|
// "200":
|
||||||
@ -169,8 +169,8 @@ func CancelWorkflowRun(ctx *context.APIContext) {
|
|||||||
// required: true
|
// required: true
|
||||||
// - name: run
|
// - name: run
|
||||||
// in: path
|
// in: path
|
||||||
// description: run ID or "latest"
|
// description: run ID
|
||||||
// type: string
|
// type: integer
|
||||||
// required: true
|
// required: true
|
||||||
// responses:
|
// responses:
|
||||||
// "200":
|
// "200":
|
||||||
@ -265,8 +265,8 @@ func ApproveWorkflowRun(ctx *context.APIContext) {
|
|||||||
// required: true
|
// required: true
|
||||||
// - name: run
|
// - name: run
|
||||||
// in: path
|
// in: path
|
||||||
// description: run ID or "latest"
|
// description: run ID
|
||||||
// type: string
|
// type: integer
|
||||||
// required: true
|
// required: true
|
||||||
// responses:
|
// responses:
|
||||||
// "200":
|
// "200":
|
||||||
@ -358,8 +358,8 @@ func RerunWorkflowJob(ctx *context.APIContext) {
|
|||||||
// required: true
|
// required: true
|
||||||
// - name: run
|
// - name: run
|
||||||
// in: path
|
// in: path
|
||||||
// description: run ID or "latest"
|
// description: run ID
|
||||||
// type: string
|
// type: integer
|
||||||
// required: true
|
// required: true
|
||||||
// - name: job_id
|
// - name: job_id
|
||||||
// in: path
|
// in: path
|
||||||
@ -442,19 +442,6 @@ func RerunWorkflowJob(ctx *context.APIContext) {
|
|||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
func getRunID(ctx *context.APIContext) (int64, *actions_model.ActionRun, error) {
|
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")
|
runID := ctx.PathParamInt64("run")
|
||||||
run, has, err := db.GetByID[actions_model.ActionRun](ctx, runID)
|
run, has, err := db.GetByID[actions_model.ActionRun](ctx, runID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -584,8 +571,8 @@ func GetWorkflowRunLogs(ctx *context.APIContext) {
|
|||||||
// required: true
|
// required: true
|
||||||
// - name: run
|
// - name: run
|
||||||
// in: path
|
// in: path
|
||||||
// description: run ID or "latest"
|
// description: run ID
|
||||||
// type: string
|
// type: integer
|
||||||
// required: true
|
// required: true
|
||||||
// responses:
|
// responses:
|
||||||
// "200":
|
// "200":
|
||||||
@ -631,8 +618,8 @@ func GetWorkflowJobLogs(ctx *context.APIContext) {
|
|||||||
// required: true
|
// required: true
|
||||||
// - name: run
|
// - name: run
|
||||||
// in: path
|
// in: path
|
||||||
// description: run ID or "latest"
|
// description: run ID
|
||||||
// type: string
|
// type: integer
|
||||||
// required: true
|
// required: true
|
||||||
// - name: job_id
|
// - name: job_id
|
||||||
// in: path
|
// in: path
|
||||||
@ -703,8 +690,8 @@ func GetWorkflowRunLogsStream(ctx *context.APIContext) {
|
|||||||
// required: true
|
// required: true
|
||||||
// - name: run
|
// - name: run
|
||||||
// in: path
|
// in: path
|
||||||
// description: run ID or "latest"
|
// description: run ID
|
||||||
// type: string
|
// type: integer
|
||||||
// required: true
|
// required: true
|
||||||
// - name: job
|
// - name: job
|
||||||
// in: query
|
// in: query
|
||||||
|
|||||||
28
templates/swagger/v1_json.tmpl
generated
28
templates/swagger/v1_json.tmpl
generated
@ -5292,8 +5292,8 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "integer",
|
||||||
"description": "run ID or \"latest\"",
|
"description": "run ID",
|
||||||
"name": "run",
|
"name": "run",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
@ -5393,8 +5393,8 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "integer",
|
||||||
"description": "run ID or \"latest\"",
|
"description": "run ID",
|
||||||
"name": "run",
|
"name": "run",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
@ -5506,8 +5506,8 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "integer",
|
||||||
"description": "run ID or \"latest\"",
|
"description": "run ID",
|
||||||
"name": "run",
|
"name": "run",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
@ -5556,8 +5556,8 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "integer",
|
||||||
"description": "run ID or \"latest\"",
|
"description": "run ID",
|
||||||
"name": "run",
|
"name": "run",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
@ -5612,8 +5612,8 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "integer",
|
||||||
"description": "run ID or \"latest\"",
|
"description": "run ID",
|
||||||
"name": "run",
|
"name": "run",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
@ -5656,8 +5656,8 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "integer",
|
||||||
"description": "run ID or \"latest\"",
|
"description": "run ID",
|
||||||
"name": "run",
|
"name": "run",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
@ -5770,8 +5770,8 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "integer",
|
||||||
"description": "run ID or \"latest\"",
|
"description": "run ID",
|
||||||
"name": "run",
|
"name": "run",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
|
|||||||
@ -154,10 +154,7 @@ func TestAPIActionsRerunWorkflowRun(t *testing.T) {
|
|||||||
AddTokenAuth(token)
|
AddTokenAuth(token)
|
||||||
MakeRequest(t, req, http.StatusNotFound)
|
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) {
|
func TestAPIActionsRerunWorkflowRunPermissions(t *testing.T) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user