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

Migrate to multi-module project #1197

Closed
wants to merge 11 commits into from
Closed

Migrate to multi-module project #1197

wants to merge 11 commits into from

Conversation

jamietanna
Copy link
Member

@jamietanna jamietanna commented Aug 17, 2023

⚠️ FYI this PR is expected to be rebased, not squashed


As a path to making #1142 a little easier, we can introduce a multi-module project that can reduce the blast radius of some of our dependencies, as well as some internal refactoring to move tests closer to where they are in use.

Closes #1142.


⚠️ Example upgrade path: https://gitlab.com/tanna.dev/dependency-management-data/-/merge_requests/76

🛑 erroring

% go get github.com/deepmap/oapi-codegen@998945bc4d286acb496479194e581e29ce354e81
% go mod tidy                           
go: finding module for package github.com/deepmap/oapi-codegen/pkg/runtime                                      
dmd.tanna.dev/internal/endoflifedate/client imports  
        github.com/deepmap/oapi-codegen/pkg/runtime: package github.com/deepmap/oapi-codegen/pkg/runtime provided by github.com/deepmap/oapi-codegen at latest version v1.13.4 but not at required version v1.13.5-0.20230818153
008-998945bc4d28                                                      
go: github.com/deepmap/oapi-codegen@v0.0.0-00010101000000-000000000000: invalid version: unknown revision 000000000000

https://stackoverflow.com/questions/55041915/multiple-modules-within-the-same-project
https://go.dev/doc/tutorial/call-module-code


TODO:

  • Update to minimum of Go 1.20 #1184
  • Some internal tweaks to replace need dependency in pkg/codegen/codegen_test.go on examples
  • Some internal tweaks to replace need dependency in pkg/securityprovider/securityprovider_test.go on internal/test
  • Correctly build/lint/test in each of the modules
  • Remove echo etc from top-level go.mod
  • Determine why tidied doesn't work
  • Migrate runtime/strictmiddleware.go to its own separate thing, one-per-package

As part of #1142, we want to reduce the transitive dependencies of
oapi-codegen, which requires creating a multi-module Go project.

Before we can do this, we need to break some dependencies between
packages that don't make sense.
As part of #1142, we want to reduce the transitive dependencies of
oapi-codegen, which requires creating a multi-module Go project.

Before we can do this, we need to break some dependencies between
packages that don't make sense.
These appear to be existing issues with the code, but are only flagged
up once we migrate `examples` to its own Go module, so we can
preemptively fix them before hand.
As part of #1142, we want to reduce the transitive dependencies of
oapi-codegen, which we can start with by removing unnecessary
dependencies on `echo` from the `pkg/codegen` project.
As part of #1142, we want to reduce the transitive dependencies of
oapi-codegen, which requires creating a multi-module Go project.

Before we can do this, we can make sure that we have set up our Makefile
and `tidy` workflow to be module-aware via steps in [0].

[0]: https://www.jvt.me/posts/2023/08/18/go-multi-module-execute/
As part of #1142, we want to reduce the transitive dependencies of
oapi-codegen, which requires creating a multi-module Go project.

We can start with the `examples` project, which definitely shouldn't be
pulled by consumers.

The fake module version updates across all files due to the way that
multi-module Go projects work, but should be a one-time update.
As part of #1142, we want to reduce the transitive dependencies of
oapi-codegen, which requires creating a multi-module Go project.

We can split each of the middleware packages into their own modules,
allowing consumers to pull only the dependences they need.
As part of #1142, we want to reduce the transitive dependencies of
oapi-codegen, which requires creating a multi-module Go project.

We can migrate `internal/test` to its own module, as it shouldn't be
(nor could it be) pulled by consumers.

The fake module version updates across all files due to the way that
multi-module Go projects work, but should be a one-time update.
As part of #1142, we want to reduce the transitive dependencies of
oapi-codegen, which requires creating a multi-module Go project.

This migrates `pkg/runtime` which unfortunately is still a little
heavyweight due to `pkg/runtime/strictmiddleware.go`.
As part of #1142, we want to reduce the transitive dependencies of
oapi-codegen, which requires creating a multi-module Go project.

We can move `pkg/testutil` to alleviate any other dependencies the root
module has on web frameworks, and allow this to be used independently.
@jamietanna jamietanna added this to the v1.14.0 milestone Aug 23, 2023
@jamietanna
Copy link
Member Author

Closing in preference for #1206

@jamietanna jamietanna closed this Aug 28, 2023
@jamietanna jamietanna deleted the chore/multi-module branch August 29, 2023 15:02
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.

v1.13.0 introduces lots of transitive dependencies to client library
1 participant