Skip to content

Commit 83eca73

Browse files
committed
fix: Improve release notes and add test workflow
1 parent 799e2a7 commit 83eca73

2 files changed

Lines changed: 53 additions & 8 deletions

File tree

.github/workflows/test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
name: Run Tests (${{ matrix.node-version }})
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
node-version: ['18.x', '20.x']
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
cache: 'npm'
27+
cache-dependency-path: 'scripts/package-lock.json'
28+
29+
- name: Install dependencies
30+
working-directory: ./scripts
31+
run: npm ci
32+
33+
- name: Run Tests
34+
working-directory: ./scripts
35+
run: npm test
36+
37+
- name: Check Test Coverage
38+
working-directory: ./scripts
39+
run: npm run test:check
40+

scripts/generate-release-notes.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ function getLastTag() {
2727

2828
function getCommitsSinceTag(tag) {
2929
if (!tag) {
30-
// If no tag, get all commits
31-
return exec('git log --pretty=format:"%h|%s|%b" --no-merges');
30+
// If no tag, get last 20 commits
31+
return exec('git log -20 --pretty=format:"%h|%s|%b"');
3232
}
33-
return exec(`git log ${tag}..HEAD --pretty=format:"%h|%s|%b" --no-merges`);
33+
// Include merge commits to capture PR merges
34+
return exec(`git log ${tag}..HEAD --pretty=format:"%h|%s|%b"`);
3435
}
3536

3637
function categorizeCommit(message) {
@@ -213,7 +214,11 @@ function generateReleaseNotes(version) {
213214
// Full Changelog
214215
notes += `---\n\n`;
215216
notes += `## Full Changelog\n\n`;
216-
notes += `For the complete list of changes, see the [commit history](https://github.com/OS366/phantom/compare/${lastTag || 'HEAD~' + stats.total}...HEAD).\n\n`;
217+
if (lastTag) {
218+
notes += `**[${lastTag}...v${version}](https://github.com/OS366/phantom/compare/${lastTag}...v${version})**\n\n`;
219+
} else {
220+
notes += `**[View all commits](https://github.com/OS366/phantom/commits/main)**\n\n`;
221+
}
217222

218223
return notes;
219224
}
@@ -232,9 +237,9 @@ const releaseNotes = generateReleaseNotes(version);
232237
const outputPath = path.join(__dirname, '..', 'docs', `RELEASE_NOTES_v${version}.md`);
233238
fs.writeFileSync(outputPath, releaseNotes, 'utf8');
234239

235-
console.log(`✅ Release notes generated: ${outputPath}`);
236-
console.log(`\n${releaseNotes.substring(0, 500)}...\n`);
240+
// Log to stderr so it doesn't pollute stdout (which is captured by workflow)
241+
console.error(`✅ Release notes generated: ${outputPath}`);
237242

238-
// Also output to stdout for GitHub Actions
239-
console.log('::set-output name=notes::' + releaseNotes.replace(/\n/g, '%0A'));
243+
// Output release notes to stdout for GitHub Actions workflow to capture
244+
console.log(releaseNotes);
240245

0 commit comments

Comments
 (0)