Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
82 changes: 82 additions & 0 deletions .github/workflows/validate-cxx-api-snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Validate C++ API Snapshots

on:
workflow_dispatch:
pull_request:
paths:
- "packages/react-native/ReactCommon/**"
- "packages/react-native/ReactAndroid/**"
- "packages/react-native/React/**"
- "packages/react-native/ReactApple/**"
- "packages/react-native/Libraries/**"
- "scripts/cxx-api/**"
push:
branches:
- main
- "*-stable"
paths:
- "packages/react-native/ReactCommon/**"
- "packages/react-native/ReactAndroid/**"
- "packages/react-native/React/**"
- "packages/react-native/ReactApple/**"
- "packages/react-native/Libraries/**"
- "scripts/cxx-api/**"

env:
DOXYGEN_VERSION: "1.16.1"

jobs:
validate_cxx_api_snapshots:
runs-on: ubuntu-latest
if: github.repository == 'facebook/react-native'
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Run yarn
uses: ./.github/actions/yarn-install
- name: Restore Doxygen cache
id: cache-doxygen
uses: actions/cache@v4
with:
path: /tmp/doxygen-${{ env.DOXYGEN_VERSION }}
key: doxygen-${{ env.DOXYGEN_VERSION }}
- name: Install Doxygen
if: steps.cache-doxygen.outputs.cache-hit != 'true'
shell: bash
run: |
DOXYGEN_URL="https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz"
MAX_RETRIES=3
for i in $(seq 1 $MAX_RETRIES); do
echo "Attempt $i of $MAX_RETRIES: Installing Doxygen ${DOXYGEN_VERSION}..."
curl -fsSL "$DOXYGEN_URL" -o /tmp/doxygen.tar.gz && \
tar -xzf /tmp/doxygen.tar.gz -C /tmp && \
echo "Doxygen installed successfully." && \
break
echo "Attempt $i failed."
if [ $i -eq $MAX_RETRIES ]; then
echo "All $MAX_RETRIES attempts failed."
exit 1
fi
sleep 5
done
- name: Set DOXYGEN_BIN
shell: bash
run: echo "DOXYGEN_BIN=/tmp/doxygen-${DOXYGEN_VERSION}/bin/doxygen" >> "$GITHUB_ENV"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Python dependencies
shell: bash
run: pip install doxmlparser natsort pyyaml
- name: Validate C++ API snapshots
shell: bash
continue-on-error: true
run: yarn cxx-api-validate --output-dir /tmp/cxx-api-snapshots
- name: Upload C++ API snapshots
uses: actions/upload-artifact@v6
with:
name: cxx-api-snapshots
path: /tmp/cxx-api-snapshots/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"clang-format": "clang-format -i --glob=*/**/*.{h,cpp,m,mm}",
"clean": "node ./scripts/build/clean.js",
"cxx-api-build": "python -m scripts.cxx-api.parser",
"cxx-api-validate": "python -m scripts.cxx-api.parser --check",
"cxx-api-validate": "python -m scripts.cxx-api.parser --validate",
"flow-check": "flow check",
"flow": "flow",
"format-check": "prettier --list-different \"./**/*.{js,md,yml,ts,tsx}\"",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/ReactCommon/react/bridging/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct Bridging<std::array<T, N>> : array_detail::BridgingStatic<std::array<T, N

template <typename T1, typename T2>
struct Bridging<std::pair<T1, T2>> : array_detail::BridgingStatic<std::pair<T1, T2>, 2> {
static std::pair<T1, T1>
static std::pair<T1, T2>
fromJs(facebook::jsi::Runtime &rt, const jsi::Array &array, const std::shared_ptr<CallInvoker> &jsInvoker)
{
return std::make_pair(
Expand Down
6 changes: 3 additions & 3 deletions scripts/cxx-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ Maintainers should run this command whenever making intentional C++ API changes:
python -m scripts.cxx-api.parser
```

#### Check snapshots against committed baseline
#### Validate snapshots against committed baseline

This mode generates snapshots to a temporary directory and compares them against the committed `.api` files. It is designed for CI:

```sh
python -m scripts.cxx-api.parser --check
python -m scripts.cxx-api.parser --validate
```

If any snapshot differs, a unified diff is printed and the process exits with a non-zero status. To fix a failing check, regenerate the snapshots with `python -m scripts.cxx-api.parser` and commit the updated `.api` files.
If any snapshot differs, a unified diff is printed and the process exits with a non-zero status. To fix a failing validation, regenerate the snapshots with `python -m scripts.cxx-api.parser` and commit the updated `.api` files.

## How it works

Expand Down
Loading
Loading