generated from actions/typescript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add new ability to recursively build changelog - add feature to consume PRs if they were matched to a category - keep header if children have entry
- Loading branch information
Showing
7 changed files
with
201 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import moment from 'moment' | ||
import {DefaultConfiguration} from '../src/configuration' | ||
import {PullRequestInfo} from '../src/pr-collector/pullRequests' | ||
import {GithubRepository} from '../src/repositories/GithubRepository' | ||
import {clear} from '../src/transform' | ||
import {buildChangelogTest, buildPullRequeset} from './utils' | ||
|
||
jest.setTimeout(180000) | ||
clear() | ||
|
||
const repositoryUtils = new GithubRepository(process.env.GITEA_TOKEN || '', undefined, '.') | ||
|
||
// test set of PRs with lables predefined | ||
const pullRequestsWithLabels: PullRequestInfo[] = [] | ||
pullRequestsWithLabels.push( | ||
buildPullRequeset(1, 'Core Feature Ticket', ['core', 'feature']), | ||
buildPullRequeset(2, 'Core Bug Ticket', ['core', 'bug']), | ||
buildPullRequeset(3, 'Mobile Feature Ticket', ['mobile', 'feature']), | ||
buildPullRequeset(4, 'Mobile Bug Ticket', ['mobile', 'bug']), | ||
buildPullRequeset(5, 'Mobile & Core Feature Ticket', ['core', 'mobile', 'feature']), | ||
buildPullRequeset(6, 'Mobile & Core Bug Ticket', ['core', 'mobile', 'bug']), | ||
buildPullRequeset(7, 'Mobile & Core Bug Bug Ticket', ['core', 'mobile', 'bug', 'fancy-bug']) | ||
) | ||
|
||
it('Match multiple labels exhaustive for category', async () => { | ||
const customConfig = Object.assign({}, DefaultConfiguration) | ||
customConfig.pr_template = '- #{{TITLE}}' | ||
customConfig.categories = [ | ||
{ | ||
title: '## Core', | ||
labels: ['core'], | ||
consume: true, | ||
categories: [ | ||
{ | ||
title: '### 🚀 Features', | ||
labels: ['feature'] | ||
}, | ||
{ | ||
title: '### 🧪 Bug', | ||
labels: ['bug'], | ||
categories: [ | ||
{ | ||
title: '#### 🧪 Bug Bug', | ||
labels: ['fancy-bug'] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
title: '## Mobile', | ||
labels: ['mobile'], | ||
consume: true, | ||
categories: [ | ||
{ | ||
title: '### 🚀 Features', | ||
labels: ['feature'] | ||
}, | ||
{ | ||
title: '### 🧪 Bug', | ||
labels: ['bug'] | ||
} | ||
] | ||
}, | ||
{ | ||
title: '## Desktop', | ||
labels: ['desktop'], | ||
consume: true, | ||
categories: [ | ||
{ | ||
title: '### 🚀 Features', | ||
labels: ['feature'] | ||
}, | ||
{ | ||
title: '### 🧪 Bug', | ||
labels: ['bug'] | ||
} | ||
] | ||
} | ||
] | ||
|
||
expect(buildChangelogTest(customConfig, pullRequestsWithLabels, repositoryUtils)).toStrictEqual(``) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {Configuration} from '../src/configuration' | ||
import {DefaultDiffInfo} from '../src/pr-collector/commits' | ||
import {PullRequestInfo} from '../src/pr-collector/pullRequests' | ||
import {buildChangelog} from '../src/transform' | ||
import {BaseRepository} from '../src/repositories/BaseRepository' | ||
import moment from 'moment' | ||
|
||
export const buildChangelogTest = (config: Configuration, prs: PullRequestInfo[], repositoryUtils: BaseRepository): string => { | ||
return buildChangelog(DefaultDiffInfo, prs, { | ||
owner: 'mikepenz', | ||
repo: 'test-repo', | ||
fromTag: {name: '1.0.0'}, | ||
toTag: {name: '2.0.0'}, | ||
includeOpen: false, | ||
failOnError: false, | ||
fetchReviewers: false, | ||
fetchReleaseInformation: false, | ||
fetchReviews: false, | ||
commitMode: false, | ||
configuration: config, | ||
repositoryUtils | ||
}) | ||
} | ||
|
||
export const buildPullRequeset = (number: number, title: string, labels: string[] = ['feature']): PullRequestInfo => { | ||
return { | ||
number, | ||
title, | ||
htmlURL: '', | ||
baseBranch: '', | ||
createdAt: moment(), | ||
mergedAt: moment(), | ||
mergeCommitSha: 'sha', | ||
author: 'Author', | ||
repoName: 'test-repo', | ||
labels, | ||
milestone: '', | ||
body: '', | ||
assignees: [], | ||
requestedReviewers: [], | ||
approvedReviewers: [], | ||
status: 'merged' | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.