1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00
Forgejo runner - alpha release, should not be considered secure enough to deploy in production
Find a file
Earl Warren 16276cc0d6
fix: use a fixed runner name for old (<= v1.20) Forgejo instances (#972)
The bug was already there before the recent refactor. Only it
manifested itself when shutting down the runner because
`resp.Msg.GetRunner().GetName()` was only called then. It was
correctly refactored in the createRunner function and therefore
surfaced because `resp.Msg.GetRunner().GetName()` was called
during initialization instead of during shutdown.

```
time="2025-09-10T05:41:10Z" level=info msg="log level changed to debug" func="[func2]" file="[daemon.go:130]"
time="2025-09-10T05:41:10Z" level=info msg="Starting runner daemon" func="[runDaemon]" file="[daemon.go:51]"
time="2025-09-10T05:41:10Z" level=warning msg="Because the Forgejo instance is an old version, skipping declaring the labels and version." func="[func6]" file="[daemon.go:208]"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xcc1a23]
goroutine 1 [running]:
code.forgejo.org/forgejo/runner/v11/internal/app/cmd.init.func6({0x111f428, 0xc0000e8ab0}, 0xc0003b4000, 0xc0003b8230, {0x1125eb8?, 0xc000424040?}, {0xc000032840, 0x6, 0x8})
	/srv/internal/app/cmd/daemon.go:222 +0x4a3
code.forgejo.org/forgejo/runner/v11/internal/app/cmd.runDaemon({0x111f578, 0xc00025fa00}, 0xc0000380b0)
	/srv/internal/app/cmd/daemon.go:68 +0x23f
code.forgejo.org/forgejo/runner/v11/internal/app/cmd.Execute.getRunDaemonCommandProcessor.func6(0xc000044d00?, {0xc0000c4360?, 0x4?, 0xf63e10?})
	/srv/internal/app/cmd/daemon.go:33 +0x1f
github.com/spf13/cobra.(*Command).execute(0xc0000fe908, {0xc0000c4340, 0x2, 0x2})
	/go/pkg/mod/github.com/spf13/cobra@v1.10.1/command.go:1015 +0xaaa
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000fe008)
	/go/pkg/mod/github.com/spf13/cobra@v1.10.1/command.go:1148 +0x46f
github.com/spf13/cobra.(*Command).Execute(...)
	/go/pkg/mod/github.com/spf13/cobra@v1.10.1/command.go:1071
code.forgejo.org/forgejo/runner/v11/internal/app/cmd.Execute({0x111f578, 0xc00025fa00})
	/srv/internal/app/cmd/cmd.go:89 +0xa05
main.main()
	/srv/main.go:18 +0x7b
20250910 05:41:10 daemon: client (pid 4264) exited with 2 status, exiting
```

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- bug fixes
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/972): <!--number 972 --><!--line 0 --><!--description Zml4OiB1c2UgYSBmaXhlZCBydW5uZXIgbmFtZSBmb3Igb2xkICg8PSB2MS4yMCkgRm9yZ2VqbyBpbnN0YW5jZXM=-->fix: use a fixed runner name for old (<= v1.20) Forgejo instances<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/972
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-09-10 16:06:48 +00:00
.forgejo Update https://data.forgejo.org/actions/setup-forgejo action to v3.0.3 (#969) 2025-09-10 09:18:53 +00:00
.github/workflows chore: restore GitHub windows build workflow (#815) 2025-08-07 08:56:39 +00:00
act fix: shutdown the runner when the cache fails with a non recoverable error (#935) 2025-09-07 16:03:31 +00:00
contrib Restore contrib/forgejo-runner.service (#772) 2025-07-30 22:16:05 +00:00
examples Update forgejo-runner to v11 (major) (#975) 2025-09-10 09:18:50 +00:00
internal fix: use a fixed runner name for old (<= v1.20) Forgejo instances (#972) 2025-09-10 16:06:48 +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 chore: use t.Context for tests, activate usetesting for lint + add t.TempDir and t.Chdir (#844) 2025-08-11 13:21:42 +00:00
Dockerfile chore: change the license to GPLv3-or-later (#773) 2025-09-04 09:26:12 +00:00
go.mod Update module golang.org/x/term to v0.35.0 (#966) 2025-09-09 08:52:15 +00:00
go.sum Update module golang.org/x/term to v0.35.0 (#966) 2025-09-09 08:52:15 +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 v11 (#940) 2025-09-05 07:29:38 +00:00
Makefile chore: cache: generate mocks for act/artifactcache/caches.go 2025-09-05 17:30:08 +02: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