- introduce test case to validate behavior of the regexr regex matching

- introduce test case to validate COMMIT mode with default conventional commit behavior
- introduce testcase to showcase custom placeholder and trim value to convert conventional commits to cleaned titles
This commit is contained in:
Mike Penz
2024-03-02 20:23:01 +00:00
committed by GitHub
parent db235a6627
commit 2389f61d7e
5 changed files with 75 additions and 6 deletions
+2 -6
View File
@@ -168,11 +168,7 @@ jobs:
], ],
"label_extractor": [ "label_extractor": [
{ {
"pattern": "^(build|ci|chore|doc|docs|wiki|remove|deprecate|security|dependency|package|feat|feature|fix|bug|perf|optimize|refactor|revert|style|test):(.*)", "pattern": "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)",
"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\\-\\.]+\\))?(!)?:(.*)",
"target": "$1" "target": "$1"
} }
], ],
@@ -776,7 +772,7 @@ it('Test custom changelog builder', async () => {
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch release information false, // enable to fetch release information
false, // enable to fetch reviews false, // enable to fetch reviews
false, // enable commitMode 'PR', // set the mode to use [PR, COMMIT, HYBRID]
false, // enable exportCache false, // enable exportCache
false, // enable exportOnly false, // enable exportOnly
null, // path to the cache null, // path to the cache
+70
View File
@@ -333,3 +333,73 @@ it('Should ignore PRs not merged into main branch', async () => {
console.log(changeLog) console.log(changeLog)
expect(changeLog).toStrictEqual(`153\n\n`) expect(changeLog).toStrictEqual(`153\n\n`)
}) })
it('Default configuration with commit mode', async () => {
const configuration = Object.assign({}, mergeConfiguration(undefined, undefined, 'COMMIT'))
const options = {
owner: 'conventional-commits',
repo: 'conventionalcommits.org',
fromTag: {name: '56cdc85d01fd11aa164bd958bbf6114a51abfcf6'},
toTag: {name: '325b74fbc44bf34d9fa645951d076a450b4e26be'},
includeOpen: false,
failOnError: false,
fetchViaCommits: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
mode: 'COMMIT',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/github_conventional-commits-1e1c8e-325b74.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features\n\n- feat(lang): add Bengali\n- feat(lang): add uzbek translation (#558)\n\n## 🐛 Fixes\n\n- fix: Fix grammar and consistency in french translation (#546)\n- fix(ja): fix typo\n- fix(zh-hant): Distinguish translations of 'Release/Publish'\n- fix(ko): fix translation typo for message (#567)\n\n## 📦 Other\n\n- doc: new thi.ng links and descriptions\n- docs: add link to git-changelog-command-line docker image\n- docs: Add descriptions for commit types\n\n`)
})
it('Default configuration with commit mode and custom placeholder', async () => {
const configuration = Object.assign({}, mergeConfiguration(undefined, undefined, 'COMMIT'))
configuration.pr_template = "- #{{TITLE_ONLY}}"
configuration.trim_values = true
configuration.custom_placeholders = [
{
"name": "TITLE_ONLY",
"source": "TITLE",
"transformer": {
"method": "regexr",
"pattern": "(\\w+(\\(.+\\))?: ?)?(.+)",
"target": "$3"
}
}
]
const options = {
owner: 'conventional-commits',
repo: 'conventionalcommits.org',
fromTag: {name: '56cdc85d01fd11aa164bd958bbf6114a51abfcf6'},
toTag: {name: '325b74fbc44bf34d9fa645951d076a450b4e26be'},
includeOpen: false,
failOnError: false,
fetchViaCommits: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
mode: 'COMMIT',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/github_conventional-commits-1e1c8e-325b74.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features\n\n- add Bengali\n- add uzbek translation (#558)\n\n## 🐛 Fixes\n\n- Fix grammar and consistency in french translation (#546)\n- fix typo\n- Distinguish translations of 'Release/Publish'\n- fix translation typo for message (#567)\n\n## 📦 Other\n\n- new thi.ng links and descriptions\n- add link to git-changelog-command-line docker image\n- Add descriptions for commit types`)
})
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long