Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sections output #65

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ jobs:
echo "Release Notes: ${{ steps.draft-release.outputs.release-notes }}"
echo "Release URL: ${{ steps.draft-release.outputs.release-url }}"
echo "Release ID: ${{ steps.draft-release.outputs.release-id }}"
echo "Release Sections: ${{ steps.draft-release.outputs.release-sections }}"
73 changes: 71 additions & 2 deletions __tests__/notes.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {describe, expect, test, it} from '@jest/globals'
import {parseNotes, generateReleaseNotes} from '../src/notes'
import {parseNotes, generateReleaseNotes, splitMarkdownSections} from '../src/notes'
import * as github from '@actions/github'
import {Inputs} from '../src/context'
import {helpers} from 'handlebars'
import {Category} from '../src/version'

jest.mock('@actions/core')
jest.mock('@actions/github')
Expand Down Expand Up @@ -143,7 +144,7 @@ describe('generateReleaseNotes', () => {
* doc 2
* doc 3

### 🧹 Chores
### 🔨 Maintenance
* chore 1
* chore 2
* chore 3
Expand Down Expand Up @@ -173,3 +174,71 @@ describe('generateReleaseNotes', () => {
expect(notes).not.toContain('<details><summary>3 changes</summary>')
})
})

const markdown = `
<!-- Release notes generated using configuration in .github/release.yml at main -->

## What's Changed
### 🐛 Bug Fixes
* Bump anchore/sbom-action from 0.13.1 to 0.13.4 by @dependabot in https://github.com/somerepo/pull/200
### 🧪 Tests
* update by @lucacome in https://github.com/somerepo/pull/205
### 🔨 Maintenance
* Bump aquasecurity/trivy-action from 0.8.0 to 0.9.2 by @dependabot in https://github.com/somerepo/pull/175
* Bump actions/setup-go from 3 to 4 by @dependabot in https://github.com/somerepo/pull/198

**Full Changelog**: https://github.com/somerepo/compare/v5.0.4...v5.0.5`

describe('splitMarkdownSections', () => {
it('splits sections correctly', async () => {
const expectedOutput = {
bug: ['* Bump anchore/sbom-action from 0.13.1 to 0.13.4 by @dependabot in https://github.com/somerepo/pull/200'],
tests: ['* update by @lucacome in https://github.com/somerepo/pull/205'],
chore: [
'* Bump aquasecurity/trivy-action from 0.8.0 to 0.9.2 by @dependabot in https://github.com/somerepo/pull/175',
'* Bump actions/setup-go from 3 to 4 by @dependabot in https://github.com/somerepo/pull/198',
],
dependencies: [],
'*': [],
documentation: [],
enhancement: [],
change: [],
}
const categories = [
{
title: 'Others', // default category
labels: ['*'],
},
{
title: '🐛 Bug Fixes',
labels: ['bug'],
},
{
title: '🧪 Tests',
labels: ['tests'],
},
{
title: '🔨 Maintenance',
labels: ['chore'],
},
{
title: '📦 Dependencies',
labels: ['dependencies'],
},
{
title: '📝 Documentation',
labels: ['documentation'],
},
{
title: '🚀 Features',
labels: ['enhancement'],
},
{
title: '💣 Breaking Changes',
labels: ['change'],
},
]
const result = await splitMarkdownSections(markdown, categories)
expect(result).toEqual(expectedOutput)
})
})
188 changes: 120 additions & 68 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Loading