Skip to content

fix(runner): include the workdir in the job container name - #6259

Open
njarrar wants to merge 1 commit into
nektos:mainfrom
njarrar:fix/reuse-container-name-per-repo
Open

njarrar wants to merge 1 commit into
nektos:mainfrom
njarrar:fix/reuse-container-name-per-repo

Conversation

@njarrar

@njarrar njarrar commented Nov 16, 2026 •

Copy link
Copy Markdown

Fixes #6258

The job container name was built only from the workflow and job names, so with --reuse two repositories that use the same workflow and job names got the same container and volumes. The second run then failed with a chdir error into the first repository's workdir.

This adds a short hash of the workdir to the job container name (option 1 from the issue). The name is still repeatable for the same repository, so --reuse keeps working. Existing retained containers get a new name once after upgrading.

Description

Checklist

  • Linked issue (for example, fixes #123)
  • Tests added or updated, or an explanation of why tests are not needed
  • Description above explains the change

Summary by CodeRabbit

  • New Features
    • Job container names now reflect the configured working directory, while remaining consistent for repeated runs in the same directory.
  • Tests
    • Added coverage to verify that names differ across working directories and remain repeatable for the same one.

Jobs with the same workflow and job names in different repositories got
the same container name, so --reuse handed one repository's retained
container and volumes to another. Add a short hash of the workdir to the
name so it stays repeatable per repository.

Fixes nektos#6258
@njarrar
njarrar requested a review from a team as a code owner November 16, 2026 16:03
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Job container names now include the first four bytes of the configured work directory’s SHA-256 hash when the work directory is nonempty. A test checks that different work directories produce different names and repeated calls for the same work directory produce the same name.

Changes: Job container names

Layer / File(s) Summary
Workdir-based naming and validation
pkg/runner/run_context.go, pkg/runner/run_context_test.go
When the configured work directory is nonempty, jobContainerName adds its hash to the name. The test checks name differentiation and repeatability.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • nektos/act#6062: This PR also changes job container naming to address collisions affecting --reuse.

Suggested reviewers: cplee

Merge Risk: Minimal · up to e32b4

Job container names now include a short hash of the work directory. Repositories with matching workflow and job names therefore stop sharing retained containers under --reuse. Names stay stable across runs for the same directory. Existing retained containers are renamed once after upgrade. No concrete merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the primary change: the job container name now includes the workdir. It matches the raw summary, which says the workdir hash is added to the container name. The title uses the conventi…
Description check Passed The description states the problem: with --reuse, repositories sharing workflow and job names got the same job container and volumes, causing a chdir failure. It states the fix (a short workdir hash i…
Linked Issues check Passed [#6258] The objective is to keep --reuse job containers and volumes from being shared across repositories with matching workflow and job names, while keeping names repeatable. At head, `RunContext.j…
Out of Scope Changes check Passed The whole-PR change set, per the summary, touches only pkg/runner/run_context.go (the jobContainerName function) and pkg/runner/run_context_test.go (one added test). The function change is the d…
Full details: Title check

Explanation

The title names the primary change: the job container name now includes the workdir. It matches the raw summary, which says the workdir hash is added to the container name. The title uses the conventional fix(runner) prefix and is specific, so it passes.

Full details: Description check

Explanation

The description states the problem: with --reuse, repositories sharing workflow and job names got the same job container and volumes, causing a chdir failure. It states the fix (a short workdir hash in the container name), links issue #6258 via 'Fixes #6258', and notes the one-time rename of retained containers after upgrade. The template sections are present. The checklist items are unticked, and the template's placeholder comment is left in place. The test checklist item is not marked, though the summary shows a new test was added. These gaps are minor, so the check passes.

Full details: Linked Issues check

Explanation

[#6258] The objective is to keep --reuse job containers and volumes from being shared across repositories with matching workflow and job names, while keeping names repeatable. At head, RunContext.jobContainerName() in pkg/runner/run_context.go appends the first 4 bytes of the SHA-256 of Config.Workdir (hex-encoded) to the existing act plus rc.String() parts when Workdir is nonempty. Different workdirs therefore produce different job container names. The same workdir produces the same name, so reuse still works. The job volume names (name, name-env) and service container and network names are all derived from jobContainerName(), so they also differ per repository. The issue's suggested repository-root hash approach is implemented on the workdir, which act sets to the repository path. The new test TestJobContainerNameDependsOnWorkdir is described in the summary. Its body was not read because the test file was truncated, so its exact assertions are not verified. The implementation evidence alone establishes the behavior.

Full details: Out of Scope Changes check

Explanation

The whole-PR change set, per the summary, touches only pkg/runner/run_context.go (the jobContainerName function) and pkg/runner/run_context_test.go (one added test). The function change is the direct implementation of #6258. The test supports that change. The one-time container rename for existing retained containers is a consequence of the naming change that the PR description states. No unrelated changes were identified. The base-side diff could not be read because changed blobs were unavailable, so this verdict relies on the head file content and the PR summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: nektos/act
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: ac4c099
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a771653b-e309-472f-8aec-075b0cb16e69
Commits

Reviewing files that changed from the base of the PR and between ac4c099 and e32b4b9.

Files selected for processing: 2

  • pkg/runner/run_context.go
  • pkg/runner/run_context_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
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.

Title: --reuse shares job containers between different repositories that use the same workflow and job names

1 participant