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

Introduce fetchViaCommits configuration | Offers a new feature to solve an edge case resulting in old PRs not being included in changelog for squash merges #1180

Merged
merged 6 commits into from
Jul 28, 2023
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ For advanced use cases additional settings can be provided to the action
| `includeOpen` | Enables to also fetch currently open PRs. Default: false |
| `ignorePreReleases` | Allows to ignore pre-releases for changelog generation (E.g. for 1.0.1... 1.0.0-rc02 <- ignore, 1.0.0 <- pick). Only used if `fromTag` was not specified. Default: false |
| `failOnError` | Defines if the action will result in a build failure if problems occurred. Default: false |
| `fetchViaCommits` | Enables PRs to get fetched via the commits identified between from->to tag. This will do 1 API request per commit -> Best for scenarios with squash merges | Or shorter from->to diffs (< 10 commits) | Also effective for shorters diffs for very old PRs. Default: false |
| `fetchReviewers` | Will enable fetching the users/reviewers who approved the PR. Default: false |
| `fetchReleaseInformation` | Will enable fetching additional release information from tags. Default: false |
| `fetchReviews` | Will enable fetching the reviews on of the PR. Default: false |
Expand Down
14 changes: 14 additions & 0 deletions __tests__/releaseNotesBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
false,
false,
false,
true, // enable to fetch via commits
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down Expand Up @@ -47,6 +48,7 @@ it('Should match generated changelog (unspecified tags)', async () => {
false,
false,
false,
false, // enable to fetch via commits
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
Expand All @@ -73,6 +75,7 @@ it('Should use empty placeholder', async () => {
false,
false,
false,
true, // enable to fetch via commits
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
Expand All @@ -99,6 +102,7 @@ it('Should fill empty placeholders', async () => {
false,
false,
false,
true, // enable to fetch via commits
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down Expand Up @@ -127,6 +131,7 @@ it('Should fill `template` placeholders', async () => {
false,
false,
false,
true, // enable to fetch via commits
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down Expand Up @@ -156,6 +161,7 @@ it('Should fill `template` placeholders, ignore', async () => {
false,
false,
false,
false, // enable to fetch via commits
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down Expand Up @@ -184,6 +190,7 @@ it('Uncategorized category', async () => {
false,
false,
false,
false, // enable to fetch via commits
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down Expand Up @@ -212,6 +219,7 @@ it('Verify commit based changelog', async () => {
false,
false,
false,
true, // enable to fetch via commits
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down Expand Up @@ -240,6 +248,7 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
false,
false,
false,
false, // enable to fetch via commits
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down Expand Up @@ -268,6 +277,7 @@ it('Verify default inclusion of open PRs', async () => {
true, // includeOpen
false, // failOnError
false, // ignorePrePrelease
false, // enable to fetch via commits
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down Expand Up @@ -296,6 +306,7 @@ it('Verify custom categorisation of open PRs', async () => {
true, // includeOpen
false, // failOnError
false, // ignorePrePrelease
false, // enable to fetch via commits
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down Expand Up @@ -324,6 +335,7 @@ it('Verify reviewers who approved are fetched and also release information', asy
true, // includeOpen
false, // failOnError
false, // ignorePrePrelease
false, // enable to fetch via commits
true, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down Expand Up @@ -353,6 +365,7 @@ it('Fetch release information', async () => {
true, // includeOpen
false, // failOnError
false, // ignorePrePrelease
false, // enable to fetch via commits
false, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down Expand Up @@ -380,6 +393,7 @@ it('Fetch release information for non existing tag / release', async () => {
true, // includeOpen
false, // failOnError
false, // ignorePrePrelease
false, // enable to fetch via commits
false, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
Expand Down
14 changes: 12 additions & 2 deletions __tests__/releaseNotesBuilderPull.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {mergeConfiguration, resolveConfiguration} from '../src/utils'
import {Octokit} from '@octokit/rest'
import {buildChangelog} from '../src/transform'
import { pullData } from 'github-pr-collector'
import {pullData} from 'github-pr-collector'

jest.setTimeout(180000)

Expand All @@ -20,6 +20,7 @@ it('Should have empty changelog (tags)', async () => {
toTag: {name: 'v0.0.2'},
includeOpen: false,
failOnError: false,
fetchViaCommits: true,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
Expand All @@ -41,6 +42,7 @@ it('Should match generated changelog (tags)', async () => {
toTag: {name: 'v0.0.3'},
includeOpen: false,
failOnError: false,
fetchViaCommits: true,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
Expand All @@ -61,14 +63,15 @@ it('Should match generated changelog (tags)', async () => {

it('Should match generated changelog (refs)', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_all_placeholders.json'))

const options = {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: {name: '5ec7a2d86fe9f43fdd38d5e254a1117c8a51b4c3'},
toTag: {name: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa'},
includeOpen: false,
failOnError: false,
fetchViaCommits: true,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
Expand Down Expand Up @@ -104,6 +107,7 @@ it('Should match generated changelog and replace all occurrences (refs)', async
toTag: {name: 'fa3788c8c4b3373ef8424ce3eb008a5cd07cc5aa'},
includeOpen: false,
failOnError: false,
fetchViaCommits: true,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
Expand Down Expand Up @@ -141,6 +145,7 @@ it('Should match ordered ASC', async () => {
toTag: {name: 'v0.5.0'},
includeOpen: false,
failOnError: false,
fetchViaCommits: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
Expand All @@ -164,6 +169,7 @@ it('Should match ordered DESC', async () => {
toTag: {name: 'v0.5.0'},
includeOpen: false,
failOnError: false,
fetchViaCommits: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
Expand All @@ -186,6 +192,7 @@ it('Should match ordered by title ASC', async () => {
toTag: {name: 'v0.5.0'},
includeOpen: false,
failOnError: false,
fetchViaCommits: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
Expand All @@ -209,6 +216,7 @@ it('Should match ordered by title DESC', async () => {
toTag: {name: 'v0.5.0'},
includeOpen: false,
failOnError: false,
fetchViaCommits: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
Expand All @@ -233,6 +241,7 @@ it('Should ignore PRs not merged into develop branch', async () => {
toTag: {name: 'v1.4.0'},
includeOpen: false,
failOnError: false,
fetchViaCommits: true,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
Expand All @@ -254,6 +263,7 @@ it('Should ignore PRs not merged into main branch', async () => {
toTag: {name: 'v1.4.0'},
includeOpen: false,
failOnError: false,
fetchViaCommits: true,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/tags.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TagInfo, filterTags, prepareAndSortTags } from "github-pr-collector/lib/tags"
import {TagInfo, filterTags, prepareAndSortTags} from 'github-pr-collector/lib/tags'

jest.setTimeout(180000)

Expand Down
12 changes: 5 additions & 7 deletions __tests__/transform.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {buildChangelog} from '../src/transform'
import moment from 'moment'
import {Configuration, DefaultConfiguration} from '../src/configuration'
import { PullRequestInfo } from 'github-pr-collector/lib/pullRequests'
import { DefaultDiffInfo } from 'github-pr-collector/lib/commits'
import {PullRequestInfo} from 'github-pr-collector/lib/pullRequests'
import {DefaultDiffInfo} from 'github-pr-collector/lib/commits'

jest.setTimeout(180000)

Expand Down Expand Up @@ -409,16 +409,14 @@ it('Reference PRs', async () => {
labels: []
}
]
customConfig.pr_template = "${{NUMBER}} -- ${{REFERENCED[*].number}}"
customConfig.pr_template = '${{NUMBER}} -- ${{REFERENCED[*].number}}'
customConfig.reference = {
pattern: '.*\ \#(.).*', // matches the 1 from "abcdefg #1 adfasdf"
pattern: '.* #(.).*', // matches the 1 from "abcdefg #1 adfasdf"
on_property: 'body',
method: 'replace',
target: '$1'
}
expect(buildChangelogTest(customConfig, pullRequestsWithLabels)).toStrictEqual(
`1 -- 2\n4 -- \n3 -- \n\n`
)
expect(buildChangelogTest(customConfig, pullRequestsWithLabels)).toStrictEqual(`1 -- 2\n4 -- \n3 -- \n\n`)
})

it('Use empty_content for empty category', async () => {
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ inputs:
failOnError:
description: 'Defines if the action should result in a build failure, if an error was discovered'
default: "false"
fetchViaCommits:
description: 'Defines if PRs are fetched via the commits identified. This will do 1 API request per commit -> Best for scenarios with squash merges | Or shorter from-to diffs (< 10 commits) | Also effective for shorters diffs for very old PRs'
default: "false"
fetchReviewers:
description: 'Will enable fetching the users/reviewers who approved the PR'
default: "false"
Expand Down
Loading
Loading