From f8d5eadc6df14eeb13338de233901c46803b65ac Mon Sep 17 00:00:00 2001 From: Dawid Malecki Date: Fri, 12 Dec 2025 12:54:48 +0100 Subject: [PATCH 1/5] verify --- .../action.yml | 22 ++++++------------- .github/workflows/danger-pr.yml | 8 +++---- private/react-native-bots/dangerfile.js | 5 +---- 3 files changed, 12 insertions(+), 23 deletions(-) rename .github/actions/{diff-js-api-breaking-changes => diff-js-api-changes}/action.yml (75%) diff --git a/.github/actions/diff-js-api-breaking-changes/action.yml b/.github/actions/diff-js-api-changes/action.yml similarity index 75% rename from .github/actions/diff-js-api-breaking-changes/action.yml rename to .github/actions/diff-js-api-changes/action.yml index 4b5db7bfcd2d..c6f2464c9cf5 100644 --- a/.github/actions/diff-js-api-breaking-changes/action.yml +++ b/.github/actions/diff-js-api-changes/action.yml @@ -1,38 +1,30 @@ -name: diff-js-api-breaking-changes +name: diff-js-api-changes description: Check for breaking changes in the public React Native JS API runs: using: composite steps: - - name: Checkout PR branch - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - name: Get merge base commit with main id: merge_base - shell: bash run: | + git fetch origin ${{ github.event.pull_request.head.sha }} --depth=100 BASE=$(git merge-base ${{ github.event.pull_request.head.sha }} origin/main) echo "merge_base=$BASE" >> $GITHUB_OUTPUT - name: Fetch snapshots from PR head and merge base - shell: bash env: - SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-breaking-changes + SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-changes run: | mkdir -p $SCRATCH_DIR - # Fetch from PR head - git show ${{ github.event.pull_request.head.sha }}:packages/react-native/ReactNativeApi.d.ts > $SCRATCH_DIR/ReactNativeApi-after.d.ts \ - || echo "" > $SCRATCH_DIR/ReactNativeApi-after.d.ts # Fetch from merge base git show ${{ steps.merge_base.outputs.merge_base }}:packages/react-native/ReactNativeApi.d.ts > $SCRATCH_DIR/ReactNativeApi-before.d.ts \ || echo "" > $SCRATCH_DIR/ReactNativeApi-before.d.ts + # Fetch from PR head + git show ${{ github.event.pull_request.head.sha }}:packages/react-native/ReactNativeApi.d.ts > $SCRATCH_DIR/ReactNativeApi-after.d.ts \ + || echo "" > $SCRATCH_DIR/ReactNativeApi-after.d.ts - name: Run breaking change detection - shell: bash env: - SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-breaking-changes + SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-changes run: | node ./scripts/js-api/diff-api-snapshot \ $SCRATCH_DIR/ReactNativeApi-before.d.ts \ diff --git a/.github/workflows/danger-pr.yml b/.github/workflows/danger-pr.yml index cf28b788105a..516e12219dcf 100644 --- a/.github/workflows/danger-pr.yml +++ b/.github/workflows/danger-pr.yml @@ -1,7 +1,7 @@ name: Run Danger on PR on: - pull_request_target: + pull_request: types: [opened, edited, reopened, synchronize] permissions: @@ -15,15 +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: Run diff-js-api-changes + uses: ./.github/actions/diff-js-api-changes - name: Danger run: yarn danger ci --use-github-checks --failOnErrors working-directory: private/react-native-bots diff --git a/private/react-native-bots/dangerfile.js b/private/react-native-bots/dangerfile.js index 1bff20819a97..77160c71aec2 100644 --- a/private/react-native-bots/dangerfile.js +++ b/private/react-native-bots/dangerfile.js @@ -32,10 +32,7 @@ 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', - ), + path.join(process.env.RUNNER_TEMP, 'diff-js-api-changes/output.json'), 'utf8', ), ); From 210affdd3a7064166e414855e938845821cbea36 Mon Sep 17 00:00:00 2001 From: Dawid Malecki Date: Fri, 12 Dec 2025 12:57:02 +0100 Subject: [PATCH 2/5] verify without using gh token --- .github/workflows/danger-pr.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/danger-pr.yml b/.github/workflows/danger-pr.yml index 516e12219dcf..b8450884b0e9 100644 --- a/.github/workflows/danger-pr.yml +++ b/.github/workflows/danger-pr.yml @@ -24,8 +24,8 @@ jobs: uses: ./.github/actions/yarn-install - name: Run diff-js-api-changes uses: ./.github/actions/diff-js-api-changes - - name: Danger - run: yarn danger ci --use-github-checks --failOnErrors - working-directory: private/react-native-bots - env: - DANGER_GITHUB_API_TOKEN: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }} + # - name: Danger + # run: yarn danger ci --use-github-checks --failOnErrors + # working-directory: private/react-native-bots + # env: + # DANGER_GITHUB_API_TOKEN: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }} From 7cc719e3f1dd11797805860e35a54b68d1156ee4 Mon Sep 17 00:00:00 2001 From: Dawid Malecki Date: Fri, 12 Dec 2025 13:30:38 +0100 Subject: [PATCH 3/5] add shell --- .github/actions/diff-js-api-changes/action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/actions/diff-js-api-changes/action.yml b/.github/actions/diff-js-api-changes/action.yml index c6f2464c9cf5..0e098f358b4f 100644 --- a/.github/actions/diff-js-api-changes/action.yml +++ b/.github/actions/diff-js-api-changes/action.yml @@ -4,6 +4,7 @@ runs: using: composite steps: - name: Get merge base commit with main + shell: bash id: merge_base run: | git fetch origin ${{ github.event.pull_request.head.sha }} --depth=100 @@ -11,6 +12,7 @@ runs: echo "merge_base=$BASE" >> $GITHUB_OUTPUT - name: Fetch snapshots from PR head and merge base + shell: bash env: SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-changes run: | @@ -23,6 +25,7 @@ runs: || echo "" > $SCRATCH_DIR/ReactNativeApi-after.d.ts - name: Run breaking change detection + shell: bash env: SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-changes run: | From 418ee084122133a2df80b3d61c7e3421607d4cac Mon Sep 17 00:00:00 2001 From: Dawid Malecki Date: Fri, 12 Dec 2025 13:38:26 +0100 Subject: [PATCH 4/5] fetch main --- .github/actions/diff-js-api-changes/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/diff-js-api-changes/action.yml b/.github/actions/diff-js-api-changes/action.yml index 0e098f358b4f..984d242e85cf 100644 --- a/.github/actions/diff-js-api-changes/action.yml +++ b/.github/actions/diff-js-api-changes/action.yml @@ -7,6 +7,7 @@ runs: shell: bash id: merge_base run: | + git fetch origin main --depth=0 git fetch origin ${{ github.event.pull_request.head.sha }} --depth=100 BASE=$(git merge-base ${{ github.event.pull_request.head.sha }} origin/main) echo "merge_base=$BASE" >> $GITHUB_OUTPUT From 95891d668efd353aab2b6957f53d1cba35ad8b15 Mon Sep 17 00:00:00 2001 From: Dawid Malecki Date: Fri, 12 Dec 2025 13:39:58 +0100 Subject: [PATCH 5/5] do not set depth --- .github/actions/diff-js-api-changes/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/diff-js-api-changes/action.yml b/.github/actions/diff-js-api-changes/action.yml index 984d242e85cf..b014978de9e0 100644 --- a/.github/actions/diff-js-api-changes/action.yml +++ b/.github/actions/diff-js-api-changes/action.yml @@ -7,7 +7,7 @@ runs: shell: bash id: merge_base run: | - git fetch origin main --depth=0 + git fetch origin main git fetch origin ${{ github.event.pull_request.head.sha }} --depth=100 BASE=$(git merge-base ${{ github.event.pull_request.head.sha }} origin/main) echo "merge_base=$BASE" >> $GITHUB_OUTPUT