From 69f9d50745e75b025f714ec22f369cd6f78b4763 Mon Sep 17 00:00:00 2001 From: John Moon Date: Tue, 30 Dec 2025 22:39:34 +0100 Subject: [PATCH] feat: add Forgejo server version to runner context (#10642) Currently, there's no way for actions runners to know what version of Forgejo is running on the server side. This makes it difficult/impossible to know which features are available and can make maintaining compatibility tricky. Let's add the Forgejo server version to the context. See associated PR in the runner repo: https://code.forgejo.org/forgejo/runner/pulls/1249 ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [x] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [x] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/.md` to be be used for the release notes instead of the title. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10642 Reviewed-by: Michael Kriese Reviewed-by: Mathieu Fenniak Co-authored-by: John Moon Co-committed-by: John Moon --- services/actions/context.go | 1 + tests/integration/actions_job_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/services/actions/context.go b/services/actions/context.go index d982b231ff..0313b11031 100644 --- a/services/actions/context.go +++ b/services/actions/context.go @@ -112,6 +112,7 @@ func GenerateGiteaContext(run *actions_model.ActionRun, job *actions_model.Actio // additional contexts gitContext["gitea_default_actions_url"] = setting.Actions.DefaultActionsURL.URL() + gitContext["forgejo_server_version"] = setting.AppVer if job != nil { gitContext["job"] = job.JobID diff --git a/tests/integration/actions_job_test.go b/tests/integration/actions_job_test.go index baa1420bdd..e91f0e92bd 100644 --- a/tests/integration/actions_job_test.go +++ b/tests/integration/actions_job_test.go @@ -443,6 +443,7 @@ jobs: assert.Equal(t, actionRun.WorkflowID, gtCtx["workflow"].GetStringValue()) assert.Equal(t, "user2/actions-gitea-context/.gitea/workflows/pull.yml@refs/pull/1/head", gtCtx["workflow_ref"].GetStringValue()) assert.Equal(t, setting.Actions.DefaultActionsURL.URL(), gtCtx["gitea_default_actions_url"].GetStringValue()) + assert.Equal(t, setting.AppVer, gtCtx["forgejo_server_version"].GetStringValue()) token := gtCtx["token"].GetStringValue() assert.Equal(t, actionTask.TokenLastEight, token[len(token)-8:])