mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add a BUCK target (#48457)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48457 Adding CI support will require executing through buck. Sandboxing means the package has to be well-formed to work, so this cleans up some earlier mess. - yarn workspace - check-api.sh to configure the environment correctly when running form sandcastle - explicity dependencies in our package.json This is the first step Changelog: [Internal] Reviewed By: GijsWeterings Differential Revision: D67726588 fbshipit-source-id: 7f8605695e323ef332550820b23b85d3af5f4d69
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4f30b94a0d
commit
5f54386a66
Executable
+92
@@ -0,0 +1,92 @@
|
||||
#!/bin/bash
|
||||
# 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.
|
||||
|
||||
set -e
|
||||
|
||||
ERR_CODE_UNCOMMITTED_API_CHANGE=1
|
||||
ERR_CODE_CANT_FIND_PROJECT=2
|
||||
ERR_CODE_BAD_COMMIT=3
|
||||
|
||||
WARNING_MESSAGE_HEADER=$(cat <<EOF
|
||||
🚨 React Native Public C++ / Objective-C / Objective-C++ API Change Detected:
|
||||
|
||||
It looks like you've changed a public API that could affect our users, potentially breaking libraries and/or products using React Native.
|
||||
EOF
|
||||
)
|
||||
|
||||
WARNING_MESSAGE_TAIL=$(cat <<EOF
|
||||
|
||||
What to do now?
|
||||
---------------
|
||||
|
||||
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.
|
||||
|
||||
EOF
|
||||
)
|
||||
|
||||
ERROR_MENTION_BREAKING_CHANGE=$(cat <<EOF
|
||||
|
||||
Commit Message:
|
||||
---------------
|
||||
|
||||
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:
|
||||
|
||||
## Changelog:
|
||||
[General][Breaking] - Removed the Foo method to Bar as part of our deprecation mentioned in RFC-123
|
||||
|
||||
EOF
|
||||
)
|
||||
|
||||
function check_if_mentions_breaking_change() {
|
||||
IN_COMMIT_MESSAGE=$(sl log -r . -T '{desc}' | grep -iE '\[(android|ios|general|internal)\]\s*\[breaking\]' || true)
|
||||
if [ -z "$IN_COMMIT_MESSAGE" ]; then
|
||||
echo "$ERROR_MENTION_BREAKING_CHANGE"
|
||||
exit $ERR_CODE_BAD_COMMIT
|
||||
fi
|
||||
}
|
||||
|
||||
FBSOURCE_ROOT="$(sl root)"
|
||||
|
||||
# shellcheck source=xplat/js/env-utils/setup_env_base.sh
|
||||
source "$FBSOURCE_ROOT/xplat/js/env-utils/setup_env_base.sh"
|
||||
|
||||
# Path to a version of clang and clang-format, these should be from a consistent version
|
||||
CLANG_PATH=$( \
|
||||
buck2 targets --console=none --show-output fbcode//third-party-buck/platform010/build/llvm-fb/19:bin/clang \
|
||||
| awk '{print $2}' \
|
||||
| xargs dirname \
|
||||
)
|
||||
export PATH="$FBSOURCE_ROOT/$CLANG_PATH:$PATH"
|
||||
|
||||
function cleanup() {
|
||||
# shellcheck disable=SC2317
|
||||
popd
|
||||
}
|
||||
|
||||
pushd "$FBSOURCE_ROOT/xplat/js/react-native-github" || exit $ERR_CODE_CANT_FIND_PROJECT
|
||||
trap cleanup EXIT
|
||||
|
||||
# TODO: This operates in the sandbox and can't modify files in the repository, which we need for change detection
|
||||
# buck2 run //xplat/js/react-native-github/tools/api:public-api
|
||||
(cd tools/api && $YARN_BINARY install)
|
||||
$NODE_BINARY tools/api/public-api.js
|
||||
echo
|
||||
|
||||
API_FILE=$(grep -oP '(?<=output=)[^ \n]+' tools/api/public-api.conf)
|
||||
|
||||
API_STATUS=$(sl status --no-status "$API_FILE")
|
||||
if [ -z "$API_STATUS" ]; then
|
||||
echo "🎉 No public API changes, happy days!"
|
||||
exit 0
|
||||
else
|
||||
echo "$WARNING_MESSAGE_HEADER"
|
||||
|
||||
# Add any checks before showing the default warning
|
||||
check_if_mentions_breaking_change
|
||||
|
||||
echo "$WARNING_MESSAGE_TAIL"
|
||||
exit $ERR_CODE_UNCOMMITTED_API_CHANGE
|
||||
fi
|
||||
Reference in New Issue
Block a user