Skip to content

Commit cc5eec2

Browse files
committed
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
1 parent b33ab14 commit cc5eec2

File tree

11 files changed

+40
-205
lines changed

11 files changed

+40
-205
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
5252
},
5353
"features": {
54+
"ghcr.io/devcontainers/features/github-cli:1": {},
5455
"ghcr.io/devcontainers-community/npm-features/prettier": {}
5556
}
5657
}

.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@12150456a73e248bdc94d0794898f94e23127c88 # v7.4.0
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: 1 addition & 1 deletion
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 }}");

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,12 @@ configuring the following optional input parameters as needed.
207207

208208
- **`module-path-ignore`**: Completely ignores specified module paths. Any module whose path matches any pattern in this
209209
list will not be processed at all by the action. This is useful for:
210-
211210
- Excluding example modules (e.g., `**/examples/**`)
212211
- Skipping test modules (e.g., `**/test/**`)
213212
- Ignoring documentation-focused modules (e.g., `**/docs/**`)
214213
- Excluding entire directories or paths that contain Terraform files but shouldn't be versioned as modules
215214

216215
**Important pattern matching notes:**
217-
218216
- Patterns are relative to the workspace directory (no leading slash)
219217
- A pattern like `dir/**` will match files and directories INSIDE `dir` but NOT the `dir` directory itself
220218
- To match both a directory and its contents, you need both patterns: `dir,dir/**`
@@ -230,15 +228,13 @@ configuring the following optional input parameters as needed.
230228
a new module release.
231229

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

240237
**Common use cases:**
241-
242238
- Documentation files (`*.md`, `docs/**`)
243239
- Test files (`tests/**`, `*.tftest.hcl`)
244240
- Examples (`examples/**`)
@@ -256,15 +252,13 @@ configuring the following optional input parameters as needed.
256252
are _excluded_ from the asset. This helps reduce the asset size by omitting test files, examples, documentation, etc.
257253

258254
**Key details:**
259-
260255
- Patterns are relative to each **module directory**, not the workspace root
261256
- Uses `matchBase: true` for pattern matching (same as `module-change-exclude-patterns`)
262257
- Applied during the bundle/archive creation phase for GitHub releases
263258
- Default patterns: `.gitignore, *.md, *.tftest.hcl, tests/**`
264259
- These patterns do NOT affect versioning decisions - only the contents of release assets
265260

266261
**Common use cases:**
267-
268262
- Test directories and files (`tests/**`, `*.tftest.hcl`)
269263
- Documentation that's not needed for module functionality (`*.md`)
270264
- Development-specific files (`.gitignore`, `CHANGELOG.md`)

__tests__/releases.test.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,12 @@ describe('releases', () => {
9696
expect(versions).toEqual(sortedVersions);
9797
});
9898

99-
it('should validate release content structure', () => {
100-
for (const release of releases) {
101-
// Basic structure checks
102-
expect(release).toHaveProperty('id');
103-
expect(release).toHaveProperty('title');
104-
expect(release).toHaveProperty('body');
105-
106-
// Title format check (should at least contain v1.1.1)
107-
expect(release.title).toMatch(/v\d+\.\d+\.\d+/);
108-
109-
// Body content checks
110-
expect(typeof release.body).toBe('string');
111-
expect(release.body.length).toBeGreaterThan(0);
112-
}
113-
});
114-
11599
it('should verify specific release contents', () => {
116-
// Find v1.3.0 release
100+
// Find v1.3.0 release (This is specific for this repo - which is fine as we are just testing release object parsing)
117101
const v130Release = releases.find((r) => r.title === 'v1.3.0');
118102
expect(v130Release).toBeDefined();
103+
expect(v130Release?.tagName).toBe('v1.3.0');
104+
expect(v130Release?.title).toBe('v1.3.0');
119105
expect(v130Release?.id).toBe(182147836);
120106
expect(v130Release?.body).toContain('Enhanced Wiki Generation');
121107
expect(v130Release?.body).toContain('Asset & Exclude Pattern Filtering');

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ inputs:
127127
Character used to separate directory path components in Git tags. This separator is used to convert
128128
module directory paths into tag names (e.g., 'modules/aws/s3-bucket' becomes 'modules-aws-s3-bucket-v1.0.0'
129129
when using '-'). Must be a single character from: /, -, _, or .
130-
130+
131131
Examples with different separators:
132132
- "/" (default): modules/aws/s3-bucket/v1.0.0
133133
- "-": modules-aws-s3-bucket-v1.0.0

biome.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@
99
"enabled": false
1010
},
1111
"files": {
12-
"includes": ["*.md", "*.ts", "__mocks__/**/*.ts", "__tests__/**/*.ts", "src/**/*.ts", "scripts/**/*.ts"]
12+
"includes": [
13+
"*.md",
14+
"*.ts",
15+
"*.json",
16+
"__mocks__/**/*.ts",
17+
"__tests__/**/*.ts",
18+
".devcontainer/*.json",
19+
"src/**/*.ts",
20+
"scripts/**/*"
21+
]
1322
},
1423
"formatter": {
1524
"enabled": true,

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
"bugs": {
1414
"url": "https://github.com/techpivot/terraform-module-releaser/issues"
1515
},
16-
"keywords": ["terraform", "module", "releaser", "github-action", "monorepo"],
16+
"keywords": [
17+
"terraform",
18+
"module",
19+
"releaser",
20+
"github-action",
21+
"monorepo"
22+
],
1723
"license": "MIT",
1824
"exports": {
1925
".": "./dist/index.js"
@@ -36,16 +42,18 @@
3642
"bundle": "npm run check:fix && npm run package",
3743
"check": "biome check ./src",
3844
"check:fix": "biome check --write --unsafe .",
45+
"prettier": "npx prettier -w *.md",
3946
"dev:parse-modules": "tsx scripts/dev-parse-modules.ts",
4047
"textlint": "textlint -c .github/linters/.textlintrc **/*.md",
4148
"textlint:fix": "textlint -c .github/linters/.textlintrc --fix **/*.md",
4249
"typecheck": "tsc --noEmit",
4350
"package": "ncc build src/index.ts --source-map -o dist",
4451
"test": "vitest run --coverage",
4552
"test:watch": "vitest",
53+
"test:parse-modules": "tsx scripts/parse-modules-test.ts",
54+
"changelog": "node scripts/changelog.js 10.0.0",
4655
"coverage": "make-coverage-badge --output-path ./assets/coverage-badge.svg",
47-
"terraform-docs-version": "gh api repos/terraform-docs/terraform-docs/releases/latest --jq '.tag_name'",
48-
"changelog:test": "node .github/scripts/changelog.js 10.0.0"
56+
"terraform-docs-version": "gh api repos/terraform-docs/terraform-docs/releases/latest --jq '.tag_name'"
4957
},
5058
"dependencies": {
5159
"@actions/core": "^1.11.1",

scripts/action.yml

Lines changed: 0 additions & 163 deletions
This file was deleted.

.github/scripts/changelog.js renamed to scripts/changelog.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* USAGE:
99
* ------
1010
* 1. Set up environment variables (see below)
11-
* 2. Run via npm script: `npm run changelog:test -- "1.2.3"`
12-
* 3. Or import and use: `import { generateChangelog } from './.github/scripts/changelog.js'`
11+
* 2. Run via npm script: `npm run changelog -- "1.2.3"`
12+
* 3. Or import and use: `import { generateChangelog } from './scripts/changelog.js'`
1313
*
1414
* TESTING LOCALLY:
1515
* ----------------
@@ -21,10 +21,10 @@
2121
* export GITHUB_TOKEN="your_github_token_here"
2222
*
2323
* # Run the test script
24-
* npm run changelog:test -- "1.2.3"
24+
* npm run changelog"
2525
*
26-
* # Or test with different versions
27-
* npm run changelog:test -- "2.0.0"
26+
* # Or test with different next version (Only used for display purposes)
27+
* npm run changelog -- "2.0.0"
2828
*
2929
* Required Environment Variables:
3030
* ------------------------------
@@ -62,7 +62,7 @@ import https from 'node:https';
6262
import OpenAI from 'openai';
6363

6464
const ENDPOINT = 'https://models.github.ai/inference';
65-
const MODEL = 'openai/gpt-4.1';
65+
const MODEL = 'openai/gpt-4.1'; // gpt-5 has max request size of 4000 tokens on free
6666
const PROMPT = `
6767
You're the head of developer relations at a SaaS company. Write a concise, professional, and engaging changelog that prioritizes user-impacting changes and tells a story about the release.
6868
@@ -542,19 +542,16 @@ export { generateChangelog };
542542

543543
/**
544544
* CLI interface for testing the changelog generator locally.
545-
*
546-
* Usage: node .github/scripts/changelog.js [version]
547-
* Example: node .github/scripts/changelog.js "1.2.3"
548545
*/
549546
async function main() {
550547
// Check if this script is being run directly (not imported)
551548
if (import.meta.url === `file://${process.argv[1]}`) {
552549
const version = process.argv[2];
553550

554551
if (!version) {
555-
console.error('❌ Error: Version argument is required');
556-
console.error('Usage: node .github/scripts/changelog.js [version]');
557-
console.error('Example: node .github/scripts/changelog.js "1.2.3"');
552+
console.error('❌ Error: Next version argument is required');
553+
console.error('Usage: node scripts/changelog.js [next-version]');
554+
console.error('Example: node scripts/changelog.js "1.2.3"');
558555
process.exit(1);
559556
}
560557

0 commit comments

Comments
 (0)