diff --git a/modules/structs/repo_actions.go b/modules/structs/repo_actions.go index 981baddb91..505367336c 100644 --- a/modules/structs/repo_actions.go +++ b/modules/structs/repo_actions.go @@ -34,7 +34,7 @@ type ActionTaskResponse struct { } // ActionRun represents an ActionRun -type ActionRun struct { +type RepoActionRun struct { ID int64 `json:"id"` Name string `json:"name"` RunNumber int64 `json:"run_number"` @@ -48,7 +48,7 @@ type ActionRun struct { } // ListActionRunResponse return a list of ActionRun -type ListActionRunResponse struct { - Entries []*ActionRun `json:"workflow_runs"` - TotalCount int64 `json:"total_count"` +type ListRepoActionRunResponse struct { + Entries []*RepoActionRun `json:"workflow_runs"` + TotalCount int64 `json:"total_count"` } diff --git a/routers/api/v1/repo/action.go b/routers/api/v1/repo/action.go index 2f0f2c17cd..03089a18d3 100644 --- a/routers/api/v1/repo/action.go +++ b/routers/api/v1/repo/action.go @@ -748,7 +748,7 @@ func ListActionRuns(ctx *context.APIContext) { // type: string // responses: // "200": - // "$ref": "#/responses/ActionRunList" + // "$ref": "#/responses/RepoActionRunList" // "400": // "$ref": "#/responses/error" // "403": @@ -779,12 +779,12 @@ func ListActionRuns(ctx *context.APIContext) { return } - res := new(api.ListActionRunResponse) + res := new(api.ListRepoActionRunResponse) res.TotalCount = total - res.Entries = make([]*api.ActionRun, len(runs)) + res.Entries = make([]*api.RepoActionRun, len(runs)) for i, r := range runs { - cr, err := convert.ToActionRun(ctx, r) + cr, err := convert.ToRepoActionRun(ctx, r) if err != nil { ctx.Error(http.StatusInternalServerError, "ToActionRun", err) return @@ -821,7 +821,7 @@ func GetActionRun(ctx *context.APIContext) { // required: true // responses: // "200": - // "$ref": "#/responses/ActionRun" + // "$ref": "#/responses/RepoActionRun" // "400": // "$ref": "#/responses/error" // "403": @@ -844,9 +844,9 @@ func GetActionRun(ctx *context.APIContext) { return } - res, err := convert.ToActionRun(ctx, run) + res, err := convert.ToRepoActionRun(ctx, run) if err != nil { - ctx.Error(http.StatusInternalServerError, "ToActionRun", err) + ctx.Error(http.StatusInternalServerError, "ToRepoActionRun", err) return } diff --git a/routers/api/v1/swagger/repo.go b/routers/api/v1/swagger/repo.go index 629f207ca3..a27e94253b 100644 --- a/routers/api/v1/swagger/repo.go +++ b/routers/api/v1/swagger/repo.go @@ -456,16 +456,16 @@ type swaggerSyncForkInfo struct { Body []api.SyncForkInfo `json:"body"` } -// ActionRunList -// swagger:response ActionRunList +// RepoActionRunList +// swagger:response RepoActionRunList type swaggerRepoActionRunList struct { // in:body - Body api.ListActionRunResponse `json:"body"` + Body api.ListRepoActionRunResponse `json:"body"` } -// ActionRun -// swagger:response ActionRun +// RepoActionRun +// swagger:response RepoActionRun type swaggerRepoActionRun struct { // in:body - Body api.ActionRun `json:"body"` + Body api.RepoActionRun `json:"body"` } diff --git a/services/convert/convert.go b/services/convert/convert.go index 45e5a1994b..48da9d7623 100644 --- a/services/convert/convert.go +++ b/services/convert/convert.go @@ -222,8 +222,8 @@ func ToActionTask(ctx context.Context, t *actions_model.ActionTask) (*api.Action }, nil } -// ToActionRun convert a actions_model.ActionRun to an api.ActionRun -func ToActionRun(ctx context.Context, r *actions_model.ActionRun) (*api.ActionRun, error) { +// ToRepoActionRun convert a actions_model.ActionRun to an api.RepoActionRun +func ToRepoActionRun(ctx context.Context, r *actions_model.ActionRun) (*api.RepoActionRun, error) { if err := r.LoadAttributes(ctx); err != nil { return nil, err } @@ -231,7 +231,7 @@ func ToActionRun(ctx context.Context, r *actions_model.ActionRun) (*api.ActionRu url := strings.TrimSuffix(setting.AppURL, "/") + r.Link() actor := ToUser(ctx, r.TriggerUser, nil) - return &api.ActionRun{ + return &api.RepoActionRun{ ID: r.ID, Name: r.Title, HeadBranch: r.PrettyRef(), diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index d2957a0f86..557ea5ea2b 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -4985,7 +4985,7 @@ ], "responses": { "200": { - "$ref": "#/responses/ActionRunList" + "$ref": "#/responses/RepoActionRunList" }, "400": { "$ref": "#/responses/error" @@ -5032,7 +5032,7 @@ ], "responses": { "200": { - "$ref": "#/responses/ActionRun" + "$ref": "#/responses/RepoActionRun" }, "400": { "$ref": "#/responses/error" @@ -21067,54 +21067,6 @@ }, "x-go-package": "forgejo.org/modules/structs" }, - "ActionRun": { - "description": "ActionRun represents an ActionRun", - "type": "object", - "properties": { - "event": { - "type": "string", - "x-go-name": "Event" - }, - "head_branch": { - "type": "string", - "x-go-name": "HeadBranch" - }, - "head_sha": { - "type": "string", - "x-go-name": "HeadSHA" - }, - "id": { - "type": "integer", - "format": "int64", - "x-go-name": "ID" - }, - "name": { - "type": "string", - "x-go-name": "Name" - }, - "run_number": { - "type": "integer", - "format": "int64", - "x-go-name": "RunNumber" - }, - "status": { - "type": "string", - "x-go-name": "Status" - }, - "triggering_actor": { - "$ref": "#/definitions/User" - }, - "url": { - "type": "string", - "x-go-name": "URL" - }, - "workflow_id": { - "type": "string", - "x-go-name": "WorkflowID" - } - }, - "x-go-package": "forgejo.org/modules/structs" - }, "ActionRunJob": { "description": "ActionRunJob represents a job of a run", "type": "object", @@ -25571,7 +25523,7 @@ }, "x-go-package": "forgejo.org/modules/structs" }, - "ListActionRunResponse": { + "ListRepoActionRunResponse": { "description": "ListActionRunResponse return a list of ActionRun", "type": "object", "properties": { @@ -25583,7 +25535,7 @@ "workflow_runs": { "type": "array", "items": { - "$ref": "#/definitions/ActionRun" + "$ref": "#/definitions/RepoActionRun" }, "x-go-name": "Entries" } @@ -27348,6 +27300,54 @@ }, "x-go-package": "forgejo.org/modules/structs" }, + "RepoActionRun": { + "description": "ActionRun represents an ActionRun", + "type": "object", + "properties": { + "event": { + "type": "string", + "x-go-name": "Event" + }, + "head_branch": { + "type": "string", + "x-go-name": "HeadBranch" + }, + "head_sha": { + "type": "string", + "x-go-name": "HeadSHA" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "run_number": { + "type": "integer", + "format": "int64", + "x-go-name": "RunNumber" + }, + "status": { + "type": "string", + "x-go-name": "Status" + }, + "triggering_actor": { + "$ref": "#/definitions/User" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "workflow_id": { + "type": "string", + "x-go-name": "WorkflowID" + } + }, + "x-go-package": "forgejo.org/modules/structs" + }, "RepoCollaboratorPermission": { "description": "RepoCollaboratorPermission to get repository permission for a collaborator", "type": "object", @@ -28794,18 +28794,6 @@ } } }, - "ActionRun": { - "description": "ActionRun", - "schema": { - "$ref": "#/definitions/ActionRun" - } - }, - "ActionRunList": { - "description": "ActionRunList", - "schema": { - "$ref": "#/definitions/ListActionRunResponse" - } - }, "ActionVariable": { "description": "ActionVariable", "schema": { @@ -29566,6 +29554,18 @@ } } }, + "RepoActionRun": { + "description": "RepoActionRun", + "schema": { + "$ref": "#/definitions/RepoActionRun" + } + }, + "RepoActionRunList": { + "description": "RepoActionRunList", + "schema": { + "$ref": "#/definitions/ListRepoActionRunResponse" + } + }, "RepoCollaboratorPermission": { "description": "RepoCollaboratorPermission", "schema": { diff --git a/tests/integration/api_repo_actions_test.go b/tests/integration/api_repo_actions_test.go index a7b66d6d62..34d603487c 100644 --- a/tests/integration/api_repo_actions_test.go +++ b/tests/integration/api_repo_actions_test.go @@ -169,7 +169,7 @@ func TestAPIGetListActionRun(t *testing.T) { req.AddTokenAuth(token) res := MakeRequest(t, req, http.StatusOK) - apiRuns := new(api.ListActionRunResponse) + apiRuns := new(api.ListRepoActionRunResponse) DecodeJSON(t, res, apiRuns) assert.Equal(t, int64(len(tt.expectedIDs)), apiRuns.TotalCount) @@ -231,7 +231,7 @@ func TestAPIGetActionRun(t *testing.T) { } dbRun := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{ID: tt.runID}) - apiRun := new(api.ActionRun) + apiRun := new(api.RepoActionRun) DecodeJSON(t, res, apiRun) assert.Equal(t, dbRun.Index, apiRun.RunNumber)