Skip to content

Commit

Permalink
Prevent check-for-reproducer action trigger on Umbrella and old issues (
Browse files Browse the repository at this point in the history
#38664)

Summary:
This PR resolves problems with too spammy `check-for-reproducer` action triggering on very old and most prominently the Umbrella issues.

Also, it brings back triggering on edited issues removed in #38634

Related to #35591

## Changelog:

[INTERNAL] [FIXED] - Prevent check-for-reproducer action trigger on Umbrella and old issues

Pull Request resolved: #38664

Test Plan: <img width="470" alt="image" src="https://github.com/facebook/react-native/assets/39658211/1d840145-1e4f-43c5-a3ea-bc16e61071ef">

Reviewed By: cipolleschi

Differential Revision: D47868536

Pulled By: cortinico

fbshipit-source-id: fd78c38145c76f3867a41439aee5d087f38c85d2
  • Loading branch information
kacperkapusciak authored and facebook-github-bot committed Jul 28, 2023
1 parent 97ac793 commit 54d70cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions .github/workflow-scripts/checkForReproducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const NEEDS_REPRO_MESSAGE =
`| :warning: | Missing Reproducible Example |\n` +
`| --- | --- |\n` +
`| :information_source: | We could not detect a reproducible example in your issue report. Please provide either: <br /><ul><li>If your bug is UI related: a [Snack](https://snack.expo.dev)</li><li> If your bug is build/update related: use our [Reproducer Template](https://github.com/react-native-community/reproducer-react-native/generate). A reproducer needs to be in a GitHub repository under your username.</li></ul> |`;
const SKIP_ISSUES_OLDER_THAN = '2023-07-01T00:00:00Z';

module.exports = async (github, context) => {
const issueData = {
Expand All @@ -26,6 +27,11 @@ module.exports = async (github, context) => {

const author = issue.data.user.login;

const issueDate = issue.data.created_at;
if (isDateBefore(issueDate, SKIP_ISSUES_OLDER_THAN)) {
return;
}

const maintainerChangedLabel = await hasMaintainerChangedLabel(
github,
issueData,
Expand Down Expand Up @@ -108,3 +114,10 @@ async function hasMaintainerChangedLabel(github, issueData, author) {
event.actor.login !== author && event.label.name === NEEDS_REPRO_LABEL,
);
}

function isDateBefore(firstDate, secondDate) {
const date1 = new Date(firstDate);
const date2 = new Date(secondDate);

return date1.getTime() < date2.getTime();
}
6 changes: 3 additions & 3 deletions .github/workflows/check-for-reproducer.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Check for reproducer
# This workflow is triggered when issue is created or edited.
# Also, when a comment is added, edited or deleted.
on:
issues:
types: [opened]
types: [opened, edited]

jobs:
check-for-reproducer:
runs-on: ubuntu-latest
if: github.repository == 'facebook/react-native' && github.event.issue.pull_request == null && github.event.issue.state == 'open'
if: |
github.repository == 'facebook/react-native' && github.event.issue.pull_request == null && github.event.issue.state == 'open' && !contains(github.event.issue.labels.*.name, ':open_umbrella: Umbrella')
steps:
- uses: actions/checkout@v3
- uses: actions/github-script@v6
Expand Down

0 comments on commit 54d70cf

Please sign in to comment.