Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
james00012 wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromfeature/complete-modularization

Conversation

@james00012
Copy link
Contributor

@james00012james00012 commentedDec 1, 2025
edited
Loading

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:

  • Split monolithic module into 27 independent modules undermodules/
  • Each module has its owngo.mod with explicit dependencies
  • Addedgo.work for workspace-based development
  • Updated CI configuration for modular structure:
    • Pinned goimports to v0.21.0 (avoids Go 1.24.0 requirement)
    • Replacedgo mod tidy withgo work sync
    • Updated test commands to work with Go workspaces
  • Refactored CLI tools (cmd/pick-instance-type,cmd/terratest_log_parser):
    • Removedgo-commons/entrypoint dependency in favor of directurfave/cli/v2
    • Replacedgo-commons/logging with directlogrus usage
    • Reduces transitive dependencies for standalone binaries
  • Fixed Azure module: updatedresourcegroup.go import to useprofiles/latest for compatibility
  • AddedMIGRATION.md with upgrade instructions

Modules:

  • Tier 0 (no deps): collections, testing
  • Tier 1 (minimal deps): logger, random, retry, shell, files, environment, git
  • Tier 2: ssh, http-helper, dns-helper, oci, opa, packer, docker, database, slack
  • Tier 3: terraform, terragrunt, aws, azure, gcp, k8s, helm, test-structure, version-checker

Breaking Changes:

  • Rootgo.mod removed - users must import specific submodules
  • SeeMIGRATION.md for upgrade instructions

Test plan

  • CircleCI passes all tests
  • Verify modules can be imported independently
  • Test consumer simulation passes

@james00012james00012force-pushed thefeature/complete-modularization branch from01569bf to387d9caCompareDecember 1, 2025 15:41
@james00012james00012 marked this pull request as draftDecember 3, 2025 16:47
@james00012james00012force-pushed thefeature/complete-modularization branch 5 times, most recently fromd21d2f6 to8870a1aCompareDecember 8, 2025 01:47
This PR restructures Terratest from a monolithic module into 27 independentGo modules, enabling users to import only the specific functionality they need.Key changes:- Create separate go.mod files for each module in modules/- Add go.work workspace file to coordinate local development- Update CI to build and test modules in workspace mode- Add GitHub Action workflow for auto-tagging module releases- Fix Azure module dependencies and import compatibilityBenefits:- Reduced dependency footprint for users importing specific modules- Independent versioning capability for each module- Faster builds when only specific modules are needed- Better separation of concerns
@james00012james00012force-pushed thefeature/complete-modularization branch from8870a1a to7c213f5CompareDecember 8, 2025 02:51
@james00012james00012 marked this pull request as ready for reviewDecember 8, 2025 03:06
- Update internal module dependencies to v1.0.0- Simplify MIGRATION.md- Add GH_TOKEN docs to release workflow- Expand consumer test coverage- Remove unused replace directives
Copy link

@ThisGuyCodesThisGuyCodes left a comment

Choose a reason for hiding this comment

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

I consider this command:

go get github.com/gruntwork-io/terratest

as part of the API. Causing this command to break existing users will cause a ton of friction and frustration. We should lean into ecosystem conventions here and version the module import path.

It may seem like we need to make a new directory + copy everything, keeping both in the repo, but the only reasonthis is recommended is to support non-module-aware go tooling (the post linked is from 2019); afaik we have no intention of supporting non-module-aware tooling as all of that is way out of official support at this point.

First we need to decide if we're going to version each module independently (in which case we also need to be really careful about never letting module A return non-interface types from module B), or version all of Terratest together (this is what I would advocate for).

Then we place a major version number in the module directive in eachgo.mod file. Typically this is placed at the end:

module github.com/gruntwork-io/terratest/modules/aws/v1

the barego get command (without the version suffix) will continue to pull the latestv0.x.x tag, allowing us to even branch + release bug fixes for old versions. And so long as we tag the/v1 suffixed modules withv1.x.x thengo get github.com/gruntwork-io/terratest/modules/aws/v1 will continue to work when we release a/v2 etc.

if [[ "${{ github.event_name }}" == "release" ]]; then
# Extract version from release tag (remove 'v' prefix if present)
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"

Choose a reason for hiding this comment

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

we have control over this input; validation is great to ensure consistency, but I'd argue we should avoid "auto fixing" incorrect inputs.

If we don't want the v, then we shouldn't put the v in the release name, instead of auto-stripping it.

go 1.24.0

replace (
github.com/gruntwork-io/terratest/modules/aws => ../../modules/aws

Choose a reason for hiding this comment

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

this can create a weird situation when we start thinking about future breaking changes.

If we treat the whole of terratest as having one "version", then this is fine. If we want to version each module individually, then this can easily create situations wherepick-instance-type/v2 usesaws/v3 but the customer is usingaws/v2, and thus types will be incompatible.

In fact since replace directives only affect the main go.mod file (not things which import it), this may not even be doing what you think it is. Thego.work file does this for local development.


**Before:**
```bash
go get github.com/gruntwork-io/terratest

Choose a reason for hiding this comment

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

I feel strongly that this command needs to continue to work for existing users.

The accepted way to do breaking changes is to add a version suffix to the import path. You don't have to do this with a new directory, you can just change the module declaration ingo.mod:

module github.com/gruntwork-io/terratest/v1

And make sure you tag appropriately.

Go tooling will allow the non-suffix'dgo get command to continue to work, by pulling the latestv0.x.x tag. New users (or folks who want to upgrade) would run:

go get github.com/gruntwork-io/terratest/v1

And they'll get the latestv1.x.x version that's tagged.

This is where we need to decide if we're versioning each module individually (in which case we also need to bereally careful about never letting module A return non-interface types from module B), or version all of Terratest together (this is what I would advocate for).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ThisGuyCodesThisGuyCodesThisGuyCodes requested changes

@denis256denis256Awaiting requested review from denis256denis256 is a code owner

@yhakbaryhakbarAwaiting requested review from yhakbaryhakbar is a code owner

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@james00012@ThisGuyCodes

[8]ページ先頭

©2009-2025 Movatter.jp