Skip to content

Commit 28dfdb2

Browse files
Pranav-yadavfacebook-github-bot
authored andcommitted
Auto close issue if version is too old (#38041)
Summary: *Auto-close* an issue when the version of React Native specified is **TOO OLD**. Applies `Type: Too Old Version` label and closes such issues using `actOnLabel` workflow. ## Changelog: [GENERAL] [ADDED] - Auto close issue if version is too old. Pull Request resolved: #38041 Test Plan: - Should *auto-close* an issue with `Type: Too Old Version` label Reviewed By: NickGerleman Differential Revision: D47331471 Pulled By: cortinico fbshipit-source-id: 516468299d6923ce72e073a3b7b8b8715d15d6e0
1 parent 0519c11 commit 28dfdb2

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

.github/workflow-scripts/actOnLabel.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,16 @@ module.exports = async (github, context, labelWithContext) => {
133133
);
134134
await requestAuthorFeedback();
135135
return;
136+
case 'Type: Too Old Version':
137+
await addComment(
138+
`| :warning: | Too Old Version of React Native |\n` +
139+
`| --- | --- |\n` +
140+
`| :information_source: | It looks like your issue or the example you provided uses a [**Too Old Version of React Native**](https://github.com/reactwg/react-native-releases/blob/main/README.md#releases-support-policy).\nDue to the number of issues we receive, we're currently only accepting new issues against one of the supported versions. Please [upgrade](https://reactnative.dev/docs/upgrading) to latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If you cannot upgrade, please open your issue on [StackOverflow](https://stackoverflow.com/questions/tagged/react-native) to get further community support. |`,
141+
);
142+
await closeIssue();
143+
return;
144+
default:
145+
// No action needed
146+
return;
136147
}
137148
};

.github/workflow-scripts/verifyVersion.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ module.exports = async (github, context) => {
4242
).data;
4343
const latestVersion = parseVersionFromString(latestRelease.name);
4444

45+
// We want to "insta-close" an issue if RN version provided is too old. And encourage users to upgrade.
46+
if (isVersionTooOld(issueVersion, latestVersion)) {
47+
return {label: 'Type: Too Old Version'};
48+
}
49+
4550
if (!isVersionSupported(issueVersion, latestVersion)) {
4651
return {label: 'Type: Unsupported Version'};
4752
}
@@ -59,14 +64,34 @@ module.exports = async (github, context) => {
5964
}
6065
};
6166

62-
// We support N-2 minor versions, and the latest major.
67+
/**
68+
* Check if the RN version provided in an issue is supported.
69+
*
70+
* "We support `N-2` minor versions, and the `latest` major".
71+
*/
6372
function isVersionSupported(actualVersion, latestVersion) {
6473
return (
6574
actualVersion.major >= latestVersion.major &&
6675
actualVersion.minor >= latestVersion.minor - 2
6776
);
6877
}
6978

79+
/**
80+
* Check if the RN version provided in an issue is too old.
81+
* "We support `N-2` minor versions, and the `latest` major".
82+
*
83+
* A RN version is *too old* if it's:
84+
* - `1` or more *major* behind the *latest major*.
85+
* - `5` or more *minor* behind the *latest minor* in the *same major*. Less aggressive.
86+
* (e.g. If `0.72.0` is the current latest then `0.67.0` and lower is too old for `0.72.0`)
87+
*/
88+
function isVersionTooOld(actualVersion, latestVersion) {
89+
return (
90+
latestVersion.major - actualVersion.major >= 1 ||
91+
latestVersion.minor - actualVersion.minor >= 5
92+
);
93+
}
94+
7095
// Assumes that releases are sorted in the order of recency (i.e. most recent releases are earlier in the list)
7196
// This enables us to stop looking as soon as we find the first release with a matching major/minor version, since
7297
// we know it's the most recent release, therefore the highest patch available.

0 commit comments

Comments
 (0)