Actions
Actions
go-vcs/actions is the GitHub Actions workflow engine, reusable without the forge. Its first release is v0.1.0: the expression evaluator, the workflow parser, the planner and the conformance module. The gitea-runner protocol server is not started.
| Part | State |
|---|---|
expr, the expression evaluator | available (#3, #7) |
workflow, the YAML parser | available (#4) |
plan, the planner (triggers, path filters, matrix, needs) | available (#5) |
conformance, against act v0.2.99 | available (#6) |
| gitea-runner protocol server | not started |
expr
github.com/go-vcs/actions/expr lexes, parses and evaluates the ${{ }}
language. Contexts are passed in as JSON-shaped values; hashFiles and the
status functions are interfaces the caller implements.
v, err := expr.Evaluate("contains(github.event.labels.*.name, 'bug') && matrix.os == 'linux'",
&expr.Env{Contexts: map[string]any{"github": ev, "matrix": m}})Every input has a bound, each proved by a test:
- One work budget per template, counted in bytes (16M units): every node visited and every byte hashed, compared, sorted or copied is charged, so a loop that allocates nothing is bounded too. A wall-clock deadline (2 s) stands behind it.
- Per-tenant caps on
hashFiles: a call that outlives the deadline is abandoned; once a tenant has 16 abandoned calls running, itshashFilesis refused until some return, with at most 64 calls in flight per tenant and 256 in flight process-wide. - Expression length 21000 bytes, AST depth 100, results 1 MiB,
fromJSONinput 64 KiB, templates 256 KiB and 256 expressions. - Errors name positions and tokens, never evaluated values, so a secret flowing through an expression cannot reach an error message.
The semantics follow the GitHub documentation; case folding is ASCII only (GitHub folds Unicode), which is a known difference.
workflow
github.com/go-vcs/actions/workflow turns a workflow file into typed Go
values: jobs, steps, matrix, events with their filters, containers, services
and reusable-workflow calls. Every ${{ }} is syntax-checked at parse time, and
a malformed one is refused with a line number before any run starts.
The parser is strict: unknown and duplicate keys, a second YAML document, a
step with both or neither of uses and run, an unknown or self needs, and
branches with branches-ignore are errors. Anchors, aliases and << are
supported, under bounds: 256 KiB of input, YAML depth 64, 100000 nodes counted
after alias expansion (a billion-laughs document is refused), 256 jobs, 1000
steps per job. A container’s password is redacted in every dump.
Both packages are fuzzed, with their corpus committed.
plan
github.com/go-vcs/actions/plan decides what a parsed workflow does for an
event and in which order, and runs nothing.
pl := plan.New(w, plan.Options{Contexts: ctxs, Mask: []string{token}})
ev := plan.Event{Name: "push", Ref: "refs/heads/main", Files: changed}
m := plan.NewEventMeter(ev, pl) // one meter per event
defer m.Close()
ok, err := pl.MatchesIn(m, ev)
err = pl.Resolve()- Path filters.
branches,tags, their-ignoreforms,paths, activitytypes,scheduleandworkflow_dispatchinputs are applied. The glob syntax is GitHub’s (*,**,?,+,[...],!negation, last match wins), matched without unbounded backtracking: a literal prefix and suffix reject first, one kind of star runs a single-restart star loop, and anything else a linear table. A[...]class is compiled to a 256-bit set and holds ASCII only. - One meter per event. The work of an event is counted once, whatever the
number of workflows on it (
EventMeter): 1 MiB plus 256 units a byte of event and workflow, never more than 2^28 units, about 0.8 s of one core. An ordinary push of 200 patterns and 3000 files costs a few thousand units (8.6 ms when every file is read). Matching without a meter is an error. - Fail toward run. What exceeds the meter is refused with
ErrBudget, never read as “no match”. Above 3000 changed files GitHub cuts the diff, so the filter is taken as matched and the workflow runs: a skip on a list we hold whole would be silent. - Limits. Each plan has one work budget (16M units) shared by matching,
matrix expansion and
if:. At most 256 combinations per matrix and 4096 job instances; a pattern is 1024 bytes and a subject 4096. A matrix that readsneedsoutputs is returnedDeferredand expanded again once they are known. Thesecretscontext is never read, and masked values are replaced by***in every evaluated string.
Jobs are ordered by needs (a cycle is named, ties keep declaration order).
conformance/ is a nested module that checks 138 expressions and 400 real
workflow files against act v0.2.99, so act never reaches a user of the library.