Skip to content

Commit 664bdbc

Browse files
authored
major: Add support for tag-directory-separator and use-version-prefix inputs, with workflow, config, and mock/test improvements (#227)
* feat: add centralized action metadata system with proper array parsing - Add ACTION_INPUTS mapping for all GitHub Action inputs - Add createConfigFromInputs() function for dynamic config creation - Implement proper array parsing that distinguishes required vs optional - Required array inputs throw error on empty string - Optional array inputs return empty array on empty string - Add comprehensive type definitions for action metadata * refactor: update config system to use centralized action metadata - Replace manual input processing with createConfigFromInputs() - Add comprehensive validation for tag directory separator - Add validation for default first tag format - Simplify config initialization using metadata-driven approach - Update config mock to use real action metadata system - Improve error messages with more specific validation details * test: improve test infrastructure and input helpers - Refactor input helpers to use centralized ACTION_INPUTS metadata - Add getActionDefaults() to load defaults from action.yml - Generate input type arrays dynamically from metadata - Add getConfigKey() helper for type-safe config access - Simplify setupTestInputs() to use action.yml defaults - Remove hardcoded input arrays in favor of metadata-driven approach * test: add comprehensive config validation test coverage - Add tests for tag directory separator validation (length and character) - Add tests for default first tag format validation - Add tests for required vs optional array input handling - Add tests for array parsing edge cases and deduplication - Improve test organization with metadata-driven approach - Achieve 100% test coverage for config.ts validation logic * fix: resolve context test environment variable issues - Set up required GitHub environment variables in context tests - Fix test isolation by properly clearing context between tests - Ensure environment variables are set before context initialization - Resolve test failures caused by missing GitHub Action environment * fix: correct import paths and type inconsistencies * chore: update dependencies and action.yml defaults * chore: update package dependencies to latest versions * fix: remove unnecessary SSH agent forwarding and update prettier feature * fix: update super-linter action to specific version for consistency Fixes: https://app.aikido.dev/repositories/462873?sidebarIssue=3135661 * fix: update create-pull-request action to specific version for stability https://app.aikido.dev/repositories/462873?sidebarIssue=3135661 * fix: update SonarQube scan action to specific commit SHA for stability * fix: update package dependencies to latest versions for improved stability * feat: support optional v prefix with directory separator config - Removed deprecated action-metadata types and utility functions. - Introduced new metadata structure for action inputs in `metadata.ts`. - Updated configuration handling to support dynamic input mapping. - Enhanced tag processing to accommodate various directory separators. - Added tests for metadata input handling and error scenarios. - Improved regex patterns for module tag validation. - Updated action.yml to include new input parameters for tag directory separator and version prefix usage. - Refactored TerraformModule class to utilize new configuration settings for versioning. * fix: update rollup packages to version 4.44.0 for improved compatibility * feat: enhance tag generation configuration with detailed descriptions and examples for directory separator and version prefix options * fix: remove eslint directive for throwing literals in metadata tests * chore: update dependencies * chore: update dependencies and improve variable naming - Updated `p-limit` from version 6.2.0 to 7.0.0 in package.json. - Updated `@biomejs/biome` from version 1.9.4 to 2.2.0 in devDependencies. - Updated `textlint` from version 14.8.0 to 15.2.1 in devDependencies. - Refactored variable names in `dev-parse-modules.ts` for clarity: changed `config` to `_config`, `context` to `_context`, and `modules` to `_modules`. - Improved backward compatibility proxy in `config.ts` and `context.ts` by renaming the target parameter to `_target` for better readability. * fix: update @types/node to version 22.17.2 for improved compatibility * fix: update GitHub token reference for CI testing in workflow * refactor: simplify ACTION_INPUTS metadata definitions using factory functions * test: enhance ACTION_INPUTS tests for metadata structure and type safety * fix: formatting * test: add tests for VALID_TAG_DIRECTORY_SEPARATORS, VERSION_TAG_REGEX, and MODULE_TAG_REGEX * refactor: remove redundant SonarQube job steps from workflow * feat: refactor render -> renderTemplate function and update wiki usage template handling * fix: update changelog script import path in release workflow refactor: remove redundant release content structure validation from tests chore: update biome configuration to include all scripts chore: add new changelog script and remove deprecated action.yml test: add parse-modules-test script for local testing of parseTerraformModules function feat: implement changelog generation with GitHub API integration delete: remove unused development script for parsing modules * fix: update documentation links and remove test comment in main.tf
1 parent f02d448 commit 664bdbc

Some content is hidden

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

44 files changed

+2485
-1667
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"markdown.extension.list.indentationSize": "adaptive",
2727
"markdown.extension.italic.indicator": "_",
2828
"markdown.extension.orderedList.marker": "one",
29-
"remote.SSH.enableAgentForwarding": true,
3029
"[json]": {
3130
"editor.defaultFormatter": "biomejs.biome"
3231
},
@@ -53,6 +52,6 @@
5352
},
5453
"features": {
5554
"ghcr.io/devcontainers/features/github-cli:1": {},
56-
"ghcr.io/devcontainers-contrib/features/prettier:1": {}
55+
"ghcr.io/devcontainers-community/npm-features/prettier": {}
5756
}
5857
}

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ jobs:
4949
disable-wiki: false
5050
wiki-sidebar-changelog-max: 10
5151
delete-legacy-tags: false # Note: We don't want to delete tags in this repository
52-
terraform-docs-version: v0.19.0
53-
module-path-ignore: tf-modules/kms/examples/complete
52+
terraform-docs-version: v0.20.0
53+
module-path-ignore: tf-modules/kms/examples/complete,tf-modules/zoo,tf-modules/animal,tf-modules/s3-bucket-object
5454
module-change-exclude-patterns: .gitignore,*.md,*.tftest.hcl,tests/**,examples/**
5555
module-asset-exclude-patterns: .gitignore,*.md,*.tftest.hcl,tests/**
5656
use-ssh-source-format: true
57+
tag-directory-separator: "-"
58+
use-version-prefix: false
5759

5860
- name: Test Action Outputs
5961
id: test-outputs

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
- name: Lint Codebase
4444
id: super-linter
45-
uses: super-linter/super-linter/slim@v7
45+
uses: super-linter/super-linter@5119dcd8011e92182ce8219d9e9efc82f16fddb6 # v8.0.0
4646
env:
4747
DEFAULT_BRANCH: main
4848
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-start.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
with:
6767
result-encoding: json
6868
script: |
69-
const { generateChangelog } = await import('${{ github.workspace }}/.github/scripts/changelog.js');
69+
const { generateChangelog } = await import('${{ github.workspace }}/scripts/changelog.js');
7070
7171
try {
7272
const changelog = await generateChangelog("${{ env.VERSION }}");
@@ -149,7 +149,7 @@ jobs:
149149
}
150150
151151
- name: Create Branch and Pull Request
152-
uses: peter-evans/create-pull-request@v7
152+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
153153
with:
154154
token: ${{ steps.app-token.outputs.token }}
155155
base: main

.github/workflows/test.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ on:
1010
types: [opened, synchronize, reopened]
1111

1212
jobs:
13-
tests:
13+
Tests:
1414
runs-on: ubuntu-latest
15-
name: Test
15+
name: TypeScript Tests
1616
permissions:
1717
contents: read
1818
steps:
@@ -33,9 +33,10 @@ jobs:
3333
- name: Run Tests Typescript
3434
run: npm run test
3535
env:
36-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO_CI_TESTING }}
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3737

38+
# Note: SonarQube requires the results from tests to get the coverage report
3839
- name: SonarQube Scan
39-
uses: SonarSource/sonarqube-scan-action@v5
40+
uses: SonarSource/sonarqube-scan-action@2500896589ef8f7247069a56136f8dc177c27ccf # v5
4041
env:
4142
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

README.md

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -194,25 +194,25 @@ configuring the following optional input parameters as needed.
194194
| `delete-legacy-tags` | Specifies a boolean that determines whether tags and releases from Terraform modules that have been deleted should be automatically removed | `true` |
195195
| `disable-wiki` | Whether to disable wiki generation for Terraform modules | `false` |
196196
| `wiki-sidebar-changelog-max` | An integer that specifies how many changelog entries are displayed in the sidebar per module | `5` |
197+
| `wiki-usage-template` | A raw, multi-line string to override the default 'Usage' section in the generated wiki. Allows using variables like {{module_name}}, {{latest_tag}}, {{latest_tag_version_number}} and more.<br><sub>[Read more here](#configuring-the-wiki-usage-template)</sub> | [See action.yml](https://github.com/polleuretan/terraform-module-releaser/blob/main/action.yml#L108) |
197198
| `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` |
198199
| `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) |
199200
| `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/**` |
200201
| `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://[email protected]/owner/repo.git`) instead of HTTPS format (`git::https://github.com/owner/repo.git`) | `false` |
202-
| `wiki-usage-template` | A raw, multi-line string to override the default 'Usage' section in the generated wiki. Allows using variables like {{module_name}}, {{latest_tag}}, {{latest_tag_version_number}} and more.<br><sub>[Read more here](#configuring-the-usage-template)</sub> | [See action.yml](https://github.com/polleuretan/terraform-module-releaser/blob/main/action.yml#L108) |
202+
| `use-ssh-source-format` | If enabled, all links to source code in generated Wiki documentation will use SSH format (e.g., `git::ssh://[email protected]/owner/repo.git`) instead of HTTPS format (`git::https://github.com/owner/repo.git`) | `false` |
203+
| `tag-directory-separator` | Character used to separate directory path components in Git tags. Supports `/`, `-`, `_`, or `.` | `/` |
204+
| `use-version-prefix` | Whether to include the 'v' prefix on version tags (e.g., v1.2.3 vs 1.2.3) | `true` |
203205

204206
### Understanding the filtering options
205207

206208
- **`module-path-ignore`**: Completely ignores specified module paths. Any module whose path matches any pattern in this
207209
list will not be processed at all by the action. This is useful for:
208-
209210
- Excluding example modules (e.g., `**/examples/**`)
210211
- Skipping test modules (e.g., `**/test/**`)
211212
- Ignoring documentation-focused modules (e.g., `**/docs/**`)
212213
- Excluding entire directories or paths that contain Terraform files but shouldn't be versioned as modules
213214

214215
**Important pattern matching notes:**
215-
216216
- Patterns are relative to the workspace directory (no leading slash)
217217
- A pattern like `dir/**` will match files and directories INSIDE `dir` but NOT the `dir` directory itself
218218
- To match both a directory and its contents, you need both patterns: `dir,dir/**`
@@ -228,15 +228,13 @@ configuring the following optional input parameters as needed.
228228
a new module release.
229229

230230
**Key details:**
231-
232231
- Patterns are relative to each **module directory**, not the workspace root
233232
- Uses `matchBase: true` for pattern matching, so `*.md` will match any Markdown file in any subdirectory
234233
- Applied only after a module is identified but before determining if it needs a version change
235234
- Default patterns: `.gitignore, *.md, *.tftest.hcl, tests/**`
236235
- Use this for files that should be part of the module but don't affect its functionality
237236

238237
**Common use cases:**
239-
240238
- Documentation files (`*.md`, `docs/**`)
241239
- Test files (`tests/**`, `*.tftest.hcl`)
242240
- Examples (`examples/**`)
@@ -254,15 +252,13 @@ configuring the following optional input parameters as needed.
254252
are _excluded_ from the asset. This helps reduce the asset size by omitting test files, examples, documentation, etc.
255253

256254
**Key details:**
257-
258255
- Patterns are relative to each **module directory**, not the workspace root
259256
- Uses `matchBase: true` for pattern matching (same as `module-change-exclude-patterns`)
260257
- Applied during the bundle/archive creation phase for GitHub releases
261258
- Default patterns: `.gitignore, *.md, *.tftest.hcl, tests/**`
262259
- These patterns do NOT affect versioning decisions - only the contents of release assets
263260

264261
**Common use cases:**
265-
266262
- Test directories and files (`tests/**`, `*.tftest.hcl`)
267263
- Documentation that's not needed for module functionality (`*.md`)
268264
- Development-specific files (`.gitignore`, `CHANGELOG.md`)
@@ -282,18 +278,18 @@ similar to those used in `.gitignore` files. For more details on the pattern mat
282278
[source code](https://github.com/techpivot/terraform-module-releaser/blob/main/src/utils/file.ts) or visit the
283279
[minimatch documentation](https://github.com/isaacs/minimatch).
284280

285-
### Configuring the Usage Template
281+
### Configuring the Wiki Usage Template
286282

287283
The `wiki-usage-template` input allows you to customize the "Usage" section of the generated wiki page for each module.
288284
You can use the following dynamic variables in your template:
289285

290-
| Variable | Description | Example |
291-
| ------------------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------- |
292-
| `{{module_name}}` | The name of the module. | `aws/s3-bucket` |
293-
| `{{latest_tag}}` | The latest Git tag for the module. | `aws/s3-bucket/v1.2.3` |
294-
| `{{latest_tag_version_number}}` | The version number of the latest tag. | `1.2.3` |
295-
| `{{module_source}}` | The Git source URL for the module, respecting the `use-ssh-source-format` input. | `git::https://github.com/owner/repo.git` |
296-
| `{{module_name_terraform}}` | A Terraform-safe version of the module name (e.g., special characters replaced with underscores). | `aws_s3_bucket` |
286+
| Variable | Description | Example |
287+
| ------------------------------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
288+
| `{{module_name}}` | The name of the module. | `aws/s3-bucket` |
289+
| `{{latest_tag}}` | The latest Git tag for the module. | `aws/s3-bucket/v1.2.3` |
290+
| `{{latest_tag_version_number}}` | The version number of the latest tag (Always excludes any `v` prefix) | `1.2.3` |
291+
| `{{module_source}}` | The Git source URL for the module with `git::` prefix, respecting the `use-ssh-source-format` input. | `git::ssh://github.com/techpivot/terraform-module-releaser.git` |
292+
| `{{module_name_terraform}}` | A Terraform-safe version of the module name (e.g., special characters replaced with underscores). | `aws_s3_bucket` |
297293

298294
### Example Usage with Inputs
299295

@@ -323,29 +319,31 @@ jobs:
323319
minor-keywords: feat,feature
324320
patch-keywords: fix,chore,docs
325321
default-first-tag: v1.0.0
326-
terraform-docs-version: v0.19.0
322+
terraform-docs-version: v0.20.0
327323
delete-legacy-tags: true
328324
disable-wiki: false
329325
wiki-sidebar-changelog-max: 10
330326
module-path-ignore: path/to/ignore1,path/to/ignore2
331327
module-change-exclude-patterns: .gitignore,*.md,docs/**,examples/**,*.tftest.hcl,tests/**
332328
module-asset-exclude-patterns: .gitignore,*.md,*.tftest.hcl,tests/**
333-
use-ssh-source-format: false
329+
use-ssh-source-format: true
330+
tag-directory-separator: /
331+
use-version-prefix: true
334332
wiki-usage-template: |
335-
# My Custom Usage Instructions
336-
337-
This is a custom usage block.
338-
339-
You can add any markdown you want here.
333+
This is a custom wiki usage block that supports markdown.
340334
341-
And use variables like {{module_name}}, {{latest_tag}}, {{latest_tag_version_number}},
342-
{{module_source}} and {{module_name_terraform}}.
335+
The following variables are supported:
336+
- {{module_name}}
337+
- {{latest_tag}}
338+
- {{latest_tag_version_number}}
339+
- {{module_source}}
340+
- {{module_name_terraform}}
343341
344342
```hcl
345343
module "{{module_name_terraform}}" {
346-
source = "{{module_source}}?ref={{latest_tag}}"
347-
version = "{{latest_tag_version_number}}"
348-
# ...
344+
source = "{{module_source}}?ref={{latest_tag}}"
345+
346+
# See inputs below for additional required parameters
349347
}
350348
```
351349
````
@@ -367,6 +365,8 @@ The following outputs are available from this action:
367365

368366
```json
369367
{
368+
"changed-module-names": ["aws/vpc"],
369+
"changed-module-paths": ["/home/runner/work/terraform-module-releaser/terraform-module-releaser/aws/vpc"],
370370
"changed-modules-map": {
371371
"aws/vpc": {
372372
"path": "modules/aws/vpc",
@@ -375,16 +375,21 @@ The following outputs are available from this action:
375375
"releaseType": "minor"
376376
}
377377
},
378+
"all-module-names": ["aws/s3", "aws/vpc"],
379+
"all-module-paths": [
380+
"/home/runner/work/terraform-module-releaser/terraform-module-releaser/aws/s3",
381+
"/home/runner/work/terraform-module-releaser/terraform-module-releaser/aws/vpc"
382+
],
378383
"all-modules-map": {
379-
"aws/vpc": {
380-
"path": "modules/aws/vpc",
381-
"latestTag": "aws/vpc/v1.0.0",
382-
"latestTagVersion": "v1.0.0"
383-
},
384384
"aws/s3": {
385385
"path": "modules/aws/s3",
386386
"latestTag": "aws/s3/v2.1.0",
387387
"latestTagVersion": "v2.1.0"
388+
},
389+
"aws/vpc": {
390+
"path": "modules/aws/vpc",
391+
"latestTag": "aws/vpc/v1.0.0",
392+
"latestTagVersion": "v1.0.0"
388393
}
389394
}
390395
}

0 commit comments

Comments
 (0)