dx: PR labels re-revamp (#4016)

This is a followup to https://github.com/tldraw/tldraw/pull/3112 after a
discussion with Alex about how our release notes writing is really
manual now.

This changes the labels to be a more limited set.

It also adds a plugin to help massage the release notes into what we
want it to be:
- ignores bot commits
- use the release notes, if found, not the commit msg
- skip writing the "release notes" in general, just create the changelog
which is what we want anyway.

### Change Type

<!--  Please select a 'Scope' label ️ -->

- [ ] `sdk` — Changes the tldraw SDK
- [ ] `dotcom` — Changes the tldraw.com web app
- [ ] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [ ] `internal` — Does not affect user-facing stuff

<!--  Please select a 'Type' label ️ -->

- [ ] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [ ] `improvement` — Improving existing features
- [ ] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [ ] `tools` — Changes to infrastructure, CI, internal scripts,
debugging tools, etc.
- [ ] `dunno` — I don't know
This commit is contained in:
Mime Čuvalo 2024-06-26 12:06:15 +01:00 committed by GitHub
parent a2ebf2984b
commit 65a6890584
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 62 additions and 67 deletions

View file

@ -26,6 +26,7 @@ apps/vscode/extension/editor/index.js
apps/vscode/extension/editor/tldraw-assets.json
**/sentry.server.config.js
**/scripts/upload-sourcemaps.js
**/scripts/lib/auto-plugin.js
**/coverage/**/*
apps/dotcom/public/sw.js

View file

@ -2,24 +2,14 @@ Describe what your pull request does. If appropriate, add GIFs or images showing
### Change Type
<!-- ❗ Please select a 'Scope' label ❗️ -->
- [ ] `sdk` — Changes the tldraw SDK
- [ ] `dotcom` — Changes the tldraw.com web app
- [ ] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [ ] `internal` — Does not affect user-facing stuff
<!-- ❗ Please select a 'Type' label ❗️ -->
- [ ] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [ ] `improvement` — Improving existing features
- [ ] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [ ] `tools` — Changes to infrastructure, CI, internal scripts, debugging tools, etc.
- [ ] `dunno` — I don't know
- [ ] `improvement` — Product improvement
- [ ] `api` — API change
- [ ] `bugfix` — Bug fix
- [ ] `other` — Changes that don't affect SDK users, e.g. internal or .com changes
### Test Plan

View file

@ -56,6 +56,10 @@ export const enforcePrLabels: Flow = {
return fail('Please add a label to the PR.')
}
if (pull.body?.includes('Add a brief release note for your PR here.')) {
return fail('Add a release note to the PR body.')
}
// add any labels that are checked
console.log('adding labels')
if (selectedReleaseLabels.length > 0) {

View file

@ -0,0 +1,35 @@
module.exports = class AutoPlugin {
constructor() {
this.name = 'tldraw'
}
apply(auto) {
// Exclude bots.
auto.hooks.onCreateLogParse.tap(this.name, (changelog) =>
changelog.hooks.omitCommit.tap(this.name, (commit) =>
commit.authors.some((author) => author.type === 'Bot')
)
)
// Render the release note line, not the commit line.
auto.hooks.onCreateChangelog.tap(this.name, (changelog) =>
changelog.hooks.renderChangelogLine.tap(this.name, async (line, commit) => {
const releaseNote = /### Release Notes\n\n-(.*)/g.exec(
commit.pullRequest.body.replaceAll('\r\n', '\n')
)
return releaseNote
? `- ${releaseNote[1].trim()} [#${commit.pullRequest.number}](https://github.com/tldraw/tldraw/pull/${commit.pullRequest.number})`
: line
})
)
// Only write out changelog, not release notes (they're not very good).
auto.hooks.onCreateChangelog.tap(this.name, (changelog) =>
changelog.hooks.omitReleaseNotes.tap(this.name, (commit) => true)
)
}
}
function uniq(value, index, array) {
return array.indexOf(value) === index
}

View file

@ -10,63 +10,32 @@ interface Label {
changelogTitle: string
}
const SCOPE_LABELS = [
{
name: `sdk`,
description: `Changes the tldraw SDK`,
changelogTitle: '📚 SDK Changes',
},
{
name: `dotcom`,
description: `Changes the tldraw.com web app`,
changelogTitle: '🖥️ tldraw.com Changes',
},
{
name: `docs`,
description: `Changes to the documentation, examples, or templates.`,
changelogTitle: '📖 Documentation changes',
},
{
name: `vs code`,
description: `Changes to the vscode plugin`,
changelogTitle: '👩‍💻 VS Code Plugin Changes',
},
{
name: `internal`,
description: `Does not affect user-facing stuff`,
changelogTitle: '🕵️‍♀️ Internal Changes',
},
] as const satisfies Label[]
const TYPE_LABELS = [
{ name: `bugfix`, description: `Bug fix`, changelogTitle: '🐛 Bug Fixes' },
{ name: `feature`, description: `New feature`, changelogTitle: '🚀 Features' },
{
name: `feature`,
description: `New feature`,
changelogTitle: '🎉 New Features',
},
{
name: `improvement`,
description: `Improving existing features`,
changelogTitle: '💄 Improvements',
description: `Product improvement`,
changelogTitle: '💄 Product Improvements',
},
{
name: `chore`,
description: `Updating dependencies, other boring stuff`,
changelogTitle: '🧹 Chores',
name: `api`,
description: `API change`,
changelogTitle: '🛠️ API Changes',
},
{ name: `bugfix`, description: `Bug fix`, changelogTitle: '🐛 Bug Fixes' },
{
name: `galaxy brain`,
description: `Architectural changes`,
changelogTitle: '🤯 Architectural changes',
name: `other`,
description: `Changes that don't affect SDK users, e.g. internal or .com changes`,
changelogTitle: '🤷 Other',
},
{ name: `tests`, description: `Changes to any test code`, changelogTitle: '🧪 Tests' },
{
name: `tools`,
description: `Changes to infrastructure, CI, internal scripts, debugging tools, etc.`,
changelogTitle: '🛠️ Tools',
},
{ name: `dunno`, description: `I don't know`, changelogTitle: '🤷 Dunno' },
] as const satisfies Label[]
export function getLabelNames() {
return [...SCOPE_LABELS, ...TYPE_LABELS].map((label) => label.name)
return [...TYPE_LABELS].map((label) => label.name)
}
function formatTemplateOption(label: Label) {
@ -74,11 +43,7 @@ function formatTemplateOption(label: Label) {
}
export function formatLabelOptionsForPRTemplate() {
let result = `<!-- ❗ Please select a 'Scope' label ❗️ -->\n\n`
for (const label of SCOPE_LABELS) {
result += formatTemplateOption(label) + '\n'
}
result += `\n<!-- ❗ Please select a 'Type' label ❗️ -->\n\n`
let result = `\n<!-- ❗ Please select a 'Type' label ❗️ -->\n\n`
for (const label of TYPE_LABELS) {
result += formatTemplateOption(label) + '\n'
}
@ -88,8 +53,8 @@ export function formatLabelOptionsForPRTemplate() {
export async function generateAutoRcFile() {
const autoRcPath = join(REPO_ROOT, '.autorc')
await writeJsonFile(autoRcPath, {
plugins: ['npm'],
labels: [...SCOPE_LABELS, ...TYPE_LABELS].map(({ name, changelogTitle }) => ({
plugins: ['npm', '../scripts/lib/auto-plugin.js'],
labels: [...TYPE_LABELS.filter((l) => l.name !== 'other')].map(({ name, changelogTitle }) => ({
name,
changelogTitle,
releaseType: 'none',