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
23 changes: 23 additions & 0 deletions .github/actions/diff-js-api-breaking-changes/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: diff-js-api-breaking-changes
description: Check for breaking changes in the public React Native JS API=
runs:
using: composite
steps:
- name: Fetch snapshot from PR head
shell: bash
env:
SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-breaking-changes
run: |
mkdir $SCRATCH_DIR
git fetch --depth=1 origin ${{ github.event.pull_request.head.sha }}
git show ${{ github.event.pull_request.head.sha }}:packages/react-native/ReactNativeApi.d.ts > $SCRATCH_DIR/ReactNativeApi-after.d.ts \
|| echo "" > $SCRATCH_DIR/ReactNativeApi.d.ts
- name: Run breaking change detection
shell: bash
env:
SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-breaking-changes
run: |
node ./scripts/diff-api-snapshot \
${{ github.workspace }}/packages/react-native/ReactNativeApi.d.ts \
$SCRATCH_DIR/ReactNativeApi-after.d.ts \
> $SCRATCH_DIR/output.json
4 changes: 3 additions & 1 deletion .github/workflows/danger-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ permissions:
jobs:
danger:
runs-on: ubuntu-latest
if: github.repository == 'facebook/react-native'
if: github.repository == 'coado/react-native'
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: ./.github/actions/setup-node
- name: Run yarn install
uses: ./.github/actions/yarn-install
- name: Run diff-js-api-breaking-changes
uses: ./.github/actions/diff-js-api-breaking-changes
- name: Danger
run: yarn danger ci --use-github-checks --failOnErrors
working-directory: private/react-native-bots
Expand Down
4 changes: 4 additions & 0 deletions packages/react-native/ReactNativeApi.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export interface ReactNativeApi {
foo: string,
}
21 changes: 21 additions & 0 deletions private/react-native-bots/dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
'use strict';

const {danger, fail, warn} = require('danger');
const fs = require('fs');
const path = require('path');

const body = danger.github.pr.body?.toLowerCase() ?? '';

Expand All @@ -28,6 +30,25 @@ const isFromPhabricator = body_contains('differential revision:');
// Provides advice if a summary section is missing, or body is too short
const includesSummary = body_contains('## summary', 'summary:');

const snapshot_output = JSON.parse(
fs.readFileSync(
path.join(
process.env.RUNNER_TEMP,
'diff-js-api-breaking-changes/output.json',
),
'utf8',
),
);
if (snapshot_output && snapshot_output.result !== 'NON_BREAKING') {
const title = ':exclamation: JavaScript API change detected';
const idea =
'This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API. ' +
'Please include a clear changelog message. ' +
'This change will be subject to extra review.\n\n' +
`This change was flagged as: <code>${snapshot_output.result}</code>`;
warn(`${title} - <i>${idea}</i>`);
}

const hasNoUsefulBody =
!danger.github.pr.body || danger.github.pr.body.length < 50;
const hasTooShortAHumanSummary =
Expand Down
Loading