feat(go-ci): support private Go module dependencies - #6
Closed
juicycleff wants to merge 1 commit into
Closed
Conversation
A repo whose go.mod requires a private repo in this org has had no way to make go-ci.yml resolve it. A caller can't inject a step into a reusable workflow's jobs, so nothing on the consumer's side could fix this. This just bit a newly published module that depends on a private sibling repo. Add an optional XRAPH_REPO_TOKEN secret and a "Configure Go module auth" step in test, lint, verify and security, run before each job's Set up Go. The step is a no-op when the secret is unset, so every existing caller keeps working exactly as before. GOPRIVATE defaults to github.com/xraph/* and is now an input too, so a caller can override it if it ever needs to.
Contributor
Author
|
Closing as a duplicate. #5 landed the same capability first and did it better: it documents that the GOPRIVATE glob also sets GONOPROXY, so a broad glob drags public modules off the proxy into a full git clone per job. v1 already points at that commit, so nothing here is needed. Keeping the note about callers for whoever hits this next: a caller using |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
go-ci.ymlhad no path for a private intra-org Go module dependency. Theworkflow_call.secretsblock only declaredCODECOV_TOKEN, and nothing inthe file set
GOPRIVATEor aninsteadOfrewrite. A caller can't inject astep into a reusable workflow's own jobs, so no amount of work on the
consumer's side could fix this. It just bit a newly published module that
depends on a private repo in the same org, and its CI can't fetch that
dependency.
This adds an optional
XRAPH_REPO_TOKENsecret and a "Configure Go moduleauth" step that runs before each job's
Set up Gostep. When the secret isset, it rewrites
github.com/URLs to authenticate with the token and setsGOPRIVATE. When it isn't, the step does nothing.No-op for existing callers
XRAPH_REPO_TOKENisrequired: falseand every existing caller leaves itunset. With it unset, the new step's
if [ -n "..." ]guard is false, so thestep runs and exits clean without touching
git configorGOPRIVATE. Noexisting caller changes behavior.
Which jobs gained the step
test,lint,verifyandsecurity. I checked the other two jobs in thefile:
setupnever checks out the repo or runsgo, so it doesn't need it,and
nested-modulesonly runsgo mod edit -jsonagainst localgo.modfiles plus a direct proxy.golang.org lookup, neither of which resolves the
repo's own dependency graph, so it doesn't need it either.
Using it
If your workflow already uses
secrets: inherit, you get this for free anddon't need to touch anything. If you pass secrets explicitly, the way the
README recommends, add the
XRAPH_REPO_TOKENline yourself or your callerkeeps failing on the private dependency with no warning that a fix exists.
GOPRIVATEdefaults togithub.com/xraph/*, now exposed as theprivate-module-patterninput rather than hardcoded, since a value a callercan see and override beats one buried in a shell script.
v1 is a moving tag
Merging this and re-pointing
v1propagates to every repo in the orgimmediately. I'm not moving the tag or merging this myself, that's on you.
Verified
actionlintpasses clean on the file.step's body never executes, and
set -euo pipefaildoesn't turn that intoa failure.
passes, only that the change parses and reads as inert for existing
callers.