Skip to content
Snippets Groups Projects
Unverified Commit 75bd6557 authored by Ryan Laurie's avatar Ryan Laurie Committed by GitHub
Browse files

Hide docs issues in release notes (#45037)

parent 67f0ea16
Branches
Tags
No related merge requests found
export const nonUserFacingLabels = [
'.CI & Tests',
'.Building & Releasing',
];
export const hiddenLabels = [
'Type:Documentation',
];
\ No newline at end of file
];
import { match } from 'ts-pattern';
import { nonUserFacingLabels } from "./constants";
import { nonUserFacingLabels, hiddenLabels } from "./constants";
import { getMilestoneIssues, isLatestRelease, hasBeenReleased } from "./github";
import type { ReleaseProps, Issue } from "./types";
import {
......@@ -70,6 +70,10 @@ const isNonUserFacingIssue = (issue: Issue) => {
return nonUserFacingLabels.some(label => hasLabel(issue, label));
}
const isHiddenIssue = (issue: Issue) => {
return hiddenLabels.some(label => hasLabel(issue, label));
}
const formatIssue = (issue: Issue) => `- ${issue.title.trim()} (#${issue.number})`;
export const getDockerTag = (version: string) => {
......@@ -109,18 +113,20 @@ const issueMap: Record<IssueType, Issue[]> = {
};
export const categorizeIssues = (issues: Issue[]) => {
return issues.reduce((issueMap, issue) => {
const category: IssueType = match(issue)
.when(isNonUserFacingIssue, () => IssueType.underTheHoodIssues)
.when(isAlreadyFixedIssue, () => IssueType.alreadyFixedIssues)
.when(isBugIssue, () => IssueType.bugFixes)
.otherwise(() => IssueType.enhancements);
return {
...issueMap,
[category]: [...issueMap[category], issue],
}
}, { ...issueMap });
return issues
.filter(issue => !isHiddenIssue(issue))
.reduce((issueMap, issue) => {
const category: IssueType = match(issue)
.when(isNonUserFacingIssue, () => IssueType.underTheHoodIssues)
.when(isAlreadyFixedIssue, () => IssueType.alreadyFixedIssues)
.when(isBugIssue, () => IssueType.bugFixes)
.otherwise(() => IssueType.enhancements);
return {
...issueMap,
[category]: [...issueMap[category], issue],
}
}, { ...issueMap });
};
export const generateReleaseNotes = ({
......
......@@ -78,7 +78,7 @@ describe("Release Notes", () => {
expect(notes).toContain("**Enhancements**\n\n- Feature Issue (#2)");
expect(notes).toContain("**Bug fixes**\n\n- Bug Issue (#1)");
expect(notes).toContain("**Already Fixed**\n\nIssues that we have recently confirmed to have been fixed at some point in the past.\n\n- Issue Already Fixed (#3)");;
expect(notes).toContain("**Already Fixed**\n\nIssues that we have recently confirmed to have been fixed at some point in the past.\n\n- Issue Already Fixed (#3)");
expect(notes).toContain("**Under the Hood**\n\n- Issue That Users Don't Care About (#4)");
expect(notes).toContain("metabase/metabase-enterprise:v1.2.3");
......@@ -152,6 +152,21 @@ describe("Release Notes", () => {
expect(categorizedIssues.enhancements).toEqual([]);
});
it('should omit hidden issues', () => {
const issue = {
number: 5,
title: "Docs Issue",
labels: [{ name: "Type:Documentation" }],
} as Issue;
const categorizedIssues = categorizeIssues([issue]);
expect(categorizedIssues.enhancements).toEqual([]);
expect(categorizedIssues.bugFixes).toEqual([]);
expect(categorizedIssues.alreadyFixedIssues).toEqual([]);
expect(categorizedIssues.underTheHoodIssues).toEqual([]);
});
it('should put issues in only one bucket', () => {
const issues = [
{
......@@ -176,6 +191,11 @@ describe("Release Notes", () => {
},
{
number: 5,
title: "Non User Facing Issue 2",
labels: [{ name: ".Building & Releasing" }],
},
{
number: 6,
title: "Docs Issue",
labels: [{ name: "Type:Documentation" }],
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment