-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/text-input-ios-support-for-adjusting…
…-caret
- Loading branch information
Showing
826 changed files
with
29,332 additions
and
11,198 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
# and build a Android application that can be used to run the | ||
# tests specified in the scripts/ directory. | ||
# | ||
FROM reactnativecommunity/react-native-android:8.0 | ||
FROM reactnativecommunity/react-native-android:9.0 | ||
|
||
LABEL Description="React Native Android Test Image" | ||
LABEL maintainer="Meta Open Source <[email protected]>" | ||
|
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
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
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,110 @@ | ||
/** | ||
* 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 | ||
*/ | ||
|
||
const NEEDS_REPRO_LABEL = 'Needs: Repro'; | ||
const NEEDS_REPRO_HEADER = 'Missing Reproducible Example'; | ||
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> |`; | ||
|
||
module.exports = async (github, context) => { | ||
const issueData = { | ||
issue_number: context.payload.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}; | ||
|
||
const issue = await github.rest.issues.get(issueData); | ||
const comments = await github.rest.issues.listComments(issueData); | ||
|
||
const author = issue.data.user.login; | ||
|
||
const maintainerChangedLabel = await hasMaintainerChangedLabel( | ||
github, | ||
issueData, | ||
author, | ||
); | ||
|
||
if (maintainerChangedLabel) { | ||
return; | ||
} | ||
|
||
const botComment = comments.data.find(comment => | ||
comment.body.includes(NEEDS_REPRO_HEADER), | ||
); | ||
|
||
const entities = [issue.data, ...comments.data]; | ||
|
||
// Look for Snack or a GH repo associated with the user that added an issue or comment | ||
const hasValidReproducer = entities.some(entity => { | ||
const hasExpoSnackLink = containsPattern( | ||
entity.body, | ||
`https?:\\/\\/snack\\.expo\\.dev\\/[^\\s)\\]]+`, | ||
); | ||
|
||
const hasGithubRepoLink = containsPattern( | ||
entity.body, | ||
`https?:\\/\\/github\\.com\\/(${entity.user.login})\\/[^/]+\\/?\\s?`, | ||
); | ||
return hasExpoSnackLink || hasGithubRepoLink; | ||
}); | ||
|
||
if (hasValidReproducer) { | ||
try { | ||
await github.rest.issues.removeLabel({ | ||
...issueData, | ||
name: NEEDS_REPRO_LABEL, | ||
}); | ||
} catch (error) { | ||
if (!/Label does not exist/.test(error.message)) { | ||
throw error; | ||
} | ||
} | ||
|
||
if (!botComment) return; | ||
|
||
await github.rest.issues.deleteComment({ | ||
...issueData, | ||
comment_id: botComment.id, | ||
}); | ||
} else { | ||
await github.rest.issues.addLabels({ | ||
...issueData, | ||
labels: [NEEDS_REPRO_LABEL], | ||
}); | ||
|
||
if (botComment) return; | ||
|
||
await github.rest.issues.createComment({ | ||
...issueData, | ||
body: NEEDS_REPRO_MESSAGE, | ||
}); | ||
} | ||
}; | ||
|
||
function containsPattern(body, pattern) { | ||
const regexp = new RegExp(pattern, 'gm'); | ||
return body.search(regexp) !== -1; | ||
} | ||
|
||
// Prevents the bot from responding when maintainer has changed Needs: Repro the label | ||
async function hasMaintainerChangedLabel(github, issueData, author) { | ||
const timeline = await github.rest.issues.listEventsForTimeline(issueData); | ||
|
||
const labeledEvents = timeline.data.filter( | ||
event => event.event === 'labeled' || event.event === 'unlabeled', | ||
); | ||
const userEvents = labeledEvents.filter(event => event.actor.type !== 'Bot'); | ||
|
||
return userEvents.some( | ||
event => | ||
event.actor.login !== author && event.label.name === NEEDS_REPRO_LABEL, | ||
); | ||
} |
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,21 @@ | ||
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, edited] | ||
issue_comment: | ||
types: [created, edited, deleted] | ||
|
||
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' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const checkForReproducer = require('./.github/workflow-scripts/checkForReproducer.js') | ||
await checkForReproducer(github, context) |
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.