Skip to content

Commit

Permalink
- introduce test case to validate behavior of the regexr regex matc…
Browse files Browse the repository at this point in the history
…hing

- 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
  • Loading branch information
mikepenz authored Mar 2, 2024
1 parent db235a6 commit 2389f61
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 6 deletions.
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
70 changes: 70 additions & 0 deletions __tests__/releaseNotesBuilderPull.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,73 @@ it('Should ignore PRs not merged into main branch', async () => {
console.log(changeLog)
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`)
})
1 change: 1 addition & 0 deletions caches/github_conventional-commits-1e1c8e-325b74.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"mergedPullRequests":[{"number":0,"title":"fix: Fix grammar and consistency in french translation (#546)","htmlURL":"","baseBranch":"","createdAt":"2023-10-18T23:36:07.000Z","mergedAt":"2023-10-18T23:36:07.000Z","mergeCommitSha":"fcb21b478f78297850894c71abee35ab98042823","author":"Yopai","repoName":"","labels":[],"milestone":"","body":"fix: Fix grammar and consistency in french translation (#546)","assignees":[],"requestedReviewers":[],"approvedReviewers":[],"status":"merged"},{"number":0,"title":"doc: new thi.ng links and descriptions","htmlURL":"","baseBranch":"","createdAt":"2023-10-19T10:44:22.000Z","mergedAt":"2023-10-19T10:44:22.000Z","mergeCommitSha":"79d1a4cbdbf9f04eebc531c0e76e7fbb8ebb4b95","author":"postspectacular","repoName":"","labels":[],"milestone":"","body":"doc: new thi.ng links and descriptions","assignees":[],"requestedReviewers":[],"approvedReviewers":[],"status":"merged"},{"number":0,"title":"fix(ja): fix typo","htmlURL":"","baseBranch":"","createdAt":"2023-10-19T10:45:42.000Z","mergedAt":"2023-10-19T10:45:42.000Z","mergeCommitSha":"64ae03aacea2a3cf5271f4217d266db10f2c3043","author":"moritasoshi","repoName":"","labels":[],"milestone":"","body":"fix(ja): fix typo","assignees":[],"requestedReviewers":[],"approvedReviewers":[],"status":"merged"},{"number":0,"title":"docs: add link to git-changelog-command-line docker image","htmlURL":"","baseBranch":"","createdAt":"2023-10-19T10:47:20.000Z","mergedAt":"2023-10-19T10:47:20.000Z","mergeCommitSha":"158a7b14ef1f8c24b3e9a7cee97bd0e2c0bd6397","author":"tomasbjerre","repoName":"","labels":[],"milestone":"","body":"docs: add link to git-changelog-command-line docker image","assignees":[],"requestedReviewers":[],"approvedReviewers":[],"status":"merged"},{"number":0,"title":"docs: Add descriptions for commit types","htmlURL":"","baseBranch":"","createdAt":"2023-10-19T10:48:46.000Z","mergedAt":"2023-10-19T10:48:46.000Z","mergeCommitSha":"551cfd47a533f6222d0c9c06af096d4076b48bc9","author":"HExris","repoName":"","labels":[],"milestone":"","body":"docs: Add descriptions for commit types","assignees":[],"requestedReviewers":[],"approvedReviewers":[],"status":"merged"},{"number":0,"title":"fix(zh-hant): Distinguish translations of 'Release/Publish'","htmlURL":"","baseBranch":"","createdAt":"2023-10-19T10:49:51.000Z","mergedAt":"2023-10-19T10:49:51.000Z","mergeCommitSha":"5b935ded2e6b2cbdb3cf24f327b49ed23e31858d","author":"hwhsu1231","repoName":"","labels":[],"milestone":"","body":"fix(zh-hant): Distinguish translations of 'Release/Publish'","assignees":[],"requestedReviewers":[],"approvedReviewers":[],"status":"merged"},{"number":0,"title":"feat(lang): add Bengali","htmlURL":"","baseBranch":"","createdAt":"2023-11-05T13:42:26.000Z","mergedAt":"2023-11-05T13:42:26.000Z","mergeCommitSha":"69f9447d5648efb3bb028bc27a2276fcacb9a20d","author":"forhadakhan","repoName":"","labels":[],"milestone":"","body":"feat(lang): add Bengali","assignees":[],"requestedReviewers":[],"approvedReviewers":[],"status":"merged"},{"number":0,"title":"feat(lang): add uzbek translation (#558)","htmlURL":"","baseBranch":"","createdAt":"2024-01-22T07:55:14.000Z","mergedAt":"2024-01-22T07:55:14.000Z","mergeCommitSha":"f777146b5d331c9ee33b0028e861df14e3992fe9","author":"softXengineer","repoName":"","labels":[],"milestone":"","body":"feat(lang): add uzbek translation (#558)","assignees":[],"requestedReviewers":[],"approvedReviewers":[],"status":"merged"},{"number":0,"title":"fix(ko): fix translation typo for message (#567)","htmlURL":"","baseBranch":"","createdAt":"2024-01-29T12:49:09.000Z","mergedAt":"2024-01-29T12:49:09.000Z","mergeCommitSha":"325b74fbc44bf34d9fa645951d076a450b4e26be","author":"Igoc","repoName":"","labels":[],"milestone":"","body":"fix(ko): fix translation typo for message (#567)","assignees":[],"requestedReviewers":[],"approvedReviewers":[],"status":"merged"}],"diffInfo":{"changedFiles":11,"additions":579,"deletions":96,"changes":675,"commits":9,"commitInfo":[{"sha":"fcb21b478f78297850894c71abee35ab98042823","summary":"fix: Fix grammar and consistency in french translation (#546)","message":"fix: Fix grammar and consistency in french translation (#546)","author":"Yopai","authorDate":"2023-10-18T23:36:07.000Z","committer":"web-flow","commitDate":"2023-10-18T23:36:07.000Z"},{"sha":"79d1a4cbdbf9f04eebc531c0e76e7fbb8ebb4b95","summary":"doc: new thi.ng links and descriptions","message":"doc: new thi.ng links and descriptions","author":"postspectacular","authorDate":"2023-10-19T10:44:22.000Z","committer":"web-flow","commitDate":"2023-10-19T10:44:22.000Z"},{"sha":"64ae03aacea2a3cf5271f4217d266db10f2c3043","summary":"fix(ja): fix typo","message":"fix(ja): fix typo","author":"moritasoshi","authorDate":"2023-10-19T10:45:42.000Z","committer":"web-flow","commitDate":"2023-10-19T10:45:42.000Z"},{"sha":"158a7b14ef1f8c24b3e9a7cee97bd0e2c0bd6397","summary":"docs: add link to git-changelog-command-line docker image","message":"docs: add link to git-changelog-command-line docker image","author":"tomasbjerre","authorDate":"2023-10-19T10:47:20.000Z","committer":"web-flow","commitDate":"2023-10-19T10:47:20.000Z"},{"sha":"551cfd47a533f6222d0c9c06af096d4076b48bc9","summary":"docs: Add descriptions for commit types","message":"docs: Add descriptions for commit types","author":"HExris","authorDate":"2023-10-19T10:48:46.000Z","committer":"web-flow","commitDate":"2023-10-19T10:48:46.000Z"},{"sha":"5b935ded2e6b2cbdb3cf24f327b49ed23e31858d","summary":"fix(zh-hant): Distinguish translations of 'Release/Publish'","message":"fix(zh-hant): Distinguish translations of 'Release/Publish'","author":"hwhsu1231","authorDate":"2023-10-19T10:49:51.000Z","committer":"web-flow","commitDate":"2023-10-19T10:49:51.000Z"},{"sha":"69f9447d5648efb3bb028bc27a2276fcacb9a20d","summary":"feat(lang): add Bengali","message":"feat(lang): add Bengali","author":"forhadakhan","authorDate":"2023-11-05T13:42:26.000Z","committer":"web-flow","commitDate":"2023-11-05T13:42:26.000Z"},{"sha":"f777146b5d331c9ee33b0028e861df14e3992fe9","summary":"feat(lang): add uzbek translation (#558)","message":"feat(lang): add uzbek translation (#558)","author":"softXengineer","authorDate":"2024-01-22T07:55:14.000Z","committer":"web-flow","commitDate":"2024-01-22T07:55:14.000Z"},{"sha":"325b74fbc44bf34d9fa645951d076a450b4e26be","summary":"fix(ko): fix translation typo for message (#567)","message":"fix(ko): fix translation typo for message (#567)","author":"Igoc","authorDate":"2024-01-29T12:49:09.000Z","committer":"web-flow","commitDate":"2024-01-29T12:49:09.000Z"}]},"options":{"owner":"conventional-commits","repo":"conventionalcommits.org","fromTag":{"name":"1e1c8e11e6cb7e555e5e53f8eed5ba5fc5029993"},"toTag":{"name":"325b74fbc44bf34d9fa645951d076a450b4e26be"},"includeOpen":false,"failOnError":false,"fetchViaCommits":false,"fetchReviewers":false,"fetchReleaseInformation":false,"fetchReviews":false,"mode":"COMMIT","configuration":{"max_tags_to_fetch":200,"max_pull_requests":200,"max_back_track_time_days":365,"exclude_merge_branches":[],"sort":{"order":"ASC","on_property":"mergedAt"},"template":"#{{CHANGELOG}}","pr_template":"- #{{TITLE}}","empty_template":"- no changes","categories":[{"title":"## 🚀 Features","labels":["feature","feat"]},{"title":"## 🐛 Fixes","labels":["fix","bug"]},{"title":"## 🧪 Tests","labels":["test"]},{"title":"## 📦 Other","labels":[]}],"ignore_labels":["ignore"],"label_extractor":[{"pattern":"^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)","target":"$1"}],"transformers":[],"tag_resolver":{"method":"semver"},"base_branches":[],"custom_placeholders":[],"trim_values":false}}}
Loading

0 comments on commit 2389f61

Please sign in to comment.