diff --git a/.github/actions/diff-js-api-breaking-changes/action.yml b/.github/actions/diff-js-api-changes/action.yml similarity index 78% rename from .github/actions/diff-js-api-breaking-changes/action.yml rename to .github/actions/diff-js-api-changes/action.yml index 4b5db7bfcd2d..b014978de9e0 100644 --- a/.github/actions/diff-js-api-breaking-changes/action.yml +++ b/.github/actions/diff-js-api-changes/action.yml @@ -1,38 +1,34 @@ -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 + id: merge_base run: | + 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 - 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..b8450884b0e9 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,17 +15,17 @@ 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 - env: - DANGER_GITHUB_API_TOKEN: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }} + - 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 }} 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', ), );