-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Modularize Terratest into 27 independent modules #1632
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
Draft
james00012
wants to merge
11
commits into
main
Choose a base branch
from
feature/complete-modularization
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+2,959
−310
Conversation
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
01569bf to
387d9ca
Compare
Implements complete modularization with no root go.mod, eliminating dependency bloat and fixing ambiguous import errors. Fixes #1613 - Remove root go.mod - Add go.work workspace for local development - Create go.mod for each of 27 modules + internal/lib - Comprehensive test suite in test/modularization/ - Documentation in MODULARIZATION.md **Before:** Importing any module pulls entire ~50MB library with all cloud SDKs **After:** Import only what you need (~5MB for terraform module) - **No ambiguous imports** - Each package has exactly one source - **Reduced dependencies** - Import only needed modules - **Independent versioning** - Each module versions separately - **Cleaner dependency graphs** - No hidden transitive deps from root ```go import "github.com/gruntwork-io/terratest/modules/terraform" ``` ```go require github.com/gruntwork-io/terratest/modules/terraform v0.1.0 ``` No replace directives needed - Go fetches from GitHub tags automatically. ```bash cd test/modularization go test -v ./... ``` Tests validate: - Dependency isolation - No ambiguous imports - All modules build independently - Workspace builds successfully No breaking changes - import paths stay the same. Consumers automatically pull only needed modules instead of everything.
When a GitHub release is published, this workflow automatically creates tags for all 27 submodules in the format `modules/<name>/v<version>`. This enables Go's module system to resolve submodule versions correctly, allowing users to import specific modules: go get github.com/gruntwork-io/terratest/modules/[email protected] Features: - Triggers automatically on release publish - Can also be triggered manually for testing/re-running - Skips tags that already exist - Validates version format (X.Y.Z or X.Y.Z-suffix)
Add permissions.contents: write and explicit token to allow the workflow to push tags to the repository.
Change from GITHUB_TOKEN to GH_TOKEN for pushing submodule tags.
Instead of hardcoding module list, dynamically find all go.mod files. This way new modules are automatically tagged without workflow changes. Excludes: - Root go.mod - Test directories (test/*)
Update all internal module dependencies to v0.55.0 to match the upcoming release version.
- Pin goimports to v0.21.0 to avoid Go 1.24.0 requirement - Replace go mod tidy with go work sync for workspace compatibility - Add missing dependencies to all modules: - aws: AWS SDK v2 - database: mssql, mysql, pq drivers - docker: gotest.tools - gcp: Google Cloud SDK, go-containerregistry - helm: k8s client-go, ytbx, dyff - k8s: client-go, apimachinery - logger: junit-report, logrus - slack: slack-go - terraform: HCL, terraform-json, copier, hcl2json - test-structure: go-commons Note: Azure module has a code issue with deprecated SDK package (services/preview/sql/mgmt/v3.0/sql) that needs separate fix.
- Add cmd/terratest_log_parser and cmd/pick-instance-type to go.work - Create go.mod files for both cmd packages with proper replace directives - Update cmd packages to use urfave/cli/v2 (breaking change from v1) - Fix logger module to depend on local modules instead of monolithic terratest - Add exclude directives to prevent ambiguous imports from go-commons This fixes the CI build error: "current directory outside modules listed in go.work or their selected dependencies"
…ility The build-go-binaries helper from gruntwork-module-circleci-helpers doesn't work with Go workspaces. Replace it with direct go build commands that properly build from the workspace context.
af54abe to
0afdaf8
Compare
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.
Summary
This PR modularizes Terratest into 27 independent Go modules, enabling users to import only the modules they need without pulling in unnecessary dependencies.
Changes:
modules/go.modwith explicit dependenciesgo.workfor workspace-based developmentgo mod tidywithgo work syncModules:
Known Issues:
services/preview/sql/mgmt/v3.0/sql) that needs separate fixTest plan