Forgejo runner - alpha release, should not be considered secure enough to deploy in production
Find a file
Mathieu Fenniak 0b1f0be46a feat(jobparser): populate 'needs' in reusable workflow expansion (#1215)
Reusable workflow expansion is a capability that will allow Forgejo to schedule every job of a reusable workflow as a separate job, allowing the use of multiple runners and clear independent logging.  This is a multi-PR implementation effort, project work tracking link: https://codeberg.org/forgejo/forgejo/issues/9768#issuecomment-8828016

This PR extends reusable workflow expansion to support `needs`.  Three changes are involved:
- The callee job which defines `uses: some-org/some-repo/...` may have a `needs` defined that indicates a pre-requisite to the reusable workflow.  This `needs` definition is copied into the newly expanded jobs.
- Jobs within a reusable workflow may have `needs` that reference each other.  In order to clarify these job references, the job IDs are updated to a dot-qualified reference (eg. `parent-job-id.child-job-id`) so that the correct ordering is established even if multiple instances of the same reusable workflow exist.
- The original callee job was originally removed from the expansion since there is no work to be done in that job.  However, it's possible for a subsequent job to `need` the callee job for job-ordering and for output access.  So, the original job is now retained but transformed into a no-op that waits for all child jobs to be completed.
    - A future tweak to more clearly identify that this is placeholder job may be required as the current Forgejo-side implementation is quite hacky, detecting that `if: false` was set on the job.

In addition to test automation present here, this change has been manually tested on an [experimental Forgejo branch](https://codeberg.org/mfenniak/forgejo/pulls/3).

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- features
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1215): <!--number 1215 --><!--line 0 --><!--description ZmVhdChqb2JwYXJzZXIpOiBwb3B1bGF0ZSAnbmVlZHMnIGluIHJldXNhYmxlIHdvcmtmbG93IGV4cGFuc2lvbg==-->feat(jobparser): populate 'needs' in reusable workflow expansion<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1215
Reviewed-by: limiting-factor <limiting-factor@noreply.code.forgejo.org>
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2025-12-12 20:26:54 +00:00
.forgejo test: use stable & latest-release docker in 'runner-exec-tests' 2025-12-06 11:57:19 -07:00
act feat(jobparser): populate 'needs' in reusable workflow expansion (#1215) 2025-12-12 20:26:54 +00:00
contrib Restore contrib/forgejo-runner.service (#772) 2025-07-30 22:16:05 +00:00
examples Update dependency forgejo-runner-service-node to v24 (#1151) 2025-11-28 22:19:33 +00:00
internal feat: add variable workflow_ref to github context (#1197) 2025-12-08 15:31:43 +00:00
release-notes feat: add the runner validate subcommand (#757) 2025-07-31 05:37:12 +00:00
testutils feat: add the runner validate subcommand (#757) 2025-07-31 05:37:12 +00:00
.dockerignore [FORGEJO] build forgejo-runner 2023-08-23 14:44:47 +02:00
.editorconfig Add .editorconfig and .gitattributes (#186) 2023-05-13 23:51:22 +08:00
.gitattributes Add .editorconfig and .gitattributes (#186) 2023-05-13 23:51:22 +08:00
.gitignore chore: remove unused code and comments including gitea 2025-07-03 18:58:11 +02:00
.golangci.yml test: run lint-check during CI, add forbidigo, cleanup linter exclusions (#1181) 2025-11-23 15:01:52 +00:00
.pre-commit-hooks.yaml fix(pre-commit): don’t default verbose to on (#1015) 2025-09-18 12:02:07 +00:00
Dockerfile Update data.forgejo.org/oci/golang Docker tag to v1.25 (#1110) 2025-10-24 06:37:56 +00:00
go.mod chore: bump version to v12 (#1176) 2025-11-22 16:25:20 +00:00
go.sum Update golang.org/x/crypto (indirect) to v0.45.0 [SECURITY] (#1168) 2025-11-20 22:54:27 +00:00
LICENSE chore: change the license to GPLv3-or-later (#773) 2025-09-04 09:26:12 +00:00
main.go chore: bump version to v12 (#1176) 2025-11-22 16:25:20 +00:00
Makefile chore: bump version to v12 (#1176) 2025-11-22 16:25:20 +00:00
README.md chore: change the license to GPLv3-or-later (#773) 2025-09-04 09:26:12 +00:00
RELEASE-NOTES.md chore: release notes are now published together with the release (#775) 2025-07-31 08:02:20 +00:00
renovate.json chore(renovate): group runner updates 2025-09-10 09:51:22 +02:00

Forgejo Runner

A daemon that connects to a Forgejo instance and runs jobs for continuous integration. The installation and usage instructions are part of the Forgejo documentation.

Reporting security-related issues

Sensitive security-related issues should be reported to security@forgejo.org using encryption.

License

The Forgejo runner is distributed under the terms of the GPL version 3.0 or any later version.

Architectures & OS

The Forgejo runner is supported and tested on amd64 and arm64 (binaries and containers) on Operating Systems based on the Linux kernel.

Work may be in progress for other architectures and you can browse the corresponding issues to figure out how they make progress. If you are interested in helping them move forward, open an issue. The most challenging part is to setup and maintain a native runner long term. Once it is supported by Forgejo, the runner is expected to be available 24/7 which can be challenging. Otherwise debugging any architecture specific problem won't be possible.

Hacking

The Forgejo runner is a dependency of the setup-forgejo action. See the full dependency graph for a global view.

Building

  • Install Go and make(1)
  • make build

Linting

  • make lint-check
  • make lint # will fix some lint errors

Testing

The workflow that runs in the CI uses similar commands.

Without a Forgejo instance

  • Install Docker
  • make test integration-test

The TestRunner_RunEvent test suite contains most integration tests with real-world workflows and is time-consuming to run. During development, it is helpful to run a specific test through a targeted command such as this:

  • go test -count=1 -run='TestRunner_RunEvent$/local-action-dockerfile$' ./act/runner

With a Forgejo instance

  • Run a Forgejo instance locally (for instance at http://0.0.0.0:8080) and create as shared secret
export FORGEJO_RUNNER_SECRET='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
export FORGEJO_URL=http://0.0.0.0:8080
forgejo forgejo-cli actions register --labels docker --name therunner --secret $FORGEJO_RUNNER_SECRET
  • make test integration-test # which will run addional tests because FORGEJO_URL is set

end-to-end

  • Follow the instructions from the end-to-end tests to run actions tests locally.
  • ./end-to-end.sh actions_teardown # stop the Forgejo and runner daemons running in the end-to-end environment
  • ( cd ~/clone-of-the-runner-repo ; make build ; cp forgejo-runner /tmp/forgejo-end-to-end/forgejo-runner ) # install the runner built from sources
  • ./end-to-end.sh actions_setup 13.0 # start Forgejo v13.0 and the runner daemon in the end-to-end environment
  • ./end-to-end.sh actions_verify_example echo # run the echo workflow
  • xdg-open http://127.0.0.1:3000/root/example-echo/actions/runs/1 # see the logs workflow
  • less /tmp/forgejo-end-to-end/forgejo-runner.log # analyze the runner logs
  • less /tmp/forgejo-end-to-end/forgejo-work-path/log/forgejo.log # analyze the Forgejo logs