From b149d2a0d6c2d6d36dea40335f5801eb37a3a219 Mon Sep 17 00:00:00 2001 From: Franco Meloni Date: Mon, 23 May 2022 01:12:25 -0700 Subject: [PATCH] Run Danger on all the PRs and use fail or warning where is needed (#33872) Summary: Run Danger on all the PRs, not just on the forks, use fail or warning where is needed and make CircleCI fail if danger fails ## Changelog [Internal] - Run Danger on all the PRs and use fail or warning where is needed. Pull Request resolved: https://github.com/facebook/react-native/pull/33872 Test Plan: Run the change on CirlceCI Reviewed By: cortinico Differential Revision: D36516847 Pulled By: f-meloni fbshipit-source-id: 2c956295a56cc8aa47df4c64f8ca0a211796c73c --- .circleci/config.yml | 14 ++------------ .github/workflows/danger_pr.yml | 18 ++++++++++++++++++ bots/dangerfile.js | 8 ++++---- 3 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/danger_pr.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index afeeb6fee35..3c3c3fce637 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -327,13 +327,6 @@ jobs: command: GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" yarn lint-ci when: always - - run: - name: Analyze Pull Request (pull-bot) - command: | - cd bots - DANGER_GITHUB_API_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" yarn danger ci --use-github-checks - when: always - # ------------------------- # JOBS: Analyze Code # ------------------------- @@ -1315,11 +1308,8 @@ workflows: # Run lints on every commit - analyze_code - # Run code checks on PRs from forks - - analyze_pr: - filters: - branches: - only: /^pull\/.*$/ + # Run code checks on PRs + - analyze_pr # Gather coverage - js_coverage diff --git a/.github/workflows/danger_pr.yml b/.github/workflows/danger_pr.yml new file mode 100644 index 00000000000..8d93b77c410 --- /dev/null +++ b/.github/workflows/danger_pr.yml @@ -0,0 +1,18 @@ +name: Run Danger on PR + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + +jobs: + danger: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: yarn install + working-directory: bots + - name: Danger + run: yarn danger ci --use-github-checks --failOnErrors --id danger_pr + working-directory: bots + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/bots/dangerfile.js b/bots/dangerfile.js index 30545cbd078..40e28921179 100644 --- a/bots/dangerfile.js +++ b/bots/dangerfile.js @@ -29,7 +29,7 @@ if (!danger.github.pr.body || danger.github.pr.body.length < 50) { 'Can you add a Summary? ' + 'To do so, add a "## Summary" section to your PR description. ' + 'This is a good place to explain the motivation for making this change.'; - message(`${title} - ${idea}`); + warn(`${title} - ${idea}`); } // Warns if there are changes to package.json, and tags the team. @@ -53,7 +53,7 @@ if (!includesTestPlan && !isFromPhabricator) { 'Can you add a Test Plan? ' + 'To do so, add a "## Test Plan" section to your PR description. ' + 'A Test Plan lets us know how these changes were tested.'; - message(`${title} - ${idea}`); + warn(`${title} - ${idea}`); } // Regex looks for given categories, types, a file/framework/component, and a message - broken into 4 capture groups @@ -80,11 +80,11 @@ if (!includesChangelog) { 'Can you add a Changelog? ' + 'To do so, add a "## Changelog" section to your PR description. ' + changelogInstructions; - message(`${title} - ${idea}`); + fail(`${title} - ${idea}`); } else if (!correctlyFormattedChangelog && !containsInternalChangelog) { const title = ':clipboard: Verify Changelog Format'; const idea = changelogInstructions; - message(`${title} - ${idea}`); + fail(`${title} - ${idea}`); } // Warns if the PR is opened against stable, as commits need to be cherry picked and tagged by a release maintainer.