File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
actions/diff-js-api-breaking-changes
private/react-native-bots Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ name : diff-js-api-breaking-changes
2+ description : Check for breaking changes in the public React Native JS API
3+ runs :
4+ using : composite
5+ steps :
6+ - name : Fetch snapshot from PR head
7+ shell : bash
8+ env :
9+ SCRATCH_DIR : ${{ runner.temp }}/diff-js-api-breaking-changes
10+ run : |
11+ mkdir $SCRATCH_DIR
12+ git fetch --depth=1 origin ${{ github.event.pull_request.head.sha }}
13+ git show ${{ github.event.pull_request.head.sha }}:packages/react-native/ReactNativeApi.d.ts > $SCRATCH_DIR/ReactNativeApi-after.d.ts \
14+ || echo "" > $SCRATCH_DIR/ReactNativeApi.d.ts
15+ - name : Run breaking change detection
16+ shell : bash
17+ env :
18+ SCRATCH_DIR : ${{ runner.temp }}/diff-js-api-breaking-changes
19+ run : |
20+ node ./scripts/diff-api-snapshot \
21+ ${{ github.workspace }}/packages/react-native/ReactNativeApi.d.ts \
22+ $SCRATCH_DIR/ReactNativeApi-after.d.ts \
23+ > $SCRATCH_DIR/output.json
Original file line number Diff line number Diff line change 2222 uses : ./.github/actions/setup-node
2323 - name : Run yarn install
2424 uses : ./.github/actions/yarn-install
25+ - name : Run diff-js-api-breaking-changes
26+ uses : ./.github/actions/diff-js-api-breaking-changes
2527 - name : Danger
2628 run : yarn danger ci --use-github-checks --failOnErrors
2729 working-directory : private/react-native-bots
Original file line number Diff line number Diff line change 1111'use strict' ;
1212
1313const { danger, fail, warn} = require ( 'danger' ) ;
14+ const fs = require ( 'fs' ) ;
15+ const path = require ( 'path' ) ;
1416
1517const body = danger . github . pr . body ?. toLowerCase ( ) ?? '' ;
1618
@@ -28,6 +30,25 @@ const isFromPhabricator = body_contains('differential revision:');
2830// Provides advice if a summary section is missing, or body is too short
2931const includesSummary = body_contains ( '## summary' , 'summary:' ) ;
3032
33+ const snapshot_output = JSON . parse (
34+ fs . readFileSync (
35+ path . join (
36+ process . env . RUNNER_TEMP ,
37+ 'diff-js-api-breaking-changes/output.json' ,
38+ ) ,
39+ 'utf8' ,
40+ ) ,
41+ ) ;
42+ if ( snapshot_output && snapshot_output . result !== 'NON_BREAKING' ) {
43+ const title = ':exclamation: JavaScript API change detected' ;
44+ const idea =
45+ 'This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API. ' +
46+ 'Please include a clear changelog message. ' +
47+ 'This change will be subject to extra review.\n\n' +
48+ `This change was flagged as: <code>${ snapshot_output . result } </code>` ;
49+ warn ( `${ title } - <i>${ idea } </i>` ) ;
50+ }
51+
3152const hasNoUsefulBody =
3253 ! danger . github . pr . body || danger . github . pr . body . length < 50 ;
3354const hasTooShortAHumanSummary =
You can’t perform that action at this time.
0 commit comments