Skip to content

Commit

Permalink
Merge pull request #1348 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz authored Jul 26, 2024
2 parents ef7f5f2 + ef820d2 commit c7b3b6d
Show file tree
Hide file tree
Showing 39 changed files with 7,754 additions and 3,360 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ jobs:
uses: mikepenz/release-changelog-builder-action@v4
with:
configuration: "configs/configuration_repo.json"
ignorePreReleases: ${{ !contains(github.ref, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
481 changes: 296 additions & 185 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions __tests__/configuration.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {clear} from '../src/transform'
import {mergeConfiguration, parseConfiguration, resolveConfiguration} from '../src/utils'

jest.setTimeout(180000)
clear()

it('Configurations are merged correctly', async () => {
const configurationJson = parseConfiguration(`{
Expand Down
44 changes: 44 additions & 0 deletions __tests__/demo/demo.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {mergeConfiguration, resolveConfiguration} from '../../src/utils'
import {ReleaseNotesBuilder} from '../../src/releaseNotesBuilder'
import {GithubRepository} from '../../src/repositories/GithubRepository'

jest.setTimeout(180000)

// Define the token to use. Either retrieved from the environment.
// Alternatively provide it as a string right here.
const token = process.env.GITHUB_TOKEN || ''
const githubRepository = new GithubRepository(token, undefined, '.')
it('Test custom changelog builder', async () => {
// define the configuration file to use.
// By default, it retrieves a configuration from a json file
// You can also quickly modify in code.
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))

// Demo to modify the configuration further in code
// configuration.pr_template = "#{{TITLE}}"

const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // The base url used for the API requests (not needed for normal github)
githubRepository, // Repository implementation (allows tu test gitea). Keep default for GitHub
'.', // Root path to the checked out sources. Commonly keep as default
'mikepenz', // The owner of the repo to test
'release-changelog-builder-action-playground', // The repository name
'1.5.0', // `fromTag` The from tag name or the SHA1 of the from commit
'2.0.0', // `toTag` The to tag name or the SHA1 of the to commit
false, // `includeOpen` Define if you want to include open PRs into the changelog
false, // `failOnError` Define if the action should fail on errors
false, // `ignorePrePrerelease` used if no `fromTag` is defined to resolve the prior tag
false, // `fetchViaCommits` enable to fetch via commits
false, // `fetchReviewers` Enables fetching of reviewers for building the changelog (does additional API requests)
false, // `fetchReleaseInformation` Enable to fetch release information (does additional API requests)
false, // `fetchReviews` Enable to fetch reviews of the PRs (does additional API requests)
'PR', // `mode` Set the mode to use [PR, COMMIT, HYBRID]. PR -> builds changelog using PRs, COMMIT -> using commits, HYBRID -> Uses both
false, // `exportCache` Exports the fetched information to the cache. Not relevant for this test
false, // `exportOnly` Enables to only export the fetched information however not build a changelog
null, // `cache` Path to the cache. Not relevant for this test.
configuration // The configuration to use for building the changelog
)

const changeLog = await releaseNotesBuilder.build()
console.log(changeLog)
})
30 changes: 16 additions & 14 deletions __tests__/gitea/releaseNotesBuilderGitea.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {mergeConfiguration, resolveConfiguration} from '../../src/utils'
import {ReleaseNotesBuilder} from '../../src/releaseNotesBuilder'
import {GiteaRepository} from '../../src/repositories/GiteaRepository'
import {clear} from '../../src/transform'

jest.setTimeout(180000)
clear()

/**
* Before starting testing, you should manually clone the repository
Expand Down Expand Up @@ -36,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 @@ -76,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 @@ -113,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 @@ -149,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 @@ -200,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 @@ -308,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 @@ -417,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 @@ -482,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 @@ -556,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 @@ -633,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 @@ -671,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 @@ -712,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 @@ -744,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 @@ -778,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
41 changes: 22 additions & 19 deletions __tests__/gitea/releaseNotesBuilderPullGitea.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
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()

// load octokit instance
const enablePullData = false
Expand Down Expand Up @@ -45,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 @@ -83,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 @@ -122,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 @@ -179,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 @@ -241,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 @@ -298,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
2 changes: 2 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import * as path from 'path'
import * as process from 'process'
import * as cp from 'child_process'
import * as fs from 'fs'
import {clear} from '../src/transform'

jest.setTimeout(180000)
clear()

test('missing values should result in failure', () => {
expect.assertions(1)
Expand Down
Loading

0 comments on commit c7b3b6d

Please sign in to comment.