Skip to content

Commit 1e0fe58

Browse files
authored
refactor: implement terraform module dependency parser and enhance type system (#220)
* refactor: reorganize type system into dedicated files - Move types from index.ts to dedicated type files for better organization - Create common.types.ts for shared interfaces like ModuleInfo and ChangeInfo - Create config.types.ts for configuration-related types - Create context.types.ts for workspace context types - Create github.types.ts for GitHub API related types - Create wiki.types.ts for wiki-specific types - Create node-child-process.types.ts for Node.js process types - Update index.ts to re-export all types from dedicated files This refactoring improves code organization and makes types easier to maintain. * feat: add dedicated terraform module parser and enhance module class - Add new parser.ts with comprehensive Terraform module parsing capabilities - Implement buildModuleDependencyGraph() for tracking local module dependencies - Add getModulesToRelease() to determine release propagation based on dependencies - Enhance TerraformModule class with better change detection and release logic - Add comprehensive test coverage for parser functionality - Add test helpers for terraform module testing - Improve module name normalization and path handling This establishes a solid foundation for dependency-aware module releases and better change detection across the Terraform module ecosystem. * refactor: enhance core functionality and remove deprecated utilities - Update main.ts to use new parser and enhanced module handling - Improve configuration handling with better type safety - Enhance changelog generation with dependency-aware logic - Update pull request commenting with better module information - Improve release and tag management with new module system - Update terraform-docs integration to work with enhanced modules - Enhance wiki functionality with better module organization - Remove deprecated semver utilities in favor of built-in logic - Add new constants and improve file utility functions These changes integrate the new parser system throughout the codebase and improve the overall reliability and maintainability of the action. * test: comprehensive test suite updates and improvements - Update changelog tests to work with new module system and dependency tracking - Enhance main.ts tests with better coverage of module parsing and release logic - Improve pull request tests with dependency-aware scenarios - Update release and tag management tests for new module handling - Enhance terraform-docs tests with improved module integration - Significantly expand terraform-module tests with comprehensive coverage - Update wiki tests for new module organization and dependency features - Improve utility tests and remove deprecated semver test file - Add better test fixtures and mocking for complex scenarios These test updates ensure comprehensive coverage of the refactored codebase and provide confidence in the new dependency-aware release system. * chore: update configuration and add development tooling - Update action.yml with new input parameters and improved documentation - Update package.json with new development scripts and dependencies - Enhance TypeScript configuration for better type checking - Update .gitignore with additional patterns for development files - Add development scripts for parsing modules and testing workflows - Add test terraform modules (animal, zoo) for comprehensive testing scenarios - Update package-lock.json with new dependency versions These changes improve the development experience and provide better tooling for testing and maintaining the terraform module release system. * refactor: enhance version tag handling and validation in TerraformModule * refactor: optimize logging of parsed Terraform modules in parseTerraformModules function * refactor: make _commits property readonly to prevent unintended modifications * refactor: improve release and tag deletion comments for clarity and consistency * refactor: avoid mutating input by creating copies of tags and releases before sorting * refactor: consolidate import statements for wiki-related constants * refactor: remove commented-out code for local dependency updates in getReleaseReasons method * refactor: introduce MODULE_TAG_REGEX for improved tag parsing in TerraformModule * refactor: update output keys in CI workflow and README for consistency; enhance action output handling in main.ts
1 parent 73b9330 commit 1e0fe58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+6979
-2436
lines changed

.github/linters/.markdown-lint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ MD030:
2121
MD033:
2222
allowed_elements:
2323
- sup
24+
- sub
25+
- br
2426
- b
2527
- p
2628
- img

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
(to_entries[] |
8181
"• \(.key):",
8282
" - Path: \(.value.path)",
83-
" - Current Tag: \(.value.currentTag)",
83+
" - Latest Tag: \(.value.latestTag)",
8484
" - Next Tag: \(.value.nextTag)",
8585
" - Release Type: \(.value.releaseType)"
8686
)

.github/workflows/lint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ jobs:
5454
VALIDATE_JAVASCRIPT_PRETTIER: false # Using biome
5555
VALIDATE_JSON_PRETTIER: false # Using biome
5656
VALIDATE_JSCPD: false # Using biome
57+
VALIDATE_TERRAFORM_FMT: false # Terraform modules here aren't needed (They're for testing only)
58+
VALIDATE_TERRAFORM_TFLINT: false # Terraform modules here aren't needed (They're for testing only)
5759
VALIDATE_TYPESCRIPT_STANDARD: false # Using biome
5860
VALIDATE_TYPESCRIPT_ES: false # Using biome
5961
VALIDATE_TYPESCRIPT_PRETTIER: false # Using biome

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Dependency directory
22
node_modules
33

4+
# Terraform
5+
.terraform
6+
47
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
58
# Logs
69
logs

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,21 @@ resources.
184184
While the out-of-the-box defaults are suitable for most use cases, you can further customize the action's behavior by
185185
configuring the following optional input parameters as needed.
186186

187-
| Input | Description | Default |
188-
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
189-
| `major-keywords` | Keywords in commit messages that indicate a major release | `major change,breaking change` |
190-
| `minor-keywords` | Keywords in commit messages that indicate a minor release | `feat,feature` |
191-
| `patch-keywords` | Keywords in commit messages that indicate a patch release | `fix,chore,docs` |
192-
| `default-first-tag` | Specifies the default tag version | `v1.0.0` |
193-
| `terraform-docs-version` | Specifies the terraform-docs version used to generate documentation for the wiki | `v0.19.0` |
194-
| `delete-legacy-tags` | Specifies a boolean that determines whether tags and releases from Terraform modules that have been deleted should be automatically removed | `true` |
195-
| `disable-wiki` | Whether to disable wiki generation for Terraform modules | `false` |
196-
| `wiki-sidebar-changelog-max` | An integer that specifies how many changelog entries are displayed in the sidebar per module | `5` |
197-
| `disable-branding` | Controls whether a small branding link to the action's repository is added to PR comments. Recommended to leave enabled to support OSS. | `false` |
198-
| `module-path-ignore` | A comma-separated list of module paths to completely ignore during processing. Paths matching these patterns will not be considered for versioning, releases, or documentation generation. | `` (empty string) |
199-
| `module-change-exclude-patterns` | A comma-separated list of file patterns to exclude from triggering version changes in Terraform modules. Patterns follow glob syntax (e.g., `.gitignore,_.md`) and are relative to each Terraform module directory. Files matching these patterns will not affect version changes. **WARNING**: Avoid excluding '`_.tf`' files, as they are essential for module detection and versioning processes. | `.gitignore,*.md,*.tftest.hcl,tests/**` |
200-
| `module-asset-exclude-patterns` | A comma-separated list of file patterns to exclude when bundling a Terraform module for tag/release. Patterns follow glob syntax (e.g., `tests/\*\*`) and are relative to each Terraform module directory. Files matching these patterns will be excluded from the bundled output. | `.gitignore,*.md,*.tftest.hcl,tests/**` |
201-
| `use-ssh-source-format` | If enabled, all links to source code in generated Wiki documentation will use SSH standard format (e.g., `git::ssh://git@github.com/owner/repo.git`) instead of HTTPS format (`git::https://github.com/owner/repo.git`) | `false` |
187+
| Input | Description | Default |
188+
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
189+
| `major-keywords` | Keywords in commit messages that indicate a major release | `major change,breaking change` |
190+
| `minor-keywords` | Keywords in commit messages that indicate a minor release | `feat,feature` |
191+
| `patch-keywords` | Keywords in commit messages that indicate a patch release | `fix,chore,docs` |
192+
| `default-first-tag` | Specifies the default tag version | `v1.0.0` |
193+
| `terraform-docs-version` | Specifies the terraform-docs version used to generate documentation for the wiki | `v0.19.0` |
194+
| `delete-legacy-tags` | Specifies a boolean that determines whether tags and releases from Terraform modules that have been deleted should be automatically removed | `true` |
195+
| `disable-wiki` | Whether to disable wiki generation for Terraform modules | `false` |
196+
| `wiki-sidebar-changelog-max` | An integer that specifies how many changelog entries are displayed in the sidebar per module | `5` |
197+
| `disable-branding` | Controls whether a small branding link to the action's repository is added to PR comments. Recommended to leave enabled to support OSS. | `false` |
198+
| `module-path-ignore` | Comma-separated list of module paths to completely ignore. Modules matching any pattern here are excluded from all versioning, releases, and documentation.<br><sub>[Read more here](#understanding-the-filtering-options)</sub> | `` (empty string) |
199+
| `module-change-exclude-patterns` | Comma-separated list of file patterns (relative to each module) to exclude from triggering version changes. Lets you release a module but control which files inside it do not force a version bump.<br><sub>[Read more here](#understanding-the-filtering-options)</sub> | `.gitignore,*.md,*.tftest.hcl,tests/**` |
200+
| `module-asset-exclude-patterns` | A comma-separated list of file patterns to exclude when bundling a Terraform module for tag/release. Patterns follow glob syntax (e.g., `tests/\*\*`) and are relative to each Terraform module directory. Files matching these patterns will be excluded from the bundled output. | `.gitignore,*.md,*.tftest.hcl,tests/**` |
201+
| `use-ssh-source-format` | If enabled, all links to source code in generated Wiki documentation will use SSH standard format (e.g., `git::ssh://git@github.com/owner/repo.git`) instead of HTTPS format (`git::https://github.com/owner/repo.git`) | `false` |
202202

203203
### Understanding the filtering options
204204

@@ -339,8 +339,8 @@ The following outputs are available from this action:
339339
"changed-modules-map": {
340340
"aws/vpc": {
341341
"path": "modules/aws/vpc",
342-
"currentTag": "aws/vpc/v1.0.0",
343-
"nextTag": "aws/vpc/v1.1.0",
342+
"latestTag": "aws/vpc/v1.0.0",
343+
"releaseTag": "aws/vpc/v1.1.0",
344344
"releaseType": "minor"
345345
}
346346
},

0 commit comments

Comments
 (0)