Skip to content

Commit 13aba7b

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 13aba7b

File tree

8 files changed

+22
-194
lines changed

8 files changed

+22
-194
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
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-community/npm-features/prettier": {}
54+
"ghcr.io/devcontainers-community/npm-features/prettier": {},
55+
"ghcr.io/devcontainers/features/github-cli:1": {}
5556
}
5657
}

.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 }}");

__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');

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"enabled": false
1010
},
1111
"files": {
12-
"includes": ["*.md", "*.ts", "__mocks__/**/*.ts", "__tests__/**/*.ts", "src/**/*.ts", "scripts/**/*.ts"]
12+
"includes": ["*.md", "*.ts", "__mocks__/**/*.ts", "__tests__/**/*.ts", "src/**/*.ts", "scripts/**/*"]
1313
},
1414
"formatter": {
1515
"enabled": true,

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@
4343
"package": "ncc build src/index.ts --source-map -o dist",
4444
"test": "vitest run --coverage",
4545
"test:watch": "vitest",
46+
"test:parse-modules": "tsx scripts/parse-modules-test.ts",
47+
"changelog": "node scripts/changelog.js 10.0.0",
4648
"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"
49+
"terraform-docs-version": "gh api repos/terraform-docs/terraform-docs/releases/latest --jq '.tag_name'"
4950
},
5051
"dependencies": {
5152
"@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 & 9 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
@@ -552,9 +552,9 @@ async function main() {
552552
const version = process.argv[2];
553553

554554
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"');
555+
console.error('❌ Error: Next version argument is required');
556+
console.error('Usage: node scripts/changelog.js [next-version]');
557+
console.error('Example: node scripts/changelog.js "1.2.3"');
558558
process.exit(1);
559559
}
560560

scripts/dev-parse-modules.ts renamed to scripts/parse-modules-test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ async function main() {
3030
process.env['INPUT_DELETE-LEGACY-TAGS'] = 'false';
3131
process.env['INPUT_DISABLE-WIKI'] = 'true';
3232
process.env['INPUT_WIKI-SIDEBAR-CHANGELOG-MAX'] = '5';
33+
process.env['INPUT_WIKI-USAGE-TEMPLATE'] = 'Wiki usage template';
3334
process.env['INPUT_DISABLE-BRANDING'] = 'false';
3435
process.env.INPUT_GITHUB_TOKEN = process.env.GITHUB_TOKEN;
3536
process.env['INPUT_USE-SSH-SOURCE-FORMAT'] = 'true';
37+
process.env['INPUT_TAG-DIRECTORY-SEPARATOR'] = '/';
38+
process.env['INPUT_USE-VERSION-PREFIX'] = 'true';
3639
process.env['INPUT_MODULE-PATH-IGNORE'] = '**/examples/**';
3740
process.env['INPUT_MODULE-CHANGE-EXCLUDE-PATTERNS'] = '.gitignore,*.md';
3841

0 commit comments

Comments
 (0)