Skip to content

Commit

Permalink
chore(ci): display skipped commits in release issue (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjae-lee authored Apr 26, 2022
1 parent dd04457 commit 7cf7214
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 11 deletions.
30 changes: 30 additions & 0 deletions scripts/release/__tests__/create-release-issue.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
parseCommit,
getVersionChangesText,
getSkippedCommitsText,
decideReleaseStrategy,
readVersions,
} from '../create-release-issue';
Expand Down Expand Up @@ -247,4 +248,33 @@ describe('create release issue', () => {
expect(versions.java.skipRelease).toBeUndefined();
expect(versions.php.skipRelease).toBeUndefined();
});

it('generates text for skipped commits', () => {
expect(
getSkippedCommitsText({
commitsWithoutLanguageScope: [],
commitsWithUnknownLanguageScope: [],
})
).toMatchInlineSnapshot(`"_(None)_"`);

expect(
getSkippedCommitsText({
commitsWithoutLanguageScope: ['abcdefg fix: something'],
commitsWithUnknownLanguageScope: ['abcdef2 fix(pascal): what'],
})
).toMatchInlineSnapshot(`
"<p></p>
<p>It doesn't mean these commits are being excluded from the release. It means they're not taken into account when the release process figured out the next version number, and updated the changelog.</p>
<p>Commits without language scope:</p>
<ul>
<li>abcdefg fix: something</li>
</ul>
<p>Commits with unknown language scope:</p>
<ul>
<li>abcdef2 fix(pascal): what</li>
</ul>"
`);
});
});
46 changes: 35 additions & 11 deletions scripts/release/create-release-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,34 @@ export function getVersionChangesText(versions: Versions): string {
}).join('\n');
}

export function getSkippedCommitsText({
commitsWithoutLanguageScope,
commitsWithUnknownLanguageScope,
}: {
commitsWithoutLanguageScope: string[];
commitsWithUnknownLanguageScope: string[];
}): string {
if (
commitsWithoutLanguageScope.length === 0 &&
commitsWithUnknownLanguageScope.length === 0
) {
return '_(None)_';
}

return `<p></p>
<p>${TEXT.skippedCommitsDesc}</p>
<p>Commits without language scope:</p>
<ul>
${commitsWithoutLanguageScope.map((commit) => `<li>${commit}</li>`)}
</ul>
<p>Commits with unknown language scope:</p>
<ul>
${commitsWithUnknownLanguageScope.map((commit) => `<li>${commit}</li>`)}
</ul>`;
}

export function parseCommit(commit: string): Commit {
const LENGTH_SHA1 = 8;
const hash = commit.slice(0, LENGTH_SHA1);
Expand Down Expand Up @@ -217,24 +245,18 @@ async function createReleaseIssue(): Promise<void> {
})
.filter(Boolean) as PassedCommit[];

console.log('[INFO] Skipping these commits due to lack of language scope:');
console.log(
commitsWithoutLanguageScope.map((commit) => ` ${commit}`).join('\n')
);

console.log('');
console.log('[INFO] Skipping these commits due to unknown language scope:');
console.log(
commitsWithUnknownLanguageScope.map((commit) => ` ${commit}`).join('\n')
);

const versions = decideReleaseStrategy({
versions: readVersions(),
commits: latestCommits,
});

const versionChanges = getVersionChangesText(versions);

const skippedCommits = getSkippedCommitsText({
commitsWithoutLanguageScope,
commitsWithUnknownLanguageScope,
});

const changelogs = LANGUAGES.filter(
(lang) => !versions[lang].noCommit && versions[lang].current
)
Expand All @@ -256,6 +278,8 @@ async function createReleaseIssue(): Promise<void> {
TEXT.header,
TEXT.versionChangeHeader,
versionChanges,
TEXT.skippedCommitsHeader,
skippedCommits,
TEXT.descriptionVersionChanges,
TEXT.indenpendentVersioning,
TEXT.changelogHeader,
Expand Down
2 changes: 2 additions & 0 deletions scripts/release/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export default {
header: `## Summary`,

versionChangeHeader: `## Version Changes`,
skippedCommitsHeader: `### Skipped Commits`,
skippedCommitsDesc: `It doesn't mean these commits are being excluded from the release. It means they're not taken into account when the release process figured out the next version number, and updated the changelog.`,
noCommit: `no commit`,
currentVersionNotFound: `current version not found`,
descriptionVersionChanges: [
Expand Down

0 comments on commit 7cf7214

Please sign in to comment.