Skip to content

feat(api): Add GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs - #37196

Merged
bircni merged 27 commits into
go-gitea:mainfrom
bn-zr:feature/add-api-workflowruns
Jun 11, 2026
Merged

bircni merged 27 commits into
go-gitea:mainfrom
bn-zr:feature/add-api-workflowruns

Conversation

@bn-zr

@bn-zr bn-zr commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 13, 2026
@bn-zr
bn-zr marked this pull request as ready for review April 13, 2026 17:45
@bircni
bircni requested a review from silverwind April 13, 2026 18:09
@silverwind

silverwind commented Apr 13, 2026

Copy link
Copy Markdown
Member

This PR aims for GitHub API compatibility. A few items drift from that — implement what's feasible.

  1. workflow_id numeric IDs. GitHub docs:

    The ID of the workflow. You can also pass the workflow file name as a string.

    Gitea stores workflow_id as a filename (models/actions/run.go:36) with no numeric ID concept. Implementing this is out of scope, but the swagger description should say "filename only (e.g. build.yml)" so users don't pass numeric IDs expecting them to work.

  2. Missing query parameters. GitHub documents these; consider adding the feasible ones:

    • created — date-time range. Parse >=, <=, .. operators and add a created_unix range filter to FindRunOptions.
    • exclude_pull_requests — boolean. When true, add builder.Neq{"trigger_event": "pull_request"} in FindRunOptions.ToConds().
  3. Nonexistent workflow returns 200 with empty list. ActionsGetWorkflow in this same file returns 404 for an unknown workflow_id. For consistency:

    workflowID := ctx.PathParam("workflow_id")
    if _, err := convert.GetActionWorkflow(ctx, ctx.Repo.GitRepo, ctx.Repo.Repository, workflowID); err != nil {
        if errors.Is(err, util.ErrNotExist) {
            ctx.APIError(http.StatusNotFound, err)
        } else {
            ctx.APIErrorInternal(err)
        }
        return
    }

    Replace the empty-list test assertion with a 404 check.

  4. Test loop break. If the expected run appears first, filter checks on later runs are skipped. Drop the break:

    for _, run := range runList.Entries {
        verifyWorkflowRunCanbeFoundWithStatusFilter(t, workflowRunsURL, token, run.ID, "", run.Status, "", "", "", "")
        verifyWorkflowRunCanbeFoundWithStatusFilter(t, workflowRunsURL, token, run.ID, "", "", "", run.HeadBranch, "", "")
        verifyWorkflowRunCanbeFoundWithStatusFilter(t, workflowRunsURL, token, run.ID, "", "", run.Event, "", "", "")
        if run.ID == expectedRunID {
            found = true
        }
    }
  5. Filter coverage. Add actor and head_sha checks to testAPIWorkflowRunsByWorkflowID, mirroring testAPIWorkflowRunBasic.


Comment written by Claude Opus 4.6.

- Update workflow_id swagger description to clarify filename-only
- Add exclude_pull_requests query parameter
- Return 404 for nonexistent workflow in ActionsListWorkflowRuns
- Remove break from test loop so all runs are verified
- Add actor and head_sha filter coverage to testAPIWorkflowRunsByWorkflowID
- Update nonexistent workflow test to expect 404
@bircni
bircni force-pushed the feature/add-api-workflowruns branch from c1fd337 to e15b1c2 Compare April 13, 2026 18:56
@bircni

bircni commented Apr 14, 2026

Copy link
Copy Markdown
Member

passes locally @silverwind can you rerun? thats weird...

@silverwind

silverwind commented Apr 15, 2026

Copy link
Copy Markdown
Member

Ensure you run without test cache: go test -count=1 ..., could also be flaky. Run a few times to verify that.

@lunny lunny added the type/enhancement An improvement of existing functionality label Apr 20, 2026
@silverwind

Copy link
Copy Markdown
Member

Is it ready?

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 20, 2026
@bircni
bircni requested a review from wxiaoguang May 31, 2026 17:02
@wxiaoguang
wxiaoguang removed their request for review May 31, 2026 18:08
@bircni bircni modified the milestones: 1.27.0, 1.28.0 Jun 7, 2026
@bircni

bircni commented Jun 9, 2026

Copy link
Copy Markdown
Member

@silverwind could you please check again?

@wxiaoguang
wxiaoguang dismissed their stale review June 9, 2026 16:27

dismiss

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Jun 9, 2026
@github-actions github-actions Bot added type/feature Completely new functionality. Can only be merged if feature freeze is not active. and removed type/enhancement An improvement of existing functionality labels Jun 9, 2026
Comment thread routers/api/v1/repo/action.go Outdated
Comment thread tests/integration/workflow_run_api_check_test.go Outdated
@bircni
bircni requested a review from wxiaoguang June 10, 2026 21:53
@bircni

bircni commented Jun 11, 2026

Copy link
Copy Markdown
Member

@wxiaoguang can you check again pls

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 11, 2026
@bircni bircni modified the milestones: 1.28.0, 1.27.0 Jun 11, 2026
@bircni
bircni enabled auto-merge (squash) June 11, 2026 17:02
@bircni bircni added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jun 11, 2026
@bircni
bircni merged commit fefb6f3 into go-gitea:main Jun 11, 2026
27 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jun 11, 2026
zeekay pushed a commit to hanzoai/forge that referenced this pull request Jul 26, 2026
…id}/runs (go-gitea#37196)

- Add GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs
endpoint, matching the
https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2026-03-10#list-workflow-runs-for-a-workflow

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: bircni <bircni@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/gitea-actions related to the actions of Gitea type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants