-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat: Triage bot v2 #33555
Draft
Hotell
wants to merge
7
commits into
microsoft:master
Choose a base branch
from
Hotell:triage-bot/codeowners
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+783
−33
Draft
feat: Triage bot v2 #33555
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
56210cd
feat(triage-bot): implement raw codeowners parser
Hotell 773c9e5
feat(triage-bot): add v2 schema and config
Hotell f371e8f
feat(workspace-plugin): implement stories-map generator to generate a…
Hotell 381d8ee
chore: add @types/github-script for better DX regarding GHA types for…
Hotell 1ae5a6e
feat(triage-bot): start v2 impl
Hotell 48d6474
ci: update react-components-bug-report list
Hotell 570e31e
docs(react-carousel): normalize title creation within storybook menu
Hotell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | |||||||||||||||||
{ | |||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🕵🏾♀️ visual regressions to review in the fluentuiv9 Visual Regression ReportAvatar Converged 1 screenshots
Drawer 2 screenshots
|
|||||||||||||||||
"$schema": "../scripts/triage-bot/triage-bot.schema-v2.json", | |||||||||||||||||
"params": [ | |||||||||||||||||
{ | |||||||||||||||||
"frameworkType": "Fluent UI react-components (v9)", | |||||||||||||||||
"headingToParse": "Component", | |||||||||||||||||
"mapping": { | |||||||||||||||||
"packages/react-components/react-accordion": ["Accordion"], | |||||||||||||||||
"packages/react-components/react-avatar": ["Avatar", "AvatarGroup"], | |||||||||||||||||
"packages/react-components/react-utilities": ["Utilities"], | |||||||||||||||||
"packages/react-components/react-provider": ["FluentProvider"], | |||||||||||||||||
"packages/react-components/react-migration-v0-v9": ["Migration Shims v0"], | |||||||||||||||||
"packages/react-components/react-migration-v8-v9": ["Migration Shims v8"] | |||||||||||||||||
} | |||||||||||||||||
}, | |||||||||||||||||
{ | |||||||||||||||||
"frameworkType": "Fluent UI react (v8)", | |||||||||||||||||
"headingToParse": "Package", | |||||||||||||||||
"mapping": { | |||||||||||||||||
"packages/azure-themes": ["azure-themes"] | |||||||||||||||||
} | |||||||||||||||||
} | |||||||||||||||||
] | |||||||||||||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* | ||
* @param {Array<import('./types').FileOwnershipMatcher>} rules | ||
*/ | ||
function serialize(rules) { | ||
return rules | ||
.map(rule => { | ||
return [rule.path, rule.owners].join(' '); | ||
}) | ||
.join('\n'); | ||
} | ||
|
||
/** | ||
* | ||
* @param {string} content | ||
*/ | ||
function parse(content) { | ||
/** @type {Array<import('./types').FileOwnershipMatcher>} */ | ||
const rules = []; | ||
|
||
if (content.length === 0) { | ||
return rules; | ||
} | ||
|
||
const rawLines = content.trim().split('\n'); | ||
|
||
for (const rawLine of rawLines) { | ||
const line = rawLine.trim(); | ||
|
||
if (!line || line.startsWith('#')) { | ||
continue; | ||
} | ||
|
||
rules.push(createRule(line)); | ||
} | ||
|
||
return rules; | ||
} | ||
|
||
/** | ||
* | ||
* @param {string} rule | ||
* @returns {import('./types').FileOwnershipMatcher} | ||
*/ | ||
function createRule(rule) { | ||
const rawParts = rule.split(/\s+/); | ||
/** @type {string[]} */ | ||
const parts = []; | ||
for (const part of rawParts) { | ||
if (part.startsWith('#')) { | ||
break; | ||
} | ||
parts.push(part); | ||
} | ||
|
||
// The first part is expected to be the path | ||
const path = parts[0]; | ||
|
||
// Rest of parts is expected to be the owners | ||
const owners = parts.length > 1 ? parts.slice(1, parts.length) : []; | ||
|
||
return { path, owners }; | ||
} | ||
|
||
exports.serialize = serialize; | ||
exports.parse = parse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { parse, serialize } from './codeowners-parser'; // Replace with the actual module path | ||
|
||
describe('#serialize', () => { | ||
it('should return an empty string when rules are empty', () => { | ||
const result = serialize([]); | ||
expect(result).toEqual(''); | ||
}); | ||
|
||
it(`should return valid codeowners file based on rules`, () => { | ||
const result = serialize([ | ||
{ path: 'src/*.js', owners: ['@owner1', '@[email protected]'] }, | ||
{ path: 'docs/*.md', owners: ['@owner3'] }, | ||
]); | ||
expect(result).toMatchInlineSnapshot(` | ||
"src/*.js @owner1,@[email protected] | ||
docs/*.md @owner3" | ||
`); | ||
}); | ||
}); | ||
|
||
describe('#parse', () => { | ||
it('should return an empty array when content is empty', () => { | ||
const result = parse(''); | ||
expect(result).toEqual([]); | ||
}); | ||
|
||
it('should return an empty array when content only contains comments', () => { | ||
const content = ` | ||
# This is a comment | ||
# Another comment line | ||
`; | ||
const result = parse(content); | ||
expect(result).toEqual([]); | ||
}); | ||
|
||
it('should parse a single rule correctly', () => { | ||
const content = ` | ||
src/*.js @owner1 @owner2 @team/one [email protected] | ||
`; | ||
const result = parse(content); | ||
expect(result).toEqual([ | ||
{ | ||
path: 'src/*.js', | ||
owners: ['@owner1', '@owner2', '@team/one', '[email protected]'], | ||
}, | ||
]); | ||
}); | ||
|
||
it('should ignore inline comments after rules', () => { | ||
const content = ` | ||
src/*.js @owner1 @owner2 # inline comment | ||
`; | ||
const result = parse(content); | ||
expect(result).toEqual([ | ||
{ | ||
path: 'src/*.js', | ||
owners: ['@owner1', '@owner2'], | ||
}, | ||
]); | ||
}); | ||
|
||
it('should parse multiple rules correctly', () => { | ||
const content = ` | ||
src/*.js @owner1 @owner2 | ||
docs/*.md @owner3 | ||
# A comment | ||
assets/*.png | ||
`; | ||
const result = parse(content); | ||
expect(result).toEqual([ | ||
{ | ||
path: 'src/*.js', | ||
owners: ['@owner1', '@owner2'], | ||
}, | ||
{ | ||
path: 'docs/*.md', | ||
owners: ['@owner3'], | ||
}, | ||
{ | ||
path: 'assets/*.png', | ||
owners: [], | ||
}, | ||
]); | ||
}); | ||
|
||
it('should trim whitespace from lines and handle empty lines', () => { | ||
const content = ` | ||
src/*.js @owner1 @owner2 | ||
|
||
docs/*.md @owner3 | ||
|
||
# Comment | ||
`; | ||
const result = parse(content); | ||
expect(result).toEqual([ | ||
{ | ||
path: 'src/*.js', | ||
owners: ['@owner1', '@owner2'], | ||
}, | ||
{ | ||
path: 'docs/*.md', | ||
owners: ['@owner3'], | ||
}, | ||
]); | ||
}); | ||
|
||
it('should handle rules with no owners', () => { | ||
const content = ` | ||
src/*.js | ||
docs/*.md | ||
`; | ||
const result = parse(content); | ||
expect(result).toEqual([ | ||
{ | ||
path: 'src/*.js', | ||
owners: [], | ||
}, | ||
{ | ||
path: 'docs/*.md', | ||
owners: [], | ||
}, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
|
||
/** @typedef {import('github-script').AsyncFunctionArguments} AsyncFunctionArguments */ | ||
|
||
/** | ||
* | ||
* @param {AsyncFunctionArguments} options | ||
*/ | ||
async function main(options) { | ||
const { context, github } = options; | ||
|
||
const issueNumber = context.payload?.issue?.number; | ||
|
||
if (!issueNumber) { | ||
throw new Error('no issue number provided!'); | ||
} | ||
|
||
const issue = await github.rest.issues.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issueNumber, | ||
}); | ||
|
||
const issueMD = issue.data.body; | ||
|
||
// 1. todo parse markdown | ||
// 2. extract Component string `## Component > content` | ||
// 3. assign Labels based on Component | ||
// 4. assign code-owners based on Labels | ||
console.log(issueMD); | ||
} | ||
|
||
module.exports = main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕵🏾♀️ visual regressions to review in the fluentuiv8 Visual Regression Report
react-charting-AreaChart 1 screenshots
react-charting-LineChart 1 screenshots