Modularize Terratest into 27 independent modules #1628
Closed
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 converts Terratest from a monolithic Go module into 28 independent submodules, allowing users to import only the modules they need without pulling in unnecessary dependencies.
Changes
modules/andinternal/go.work) for local developmentBackward Compatibility Testing
Extensive testing was performed using a fork repository (james00012/terratest-modularization-test) to validate backward compatibility:
1. Consumer Simulation Test
Created an external project importing 13+ modules simultaneously:
modules/terraform,modules/terragrunt,modules/aws,modules/k8s,modules/docker,modules/helm,modules/collections,modules/random,modules/logger,modules/shell,modules/retry,modules/files,modules/environmentResult: PASS - No ambiguous import errors
2. Backward Compatibility Tests
Validated that existing user code works without modification:
terraform.Options{},terraform.Init,terraform.Applyaws.GetRandomRegion,aws.CreateS3Bucketk8s.KubectlOptions{},k8s.GetPoddocker.Options{},docker.Build,docker.Runhelm.Options{},helm.InstallMigration for Users
No changes required. Existing import paths continue to work:
Release Process
A new GitHub Action (
.github/workflows/release-modules.yml) handles submodule tagging:How It Works
v0.55.0) through the GitHub UI or APIgo.modfiles (excludes root and test directories)modules/terraform/v0.55.0modules/aws/v0.55.0modules/k8s/v0.55.0Setup Required
Add
GH_TOKENas a repository secret:GH_TOKENcontents: writepermissionManual Trigger
The workflow can also be triggered manually:
0.55.0)Auto-Discovery
The workflow automatically discovers modules - no need to update the workflow when adding new modules:
Why Submodule Tags?
Go modules require tags in the format
<path>/v<version>for submodules. Without these tags, users cannot pin specific versions:Tested On Fork
The workflow was tested on james00012/terratest-modularization-test:
Benefits
Test plan
GH_TOKENsecret after merge