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

Refactor mode configuration | Add support for HYBRID | Add new CommitMode focused default config #1312

Merged
merged 3 commits into from
Mar 2, 2024
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
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,7 @@ jobs:
],
"label_extractor": [
{
"pattern": "^(build|ci|chore|doc|docs|wiki|remove|deprecate|security|dependency|package|feat|feature|fix|bug|perf|optimize|refactor|revert|style|test):(.*)",
"target": "$1"
},
{
"pattern": "^(build|ci|chore|doc|docs|wiki|remove|deprecate|security|dependency|package|feat|feature|fix|bug|perf|optimize|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?:(.*)",
"pattern": "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)",
"target": "$1"
}
],
Expand Down Expand Up @@ -776,7 +772,7 @@ it('Test custom changelog builder', async () => {
false, // enable to fetch reviewers
false, // enable to fetch release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // set the mode to use [PR, COMMIT, HYBRID]
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down
28 changes: 14 additions & 14 deletions __tests__/gitea/releaseNotesBuilderGitea.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ it('[Gitea] Verify reviewers who approved are fetched and also release informati
true, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -78,7 +78,7 @@ it('[Gitea] Should match generated changelog (unspecified fromTag)', async () =>
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -115,7 +115,7 @@ it('[Gitea] Should match generated changelog (unspecified tags)', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -151,7 +151,7 @@ it('[Gitea] Should use empty placeholder', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -202,7 +202,7 @@ it('[Gitea] Should fill empty placeholders', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -310,7 +310,7 @@ it('[Gitea] Should fill `template` placeholders', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -419,7 +419,7 @@ it('[Gitea] Should fill `template` placeholders, ignore', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -484,7 +484,7 @@ it('[Gitea] Uncategorized category', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -558,7 +558,7 @@ it('[Gitea] Verify commit based changelog', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
true, // enable commitMode
'COMMIT', // enable commitMode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -635,7 +635,7 @@ it('[Gitea] Verify commit based changelog', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
true, // enable commitMode
'COMMIT', // enable commitMode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -673,7 +673,7 @@ it('[Gitea] Verify default inclusion of open PRs', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -714,7 +714,7 @@ it('[Gitea] Verify custom categorisation of open PRs', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -746,7 +746,7 @@ it('[Gitea] Fetch release information', async () => {
false, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down Expand Up @@ -780,7 +780,7 @@ it('[Gitea] Fetch release information for non existing tag / release', async ()
false, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
Expand Down
39 changes: 20 additions & 19 deletions __tests__/gitea/releaseNotesBuilderPullGitea.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {checkExportedData, mergeConfiguration, resolveConfiguration} from '../../src/utils'
import {buildChangelog} from '../../src/transform'
import {pullData} from '../../src/pr-collector/prCollector'
import {Options, pullData} from '../../src/pr-collector/prCollector'
import {GiteaRepository} from '../../src/repositories/GiteaRepository'
import {clear} from '../../src/transform'
import {ReleaseNotesOptions} from '../../src/releaseNotesBuilder'

jest.setTimeout(180000)
clear()
Expand Down Expand Up @@ -47,17 +48,17 @@ it('[Gitea] Should have changelog (tags)', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_0.5.0-master_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features

Expand Down Expand Up @@ -85,17 +86,17 @@ it('[Gitea] Should match generated changelog (tags)', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_0.5.0-master_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features

Expand Down Expand Up @@ -124,17 +125,17 @@ it('[Gitea] Should match generated changelog (refs)', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_3e49adf-894a64_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 📦 Uncategorized

Expand Down Expand Up @@ -181,17 +182,17 @@ it('[Gitea] Should match generated changelog and replace all occurrences (refs)'
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_3e49adf-894a64_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 📦 Uncategorized

Expand Down Expand Up @@ -243,17 +244,17 @@ it('[Gitea] Should match ordered ASC', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_0.1.0-master_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features

Expand Down Expand Up @@ -300,17 +301,17 @@ it('[Gitea] Should match ordered DESC', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_0.1.0-master_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features

Expand Down
Loading
Loading