Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lahsivjar
Copy link
Contributor

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 current getRepoRoot 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 updated

How to test these changes

  1. cd systemtest
  2. go work init
  3. go work use <path_to_apm_tools>
  4. go work use .
  5. go test -v -count=1 ./...

Tests should pass without errors.

Related issues

N/A

@lahsivjar lahsivjar requested a review from a team as a code owner June 6, 2024 15:23
Copy link
Contributor

mergify bot commented Jun 6, 2024

This pull request does not have a backport label. Could you fix it @lahsivjar? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-7.17 is the label to automatically backport to the 7.17 branch.
  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Jun 6, 2024
@@ -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
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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.

@v1v v1v added the backport-8.x Automated backport to the 8.x branch with mergify label Sep 10, 2024
@mergify mergify bot removed the backport-skip Skip notification from the automated backport with mergify label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants