Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

A free and open-source forge that lives in your Git repo.

Phase 4 slice 2: the queue and the runner

b44cbfaf873fda01a458b527e5684b2386266117 · Keenan Nemetz · 18d ago · parent 8fe238d4

Phase 4 slice 2: the queue and the runner

A push now runs a pipeline. post-receive spools one file per accepted ref update —
the hook must never write to a database or fail a commit — and the server ingests
those into data/runs.db, pinning each run to the commit and to the workflow blob it
was queued from. The unique index on (repo, ref, sha, workflow, job) is what makes
ingestion idempotent, so a spool file read twice after a crash does not run twice.

vole runner connects over SSH with the key it would push with: no token, no stored
secret, and the same identity the rest of the system uses. It may only run jobs for
repositories where its account is an admin, because running a job executes that
repository's code — a bigger power than writing to it.

Delivery is at-least-once by construction:

- A lease hands out a job for a fixed window; the runner heartbeats while it works.
- An expired lease means the runner died, and the janitor returns the job to the
  queue for somebody else.
- A runner whose lease is gone stops rather than reporting a result nobody will
  record, and a job that kills five runners in a row is failed instead of cycling.

Three bugs found while building it, each worth the test that now covers it:

- Background loops lived in Run(), so the tests — which serve the SSH listener
  themselves — never had ingestion or lease expiry. They start in New() now.
- post-receive derived the repository name from GIT_DIR, which git sets to "." for
  hooks, so every event was queued for a repository called ".". The same trap had
  already appeared in a pre-receive message; both now resolve the absolute path.
- Leases ordered only by creation time, so two pushes in the same second could be
  handed out in any order; the id breaks the tie, and ULIDs sort by time.

Verified end to end on a live instance: a push queues a job, a runner leases it,
clones the commit, prints "hi", and the run closes success with the log attached.
The integration tests cover the two exit criteria that matter — a push runs a
pipeline, and killing a runner mid-job requeues the work onto a second runner
(attempts=2, success) — plus the property that editing a workflow after a push does
not change what the already-queued run executes.

Not built yet: statuses on change requests and required-check gating (slice 3), and
signed run records (Phase 7). Runs live in data/runs.db and are visible there, not
on the web.

internal/repo/repo.go +11−4

@@ -263,10 +263,17 @@ func (s *Store) InstallHooks(dir string) error {
263 263 if err := os.MkdirAll(hookDir, 0o755); err != nil {
264 264 return err
265 265 }
266 body := "#!/bin/sh\n# Generated by Vole. Do not edit: rewritten on startup.\nexec " +
267 shellQuote(s.BinPath) + " hook pre-receive\n"
268 p := filepath.Join(hookDir, "pre-receive")
269 return os.WriteFile(p, []byte(body), 0o755)
266 // pre-receive is the policy gate; post-receive only queues CI, so it runs after
267 // the refs have moved and can never reject a push.
268 for _, hook := range []string{"pre-receive", "post-receive"} {
269 body := "#!/bin/sh\n# Generated by Vole. Do not edit: rewritten on startup.\nexec " +
270 shellQuote(s.BinPath) + " hook " + hook + "\n"
271 p := filepath.Join(hookDir, hook)
272 if err := os.WriteFile(p, []byte(body), 0o755); err != nil {
273 return err
274 }
275 }
276 return nil
270 277 }
271 278
272 279 func (s *Store) InstallAllHooks() (int, error) {