Skip to content

workflowfile: honour GH_ACTIONS_LOCK_REPO_ROOT for repo root discovery - #160

Merged
nodeselector merged 4 commits into
mainfrom
nodeselector-repo-root-env-override
Oct 12, 2026
Merged

nodeselector merged 4 commits into
mainfrom
nodeselector-repo-root-env-override

Conversation

@nodeselector

Copy link
Copy Markdown
Collaborator

Problem

Repo root discovery only walks up looking for .git. Callers relocking a partial checkout without .git fail on any $/ action with "not in a git repository" (exit 2), so workflows that use $/ can't be relocked there.

Fix

GH_ACTIONS_LOCK_REPO_ROOT names the root explicitly. An env var rather than a flag, so callers can set it unconditionally and older versions ignore it.

  • Every repo-root lookup honours it: $/ resolution, ./ composite discovery, migration, and the composite-file sweep.
  • It fails clearly if the directory doesn't exist or doesn't contain the workflow path, rather than resolving $/ against the wrong tree.
  • $/ paths stay bounded by it, same as the git root.
  • Documented under a new ENVIRONMENT section in --help.

Callers relocking a partial checkout without .git could not resolve $/
actions. The override must exist and contain the workflow path; $/
paths stay bounded by it like the git root.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 06:49
@nodeselector
nodeselector requested a review from a team as a code owner October 12, 2026 06:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Workflow symlinks can bypass the promised override containment check, and the unset-environment test is process-dependent.

2 open findings
What changed in this PR

Adds explicit repository-root discovery for partial checkouts through GH_ACTIONS_LOCK_REPO_ROOT.

Changes:

  • Applies the override to action resolution, migration, and composite discovery.
  • Validates override paths and documents the environment variable.
  • Adds unit and command-level coverage.
File Description
internal/​workflowfile/​workflowfile.go Implements override discovery and validation.
internal/​workflowfile/​workflowfile_test.go Tests override behavior and boundaries.
internal/​workflowfile/​rewrite.go Propagates discovery errors during migration.
cmd/​gh-actions-lock/​run.go Uses the override during migration sweeps.
cmd/​gh-actions-lock/​root.go Documents the environment variable.
cmd/​gh-actions-lock/​reporoot_test.go Adds command-level partial-checkout coverage.
cmd/​gh-actions-lock/​atomic_test.go Extracts shared HTTP test setup.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/gh-actions-lock/reporoot_test.go Outdated
Comment thread internal/workflowfile/workflowfile.go
@nodeselector
nodeselector merged commit 4d5f910 into main Oct 12, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants