Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56871
`diff-js-api-changes` was posting false positive "JavaScript API change detected" warnings on PRs that never modified `ReactNativeApi.d.ts`.
This happened because the action ran `git merge-base` against limited local history (`git fetch --depth=500`), which couldn't find the common ancestor for branches that were far behind main — including (often) pick requests to release branches. The fallback wrote an empty "before" snapshot, causing the entire API surface to appear newly added.
{F1989977284}
#### Changes
- Query the GitHub API first — if the PR doesn't touch `ReactNativeApi.d.ts`, skip the diff entirely.
- When the snapshot is touched, use the GitHub compare API to resolve the merge base instead of relying on local git history.
- Limit the check to PRs targeting `main` or `*-stable` branches.
Changelog: [Internal]
Reviewed By: christophpurrer
Differential Revision: D105572432
fbshipit-source-id: 20e5db01c9e6b51acb55548746c8fd512a363274
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55341
Changelog:
[INTERNAL] [CHANGED] - Add api-changes.yml workflow to replace danger-pr for detecting changes in the js api
The workflow:
- Triggers on `pull_request_target` for opened, edited, reopened, and synchronize events
- Checks out the main branch (for security, using trusted code)
- Runs the `diff-js-api-changes` action to detect API changes
- Posts a PR comment using the generic `post-pr-comment` action
The PR comment script creates, updates, or deletes a bot comment based on whether
there are any sections to report, using a marker to identify existing bot comments.
Reviewed By: huntie
Differential Revision: D90991845
fbshipit-source-id: 753475a7c24df8bc581b2ab47bfad1f5551c823c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55245
Changelog: [INTERNAL] [FIXED] - Fix diff-js-api-changes workflow to correctly compare PR head vs merge base
The `diff-js-api-changes` action was comparing main to main instead of comparing the PR head to the point of main it branched from.
The workflow now:
1. Checks out main in `danger-pr.yml` to get the trusted scripts
2. Fetches the PR head commit and computes the merge base (the point it branched from main)
3. Extracts the API snapshots from both refs using `git show` to read-only temp files
4. Runs main's diff script to compare the two snapshots
**Security notes:**
- `git fetch` only downloads git objects, it does not modify the working directory
- `git show <sha>:path` extracts a file as read-only data, not executable code
- All executed scripts come from main (trusted), PR content is only used as data
- The PR's `.d.ts` file is written to a temp directory and passed as input to main's diff script
Reviewed By: huntie
Differential Revision: D90978905
fbshipit-source-id: fc9b420a27c84f1812b436f41d3169fad4f91291
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54865
Removes introduced in D88654826, replaced with a `git fetch` with `--depth`.
This should fix CI runs on `main` (where we believe the extra checkout is clobbering the `yarn-install` step), and improve execution time.
Also shorten action name.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D89044330
fbshipit-source-id: 690eb5c7db9490e5f160e933d64eae6ac21464c8