r/forgejo • • 22d ago

What I learned building hosted runners for Forgejo Actions

I have been building hosted runners for Forgejo Actions on my servers in Germany (it’s called Stoke CI, more below, and yes, I run it). Forgejo and forgejo-runner surprised me a few times along the way so here is what I ran into in case it saves someone else the debugging.

  1. Host mode breaks Rust caching: In host mode, forgejo-runner puts every job in a randomly named directory. rust-cache puts the absolute path of “target/“ into the cache version, so it never restores since the path doesn’t match. I have opened an issue on this in https://code.forgejo.org/forgejo/forgejo-actions-feature-requests/issues/139. Write-up: https://stokeci.dev/blog/host-mode-cache-keys
  2. Ephemeral runners that never get a job never expire: Forgejo deletes an ephemeral runner after its one job, but one that never got it never gets deleted. Its credentials can be reused, even with different labels so I reuse them instead of piling up dead runners. Notes on this: https://stokeci.dev/blog/ephemeral-forgejo-runners
  3. A runner that dies mid-job leaves the job “running”: On Forgejo 17.0.1 the job was still marked running after 10+ minutes. The runner stayed listed, so still listed doesn’t mean “still alive”
  4. An empty job list is “null” not “[]”: Small thing but broke my first parser ( GET /api/v1/…/actions/jobs )

After all these obstacles I ran through, I was still able to make a functional hosted runners platform for Forgejo which I love. Right now I’m looking for bugs so I opened a beta with free signup.

Also surprisingly setting up caches for crates.io and actions caches was easy to do, which I thought would be hard.

Limits on Stoke CI (for beta):
- 2 cores, 4gb, 60 minutes per job( I know, cool right? :) )
- signups are approved by hand ( a fast approval time so it’s not really that much of a limit )

I would really like to know: what you would need before using hosted runners instead of self-hosting them?
https://stokeci.dev

20 Upvotes

15 comments sorted by

4

u/ad-on-is 22d ago

I happily selfhost my runners.

1

u/alexdev-tb 22d ago

Totally fair, self-hosting runners is a great setup if you enjoy it. I built it for the cases where it's a hassle: people who don't want to patch and babysit runners, or who hit limits like Codeberg's 10-minute cap. Out of curiosity, what's your setup, and is there anything about it you find annoying (caches, updates, Docker builds)?

1

u/ad-on-is 22d ago

dude, the entire selfhosting game is annoying 😂 but learning along the way is the fun part.

I could either continue using google photos, github, etc. and just deal with the fact that someone else is in control but also takes care that things work so I don't have to do anything... or... I can spend hours cursing and crying to figureout, how to make it work myself

1

u/alexdev-tb 21d ago

Nice! I’m not saying somebody else should be in control of your data and if you can do it yourself go for it! It’s just that other people that might not have the resources to run a self hosted runner could use mine and not spend all time renting a vps ans maintaining it.

2

u/NoInterest375 22d ago

Same for me, it juest works,, ok docker in docker had sone limitations or let say required bit more configuration, but after switch to vm it works flawlesly

1

u/nextized 22d ago

Thinking of writing a k8s operator to do ephemeral workers. Nothing concrete yet, but its on my todolist

1

u/alexdev-tb 21d ago

Nice! This post might help you avoid the same problems I had if you start developing it.

1

u/Someothernameforu 22d ago

Would love a k8s operator for Forgejo runners

1

u/Minimal-Matt 22d ago

Just out of curiosity, would this setup from Keda do what you would with the operator?
https://keda.sh/docs/2.19/scalers/forgejo/

in my mind since the runners are supposed to be ephemeral a scaled job like that would work, although it does depend on the keda operator and resources

1

u/Jmc_da_boss 21d ago

I use keda for this, very easy to set up

1

u/SerhiiCho 19d ago

Being able to have your own CI runners (similar to GitHub actions) is the best thing about Forgejo imo. I just love that 1 Orange pi can make it happen

-1

u/c0mndr 22d ago

I had the feeling this post is AI slopped, and https://www.pangram.com confirms, 100% AI slop. Would not use that service

1

u/alexdev-tb 21d ago

It looks like you are advertising that ai scanner service….. Plus I checked myself and it says it’s 55% not 100%…..

1

u/c0mndr 21d ago

Even Wikipedia uses Pangram to identify slop. But more interestingly, you did not deny…

1

u/alexdev-tb 21d ago edited 20d ago

My reply is a deny. Why would I bother and waste my time on something I myself know is not true? And I didn’t know Pangram was popular, it looked like you were advertising a service. That should serve as a sufficient answer no?