Enhance labeling workflow (#37324)

Summary:
This PR does two things:
1. Improves the labeling workflow in cases where the user is on a supported version but a higher patch number is available. Now, the label name will be friendlier ('Newer Patch Available') and we will report the version they should consider upgrading to in the message body. Once this change is merged, I can also rename all existing versions of this label for consistency.
2. Moves the addDescriptiveLabels.js script to the workflow-scripts folder for consistency with the other workflow scripts.

## Changelog:

[INTERNAL] [CHANGED] - Enhancing issue triage workflow for patch versioning

Pull Request resolved: https://github.com/facebook/react-native/pull/37324

Test Plan: See some examples of the workflow run in my fork: https://github.com/SlyCaptainFlint/react-native/issues

Reviewed By: cipolleschi

Differential Revision: D45680812

Pulled By: NickGerleman

fbshipit-source-id: 7ab07fcf52fe372d2e449bb43d6618b1c98e9245
This commit is contained in:
Olga Zinoveva
2023-05-09 10:19:47 -07:00
committed by Facebook GitHub Bot
parent e0f43fdf89
commit b6f269e8a3
4 changed files with 16 additions and 13 deletions
+4 -4
View File
@@ -7,7 +7,7 @@
* @format
*/
module.exports = async (github, context, label) => {
module.exports = async (github, context, labelWithContext) => {
const closeIssue = async () => {
await github.rest.issues.update({
issue_number: context.issue.number,
@@ -45,7 +45,7 @@ module.exports = async (github, context, label) => {
});
};
switch (label) {
switch (labelWithContext.label) {
case 'Type: Invalid':
await addComment(
`| :warning: | Issue is Invalid |\n` +
@@ -102,11 +102,11 @@ module.exports = async (github, context, label) => {
);
await requestAuthorFeedback();
return;
case 'Needs: Verify on Latest Version':
case 'Newer Patch Available':
await addComment(
`| :warning: | Newer Version of React Native is Available! |\n` +
`| --- | --- |\n` +
`| :information_source: | You are on a supported minor version, but it looks like there's a newer patch available. Please [upgrade](https://reactnative.dev/docs/upgrading) to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases. |`,
`| :information_source: | You are on a supported minor version, but it looks like there's a newer patch available - ${labelWithContext.newestPatch}. Please [upgrade](https://reactnative.dev/docs/upgrading) to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases. |`,
);
return;
case 'Needs: Version Info':
@@ -0,0 +1,154 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
module.exports = async (github, context) => {
const issue = context.payload.issue;
const title = issue?.title?.toLowerCase();
if (!title) return;
const addLabels = async labelsToAdd => {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labelsToAdd,
});
};
const labelsToAdd = [];
for (const component of components) {
if (title.includes(component.toLowerCase())) {
labelsToAdd.push(`Component: ${component}`);
}
}
for (const api of apis) {
if (title.includes(api.toLowerCase())) {
labelsToAdd.push(`API: ${api}`);
}
}
for (const topic of Object.keys(topics)) {
if (title.includes(topic.toLowerCase())) {
labelsToAdd.push(topics[topic]);
}
}
if (labelsToAdd.length > 0) {
await addLabels(labelsToAdd);
}
};
const labelAndroid = 'Platform: Android';
const labelIos = 'Platform: iOS';
const labelTvos = 'Platform: tvOS';
const labelNetworking = '🌐Networking';
const labelBundler = '📦Bundler';
const labelCli = '💻CLI';
const labelRegression = 'Impact: Regression';
const components = [
'ActivityIndicator',
'Button',
'DatePickerIOS',
'DrawerLayoutAndroid',
'FlatList',
'Image',
'ImageBackground',
'InputAccessoryView',
'KeyboardAvoidingView',
'ListView',
'MaskedViewIOS',
'Modal',
'NavigatorIOS',
'Picker',
'PickerIOS',
'ProgressBarAndroid',
'ProgressViewIOS',
'RefreshControl',
'SafeAreaView',
'ScrollView',
'SectionList',
'SegmentedControlIOS',
'Slider',
'SnapshotViewIOS',
'StatusBar',
'Switch',
'TabBarIOS',
'TextInput',
'ToolbarAndroid',
'TouchableHighlight',
'TouchableNativeFeedback',
'TouchableOpacity',
'TouchableWithoutFeedback',
'ViewPagerAndroid',
'VirtualizedList',
'WebView',
];
const apis = [
'AccessibilityInfo',
'ActionSheetIOS',
'Alert',
'AlertIOS',
'Animated',
'AppRegistry',
'AppState',
'AsyncStorage',
'BackAndroid',
'BackHandler',
'CameraRoll',
'Clipboard',
'DatePickerAndroid',
'Dimensions',
'Easing',
'Geolocation',
'ImageEditor',
'ImagePickerIOS',
'ImageStore',
'InteractionManager',
'Keyboard',
'LayoutAnimation',
'Linking',
'ListViewDataSource',
'NetInfo',
'PanResponder',
'PermissionsAndroid',
'PixelRatio',
'PushNotificationIOS',
'Settings',
'Share',
'StatusBarIOS',
'StyleSheet',
'Systrace',
'TimePickerAndroid',
'ToastAndroid',
'Transforms',
'Vibration',
'VibrationIOS',
];
const topics = {
Flow: 'Flow',
'Flow-Strict': 'Flow',
xhr: labelNetworking,
netinfo: labelNetworking,
fetch: labelNetworking,
okhttp: labelNetworking,
http: labelNetworking,
bundle: labelBundler,
bundling: labelBundler,
packager: labelBundler,
'unable to resolve module': labelBundler,
android: labelAndroid,
ios: labelIos,
tvos: labelTvos,
'react-native-cli': labelCli,
'react-native upgrade': labelCli,
'react-native link': labelCli,
'local-cli': labelCli,
regression: labelRegression,
};
+6 -3
View File
@@ -23,7 +23,7 @@ module.exports = async (github, context) => {
if (reportedVersionIsNightly(issueVersionUnparsed, issueVersion)) return;
if (!issueVersion) {
return 'Needs: Version Info';
return {label: 'Needs: Version Info'};
}
// Ensure the version matches one we support
@@ -43,7 +43,7 @@ module.exports = async (github, context) => {
const latestVersion = parseVersionFromString(latestRelease.name);
if (!isVersionSupported(issueVersion, latestVersion)) {
return 'Type: Unsupported Version';
return {label: 'Type: Unsupported Version'};
}
// We want to encourage users to repro the issue on the highest available patch for the given minor.
@@ -52,7 +52,10 @@ module.exports = async (github, context) => {
recentReleases,
);
if (latestPatchForVersion > issueVersion.patch) {
return 'Needs: Verify on Latest Version';
return {
label: 'Newer Patch Available',
newestPatch: `${issueVersion.major}.${issueVersion.minor}.${latestPatchForVersion}`,
};
}
};