Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
; Ignore the codegen e2e tests
<PROJECT_ROOT>/packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeEnumTurboModule.js

; Ignore the Dangerfile
<PROJECT_ROOT>/private/react-native-bots/dangerfile.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

Expand Down
36 changes: 36 additions & 0 deletions .github/actions/diff-js-api-changes/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: diff-js-api-changes
description: Check for breaking changes in the public React Native JS API
outputs:
message:
description: Formatted markdown message describing API changes, or empty if no changes
value: ${{ steps.format_output.outputs.message }}
runs:
using: composite
steps:
Expand Down Expand Up @@ -35,3 +39,35 @@ runs:
$SCRATCH_DIR/ReactNativeApi-before.d.ts \
$SCRATCH_DIR/ReactNativeApi-after.d.ts \
> $SCRATCH_DIR/output.json

- name: Format output message
id: format_output
shell: bash
env:
SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-changes
run: |
if [ ! -f "$SCRATCH_DIR/output.json" ]; then
echo "message=" >> $GITHUB_OUTPUT
exit 0
fi

RESULT=$(cat $SCRATCH_DIR/output.json | jq -r '.result // empty')
if [ -z "$RESULT" ] || [ "$RESULT" = "NON_BREAKING" ]; then
echo "message=" >> $GITHUB_OUTPUT
exit 0
fi

# Use delimiter for multiline output
{
echo "message<<EOF"
echo "> [!WARNING]"
echo "> **JavaScript API change detected**"
echo ">"
echo "> This PR commits an update to \`ReactNativeApi.d.ts\`, indicating a change to React Native's public JavaScript API."
echo ">"
echo "> - Please include a **clear changelog message**."
echo "> - This change will be subject to additional review."
echo ">"
echo "> This change was flagged as: \`${RESULT}\`"
echo "EOF"
} >> $GITHUB_OUTPUT
55 changes: 55 additions & 0 deletions .github/actions/post-pr-comment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: post-pr-comment
description: Post or update a PR comment, or delete if no sections
inputs:
sections:
description: 'JSON array of markdown sections to include in comment'
required: false
default: '[]'
header:
description: 'Optional header text to display at the top of the comment'
required: false
default: ''
marker:
description: 'HTML comment marker to identify this comment'
required: true
runs:
using: composite
steps:
- name: Create, update, or delete comment
uses: actions/github-script@v8
env:
SECTIONS_INPUT: ${{ inputs.sections }}
MARKER_INPUT: ${{ inputs.marker }}
HEADER_INPUT: ${{ inputs.header }}
with:
script: |
const marker = process.env.MARKER_INPUT;
const header = process.env.HEADER_INPUT;
const sections = JSON.parse(process.env.SECTIONS_INPUT)
.filter(Boolean)
.filter(s => s.trim());
const {owner, repo} = context.repo;
const issue_number = context.issue.number;
const {data: comments} = await github.rest.issues.listComments({
owner, repo, issue_number,
});
const existing = comments.find(c => c.body?.includes(marker));
if (!sections.length) {
if (existing) {
await github.rest.issues.deleteComment({owner, repo, comment_id: existing.id});
}
return;
}
const content = sections.join('\n\n');
const body = header ? `${marker}\n## ${header}\n\n${content}` : `${marker}\n${content}`;
if (existing) {
await github.rest.issues.updateComment({owner, repo, comment_id: existing.id, body});
} else {
await github.rest.issues.createComment({owner, repo, issue_number, body});
}
40 changes: 40 additions & 0 deletions .github/workflow-scripts/checkBranchTarget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* 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
*/

'use strict';

/**
* Validates that the PR targets an appropriate base branch.
*
* @param {string} baseRef - The base branch ref (e.g., 'main', '0.76-stable')
* @returns {{message: string, status: 'PASS'|'FAIL', shouldAddPickLabel: boolean}}
*/
function checkBranchTarget(baseRef) {
const isMain = baseRef === 'main';
const isStable = baseRef.endsWith('-stable');

let message = '';
let status = 'PASS';
if (!isMain && !isStable) {
status = 'FAIL';
message = `> [!CAUTION]
> **Invalid Base Branch**
>
> The base branch for this PR is \`${baseRef}\`, which is not \`main\` or a \`-stable\` branch.
> [Are you sure you want to target this branch?](https://reactnative.dev/docs/contributing#pull-requests)`;
}

return {
message,
status,
shouldAddPickLabel: isStable,
};
}

module.exports = checkBranchTarget;
Loading
Loading