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

ci: fix minor release note generation bugs #1643

Merged
merged 4 commits into from
May 16, 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
42 changes: 0 additions & 42 deletions .github/workflows/test-specific.yml

This file was deleted.

23 changes: 17 additions & 6 deletions bin/conventional-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,19 @@ class ConventionalChangelog {
const conventionalCommitsStream = gitRawCommits({
format: '%B%n-hash-%n%H',
from: `v${this.previousVersion}`
}).pipe(conventionalCommitsParser(config.parserOpts))
})
.pipe(
new stream.Transform({
objectMode: true,
transform(chunk, encoding, callback) {
const commit = chunk.toString().split('\n')
commit[0] = self.removePrLinks(commit[0])
this.push(commit.join('\n'))
callback()
}
})
)
.pipe(conventionalCommitsParser(config.parserOpts))

conventionalCommitsStream.on('data', function onData(data) {
if (RELEASEABLE_PREFIXES.includes(data.type)) {
Expand Down Expand Up @@ -135,22 +147,21 @@ class ConventionalChangelog {
* @returns {object} the entry to add to the JSON changelog
*/
generateJsonChangelog(commits) {
const self = this
const securityChanges = []
const bugfixChanges = []
const featureChanges = []

commits.forEach((commit) => {
if (commit.type === 'security') {
securityChanges.push(self.removePrLinks(commit.subject))
securityChanges.push(commit.subject)
}

if (commit.type === 'fix') {
bugfixChanges.push(self.removePrLinks(commit.subject))
bugfixChanges.push(commit.subject)
}

if (commit.type === 'feat') {
featureChanges.push(self.removePrLinks(commit.subject))
featureChanges.push(commit.subject)
}
})

Expand Down Expand Up @@ -182,7 +193,7 @@ class ConventionalChangelog {
])

return new Promise((resolve, reject) => {
const commitsStream = new stream.Stream.Readable({
const commitsStream = new stream.Readable({
objectMode: true
})

Expand Down
2 changes: 1 addition & 1 deletion bin/create-github-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function getReleaseNotes(tagName, releaseNotesFile) {
throw new Error(`Current tag (${currentVersionHeader}) not first line of release notes.`)
}

const sections = data.split('### ', 2)
const sections = data.split(/^### /m, 2)
if (sections.length !== 2) {
throw new Error('Did not split into multiple sections. Double check notes format.')
}
Expand Down
9 changes: 2 additions & 7 deletions bin/templates/commit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@
{{~header}}
{{~/if}}

{{~!-- PR link --}}{{~#if pr}}
([#{{pr.id}}]({{pr.url}}))
{{~/if}}

{{~!-- commit link --}}{{~#if hash}}
([{{shortHash}}]({{@root.host}}/{{@root.owner}}/{{@root.repository}}/commit/{{hash}}))
{{~/if}}
{{~!-- PR link --}}{{~#if pr}} ([#{{pr.id}}]({{pr.url}})){{~/if}}
{{~!-- commit link --}}{{~#if hash}} ([{{shortHash}}]({{@root.host}}/{{@root.owner}}/{{@root.repository}}/commit/{{hash}})){{~/if}}

{{~!-- commit references --}}
{{~#if references~}}
Expand Down
21 changes: 10 additions & 11 deletions bin/test/conventional-changelog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ const exampleJson = {
const exampleCommit = {
type: 'fix',
scope: 'thing',
subject: 'updated Thing to prevent accidental modifications to inputs',
subject: 'updated Thing to prevent modifications to inputs',
merge: null,
header: 'fix(thing)!: updated Thing to prevent accidental modifications to inputs',
header: 'fix(thing)!: updated Thing to prevent modifications to inputs',
body: 'Thing no longer mutates provided inputs, but instead clones inputs before performing modifications. Thing will now always return an entirely new output',
footer: 'Fixes #1234, contributed by @someone',
notes: [
{
title: 'BREAKING CHANGE',
text: 'updated Thing to prevent accidental modifications to inputs'
text: 'updated Thing to prevent modifications to inputs'
}
],
references: [
Expand All @@ -55,12 +55,11 @@ const exampleCommit = {
const exampleMarkdown = `### v1.0.0 (2020-04-03)
#### ⚠ BREAKING CHANGES

* **thing:** updated Thing to prevent accidental modifications to inputs
* **thing:** updated Thing to prevent modifications to inputs

#### Bug Fixes

* **thing:** updated Thing to prevent accidental modifications to inputs
([#123](https://github.com/newrelic/node-newrelic/pull/123)), closes [1234](https://github.com/newrelic/node-newrelic/issues/1234)
* **thing:** updated Thing to prevent modifications to inputs ([#123](https://github.com/newrelic/node-newrelic/pull/123)), closes [1234](https://github.com/newrelic/node-newrelic/issues/1234)
* Thing no longer mutates provided inputs, but instead clones inputs before performing modifications. Thing will now always return an entirely new output
`

Expand Down Expand Up @@ -135,7 +134,7 @@ tap.test('Conventional Changelog Class', (testHarness) => {
})
mockGitLog.push(
[
'fix(thing)!: updated Thing to prevent accidental modifications to inputs',
'fix(thing)!: updated Thing to prevent modifications to inputs (#123)',
'Thing no longer mutates provided inputs, but instead clones inputs before performing modifications. Thing will now always return an entirely new output',
'Fixes #1234, contributed by @someone'
].join('\n')
Expand Down Expand Up @@ -186,10 +185,10 @@ tap.test('Conventional Changelog Class', (testHarness) => {

testHarness.test('generateJsonChangelog - should create the new JSON changelog entry', (t) => {
const commits = [
{ type: 'fix', subject: 'Fixed issue one (#1234)' },
{ type: 'fix', subject: ' Fixed issue two' },
{ type: 'feat', subject: 'Added something new ' },
{ type: 'security', subject: ' Bumped some dep (#4567)' }
{ type: 'fix', subject: 'Fixed issue one' },
{ type: 'fix', subject: 'Fixed issue two' },
{ type: 'feat', subject: 'Added something new' },
{ type: 'security', subject: 'Bumped some dep' }
]
const changelog = new ConventionalChangelog({ newVersion: '1.0.0', previousVersion: '0.9.0' })

Expand Down