Skip to content

Commit b8ab911

Browse files
committed
Remove 'latest' support from run ID parameter for consistency with other workflow APIs
1 parent ef7f7e2 commit b8ab911

File tree

3 files changed

+29
-45
lines changed

3 files changed

+29
-45
lines changed

routers/api/v1/repo/actions_run.go

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ func RerunWorkflowRun(ctx *context.APIContext) {
9494
// required: true
9595
// - name: run
9696
// in: path
97-
// description: run ID or "latest"
98-
// type: string
97+
// description: run ID
98+
// type: integer
9999
// required: true
100100
// responses:
101101
// "200":
@@ -169,8 +169,8 @@ func CancelWorkflowRun(ctx *context.APIContext) {
169169
// required: true
170170
// - name: run
171171
// in: path
172-
// description: run ID or "latest"
173-
// type: string
172+
// description: run ID
173+
// type: integer
174174
// required: true
175175
// responses:
176176
// "200":
@@ -265,8 +265,8 @@ func ApproveWorkflowRun(ctx *context.APIContext) {
265265
// required: true
266266
// - name: run
267267
// in: path
268-
// description: run ID or "latest"
269-
// type: string
268+
// description: run ID
269+
// type: integer
270270
// required: true
271271
// responses:
272272
// "200":
@@ -358,8 +358,8 @@ func RerunWorkflowJob(ctx *context.APIContext) {
358358
// required: true
359359
// - name: run
360360
// in: path
361-
// description: run ID or "latest"
362-
// type: string
361+
// description: run ID
362+
// type: integer
363363
// required: true
364364
// - name: job_id
365365
// in: path
@@ -442,19 +442,6 @@ func RerunWorkflowJob(ctx *context.APIContext) {
442442

443443
// Helper functions
444444
func getRunID(ctx *context.APIContext) (int64, *actions_model.ActionRun, error) {
445-
// if run param is "latest", get the latest run
446-
if ctx.PathParam("run") == "latest" {
447-
run, err := actions_model.GetLatestRun(ctx, ctx.Repo.Repository.ID)
448-
if err != nil {
449-
return 0, nil, err
450-
}
451-
if run == nil {
452-
return 0, nil, util.ErrNotExist
453-
}
454-
return run.ID, run, nil
455-
}
456-
457-
// Otherwise get run by ID
458445
runID := ctx.PathParamInt64("run")
459446
run, has, err := db.GetByID[actions_model.ActionRun](ctx, runID)
460447
if err != nil {
@@ -584,8 +571,8 @@ func GetWorkflowRunLogs(ctx *context.APIContext) {
584571
// required: true
585572
// - name: run
586573
// in: path
587-
// description: run ID or "latest"
588-
// type: string
574+
// description: run ID
575+
// type: integer
589576
// required: true
590577
// responses:
591578
// "200":
@@ -631,8 +618,8 @@ func GetWorkflowJobLogs(ctx *context.APIContext) {
631618
// required: true
632619
// - name: run
633620
// in: path
634-
// description: run ID or "latest"
635-
// type: string
621+
// description: run ID
622+
// type: integer
636623
// required: true
637624
// - name: job_id
638625
// in: path
@@ -703,8 +690,8 @@ func GetWorkflowRunLogsStream(ctx *context.APIContext) {
703690
// required: true
704691
// - name: run
705692
// in: path
706-
// description: run ID or "latest"
707-
// type: string
693+
// description: run ID
694+
// type: integer
708695
// required: true
709696
// - name: job
710697
// in: query

templates/swagger/v1_json.tmpl

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration/api_actions_run_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ func TestAPIActionsRerunWorkflowRun(t *testing.T) {
154154
AddTokenAuth(token)
155155
MakeRequest(t, req, http.StatusNotFound)
156156

157-
// Test rerun with "latest" parameter
158-
req = NewRequest(t, "POST", fmt.Sprintf("/api/v1/repos/%s/actions/runs/latest/rerun", repo.FullName())).
159-
AddTokenAuth(token)
160-
MakeRequest(t, req, http.StatusOK)
157+
161158
}
162159

163160
func TestAPIActionsRerunWorkflowRunPermissions(t *testing.T) {

0 commit comments

Comments
 (0)