Skip to content

Commit a8cf53f

Browse files
blakeffacebook-github-bot
authored andcommitted
Add messaging to phabricator (facebook#48470)
Summary: Pull Request resolved: facebook#48470 This introduces: - `validate_rn_cpp_api`: run a shell script that fails if the user changes the C++ API. Importantly it produces an artifact with details to share with the user: `message`. - `message` has to be extracted from `stdout`, which **get_user_message** does if the `validate_rn_cpp_api` action is not successful (**warning**). - The then users `comment_to_signalhub` to share this as a warning to the user (until we're confident this entire stack is very stable, at which time we'll block). The provides 2 classes of warning: 1. vanilla you've change the API, 2. you've change the API and haven't included the correct changelog. Changelog: [Internal] Reviewed By: GijsWeterings Differential Revision: D67776215 fbshipit-source-id: 4ac7451c8ecef62ba968710ec41804ba42153976
1 parent d22dbb5 commit a8cf53f

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

tools/api/check-api.sh

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ ERR_CODE_UNCOMMITTED_API_CHANGE=1
1010
ERR_CODE_CANT_FIND_PROJECT=2
1111
ERR_CODE_BAD_COMMIT=3
1212

13+
# Delimit what we share with the users in PR / diffs
14+
MSG_START="=== MSG_START ==="
15+
MSG_END="=== MSG_END ==="
16+
1317
WARNING_MESSAGE_HEADER=$(cat <<EOF
14-
🚨 React Native Public C++ / Objective-C / Objective-C++ API Change Detected:
18+
# React Native Public C++ / Objective-C / Objective-C++ API Change Detected:
1519
1620
It looks like you've changed a public API that could affect our users, potentially breaking libraries and/or products using React Native.
1721
EOF
1822
)
1923

2024
WARNING_MESSAGE_TAIL=$(cat <<EOF
2125
22-
What to do now?
23-
---------------
26+
### What to do now?
2427
2528
Nothing for now, we're just tracking this. In the future we'll start adding folks from React Org as reviewers to check these changes align with our public API policy.
2629
@@ -29,13 +32,12 @@ EOF
2932

3033
ERROR_MENTION_BREAKING_CHANGE=$(cat <<EOF
3134
32-
Commit Message:
33-
---------------
35+
## Commit Message:
3436
3537
If you did not intend to change React Native's Public API, please revert those changes in this commit. If you did intend to change the Public API, You *MUST* add a changelog entry to your commit message using the "Breaking" type (https://reactnative.dev/contributing/changelogs-in-pull-requests). For example:
3638
37-
## Changelog:
38-
[General][Breaking] - Removed the Foo method to Bar as part of our deprecation mentioned in RFC-123
39+
## Changelog:
40+
[General][Breaking] - Removed the Foo method to Bar as part of our deprecation mentioned in RFC-123
3941
4042
EOF
4143
)
@@ -44,6 +46,7 @@ function check_if_mentions_breaking_change() {
4446
IN_COMMIT_MESSAGE=$(hg log -r . -T '{desc}' | grep -iE '\[(android|ios|general|internal)\]\s*\[breaking\]' || true)
4547
if [ -z "$IN_COMMIT_MESSAGE" ]; then
4648
echo "$ERROR_MENTION_BREAKING_CHANGE"
49+
echo "$MSG_END"
4750
exit $ERR_CODE_BAD_COMMIT
4851
fi
4952
}
@@ -82,11 +85,23 @@ if [ -z "$API_STATUS" ]; then
8285
echo "🎉 No public API changes, happy days!"
8386
exit 0
8487
else
88+
echo "$MSG_START"
89+
echo
8590
echo "$WARNING_MESSAGE_HEADER"
91+
echo
92+
echo "### Overview:"
93+
echo "\`\`\`"
94+
hg diff --stat
95+
echo "\`\`\`"
96+
echo "### Differences:"
97+
echo "\`\`\`diff"
98+
hg diff "$API_FILE"
99+
echo "\`\`\`"
86100

87101
# Add any checks before showing the default warning
88102
check_if_mentions_breaking_change
89103

90104
echo "$WARNING_MESSAGE_TAIL"
105+
echo "$MSG_END"
91106
exit $ERR_CODE_UNCOMMITTED_API_CHANGE
92107
fi

0 commit comments

Comments
 (0)