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

Hack: go.work support with one-caveat (dependency bleed) #1

Closed
wants to merge 4 commits into from

Conversation

stefanpenner
Copy link
Owner

@stefanpenner stefanpenner commented Jan 4, 2024

TODO: Basically everything beyond proof of concept

  • test in more complex situations
  • add tests which at-least matching existing go.mod level of tests
  • detect and error with useful messages when dependencies are out of sync

Up next:

  • explore options to avoid "dependency bleed" problem effecting our users
  • if all that testing and experimenting pans out, actually productionize this
    • proper tests
    • polish polish
    • work with gazelle forks to understand a path forward off this fork.

@stefanpenner stefanpenner force-pushed the hack-duplicate-go-deps-from-file branch from 519a434 to 907af59 Compare January 4, 2024 23:56
@stefanpenner stefanpenner changed the title Hack: Allow duplicate calls to go_deps.from_file Hack: go.work support with mega-caveats Jan 4, 2024
@stefanpenner stefanpenner force-pushed the hack-duplicate-go-deps-from-file branch 2 times, most recently from 0348aa7 to 4a351bb Compare January 5, 2024 23:14
@stefanpenner stefanpenner force-pushed the hack-duplicate-go-deps-from-file branch 3 times, most recently from fd29820 to 39fb524 Compare January 19, 2024 20:49
@stefanpenner stefanpenner changed the title Hack: go.work support with mega-caveats Hack: go.work support with one-caveat (dependency bleed) Jan 22, 2024
@stefanpenner stefanpenner force-pushed the hack-duplicate-go-deps-from-file branch from 39fb524 to 1ae9e29 Compare January 22, 2024 17:36
MODULE.bazel Outdated
@@ -48,15 +48,11 @@ use_repo(
"org_golang_x_tools_go_vcs",
# Referenced by `gazelle_binary`.
"bazel_gazelle_go_repository_config",
# Dependencies of rules_go that require special handling in go_deps.
Copy link
Owner Author

Choose a reason for hiding this comment

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

Probably shouldn't remove these

@stefanpenner stefanpenner marked this pull request as draft January 24, 2024 23:24
from_file_tags = []
go_works = []
module_tag_path_to_label = {}

for from_file_tag in module.tags.from_file:
Copy link
Owner Author

Choose a reason for hiding this comment

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

let's leave ourselves and future travelers a nice comment here, describing what is happening and why.

@stefanpenner stefanpenner force-pushed the hack-duplicate-go-deps-from-file branch 9 times, most recently from 82b70b3 to f7a7d32 Compare February 8, 2024 17:30
@stefanpenner stefanpenner force-pushed the hack-duplicate-go-deps-from-file branch 4 times, most recently from a869982 to 30af2af Compare February 15, 2024 21:59
@stefanpenner stefanpenner force-pushed the hack-duplicate-go-deps-from-file branch from 30af2af to dc31480 Compare February 15, 2024 21:59
Caveats:
* allows for dependency bleed between different go modules in the workspace - this is sorta by design for this stepping stone, but is far from ideal
* doesn't support replace statements in go.work yet (but that shouldn't be to hard to add)

continue the megahack experiment: handle replace in go.work

Lets provide a warning if differing versions are discovered

Improve duplicate Version Warning Message

* include both core + meta version segments in warning. 0.0.0 vs 0.0.0 isn't useful
* include label were offending versions reside

ensure error message is valid for all three scenarios

1) if external dependencies are out of sync, and something go work sync can handle, inform the user to run `go work sync`
2) if in-repo dependencies managed by go.work are out of sync inform the user to manually correct
3) if external dependencies have the same core version, but a different meta version tell the user to manually correct

transition warning to error and touchup message

Add tests for handling go.work files

These tests aren't exhaustive, but they match the testing done for go.mod
files. In the future, it would likely be good to add additional more
comprehensive tests.
@stefanpenner stefanpenner force-pushed the hack-duplicate-go-deps-from-file branch from dc31480 to d0dc074 Compare February 15, 2024 22:19
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.

4 participants