-
Notifications
You must be signed in to change notification settings - Fork 525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[systemtest] Get repo root correctly with go workspaces #13355
base: main
Are you sure you want to change the base?
Conversation
This pull request does not have a backport label. Could you fix it @lahsivjar? 🙏
NOTE: |
@@ -199,7 +199,18 @@ func getRepoRoot() (string, error) { | |||
if err != nil { | |||
return "", err | |||
} | |||
repoRoot = filepath.Clean(strings.TrimSpace(string(output))) | |||
// When go workspaces is enabled then go list lists all the module paths in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would go list -f '{{.Module.Dir}}' .
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't use this because, IIANM, this will only work if we run the command in the same directory as the go.mod
file and I assumed that would not be desirable as in that case we could have used something like os.Getwd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Maybe we could use https://pkg.go.dev/runtime#Caller to locate the source code, and then the repo root relative to that. Not very robust to code changes/moving around, but I don't think that should happen often if at all.
Motivation/summary
Fixes the repo root resolution when go workspace is in use. In this case the command
go list -m
will list all the modules in use by the go workspace and the currentgetRepoRoot
cannot handle it correctly.The changes the PR proposes is also kinda hacky, happy to hear if others have a better solution to finding the repo root or fixing the issue.
Checklist
- [ ] Update CHANGELOG.asciidoc- [ ] Documentation has been updatedHow to test these changes
cd systemtest
go work init
go work use <path_to_apm_tools>
go work use .
go test -v -count=1 ./...
Tests should pass without errors.
Related issues
N/A