Skip to content

fix: resolve container: ${{ matrix.container }} map indirection instead of stringifying to "Object"#6112

Open
elijahr wants to merge 5 commits into
nektos:masterfrom
axiomantic:fix/matrix-container-indirection
Open

fix: resolve container: ${{ matrix.container }} map indirection instead of stringifying to "Object"#6112
elijahr wants to merge 5 commits into
nektos:masterfrom
axiomantic:fix/matrix-container-indirection

Conversation

@elijahr

@elijahr elijahr commented Jun 11, 2026

Copy link
Copy Markdown

container: ${{ matrix.container }} at the job level, where each matrix entry supplies a container: map, was stringified to the literal "Object" — act tried to pull library/Object instead of the map's image. The container field was decoded before the matrix expression was evaluated, so the map structure was lost.

This resolves the container per job-run: it deep-copies the raw container: node, evaluates the copy with act's type-preserving evaluator (the same one runs-on uses), then decodes it — so ${{ matrix.container }} becomes the actual map with its image and sibling fields (env, options, ports, etc.). Plain-string containers, embedded expressions, and jobs with no container behave exactly as before. The deep copy is deliberate: the job is shared across matrix cells that run in parallel, so mutating it in place would leak the container between cells and race.

Added regression tests in run_context_test.go, including a parallel-cells -race test that guards cross-cell leakage.

elijahr added 5 commits June 11, 2026 01:08
Extract the scalar-vs-mapping decode switch from Job.Container() into an
exported model.DecodeContainerNode(*yaml.Node) *ContainerSpec so the runner's
per-RunContext container resolver can decode an evaluated node with
byte-identical semantics. Job.Container() now delegates to it.

Semantics are preserved exactly: empty scalar -> &ContainerSpec{Image:""}
(not nil); decode error -> OnDecodeNodeError (fatal by default) -> nil;
nil/zero node -> nil (host execution).
A job-level `container: ${{ matrix.container }}` where each matrix cell
supplies a container MAP was stringified to the literal "Object" (pulling
docker.io/library/Object), because Job.Container() decoded the unevaluated
scalar and Interpolate's forceFormat=true coerced the map to "Object".

Add a per-RunContext resolveJobContainer(ctx) that deep-copies the shared
RawContainer yaml.Node, evaluates the COPY with the type-preserving
EvaluateYamlNode (forceFormat=false), and decodes via the shared
model.DecodeContainerNode helper. The result is memoized on a new
resolvedJobContainer field. All five .Container() consumers (containerImage,
options, GetBindsAndMounts, handleCredentials, mergeEnv) route through the
resolver; GetBindsAndMounts gains a ctx parameter threaded from its three
production callers.

The shared *Job is NEVER mutated: cells run in parallel and share one *Job
pointer, so in-place evaluation would leak across cells and race. Deep-copy +
per-RunContext memo make resolution race-free by construction. When ExprEval
is nil (a consumer reached before startJob sets it, or the bare-RC unit
harness), the resolver falls back to a pure decode of the un-evaluated node,
exactly reproducing the prior Job.Container() behavior.

Tests: TestResolveJobContainer covers the distinct-image leak guard,
sibling-field preservation, undefined-matrix host fallback (pinned to the
observed empty-image-no-error branch), plain-string back-compat, nested-expr
recursion, and nil-ExprEval pure-decode. TestResolveJobContainer_ParallelCells
NoLeak proves race-freedom under -race. A Docker-guarded matrix-container
integration fixture is added to the TestRunEvent table.
Addresses review feedback: defensive nil checks for rc.Run/job and nil-safe deepCopyYamlNode.
…terpolation

Addresses review feedback: memoize the resolved container only when ExprEval is set (avoids caching an un-evaluated spec), and remove the redundant, nil-unsafe Interpolate calls in containerImage/options since resolveJobContainer already fully evaluates the node.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant