diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 0000000..0660e5a --- /dev/null +++ b/.github/workflows/danger.yml @@ -0,0 +1,19 @@ +name: Issue + PR management + +on: [pull_request] + +jobs: + danger: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '15.x' + - run: yarn install + - run: yarn run build + - name: Danger JS Action + uses: danger/danger-js@9.1.8 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/dangerfile.ts b/dangerfile.ts new file mode 100644 index 0000000..588864c --- /dev/null +++ b/dangerfile.ts @@ -0,0 +1,26 @@ +import { danger, warn } from 'danger'; + +// No PR is too small to include a description of why you made a change +function checkPRBodyLength() { + if (danger.github.pr === undefined) { + return; + } + + // @ts-ignore + if (danger.github.pr.body.length < 10) { + warn('Please include a description of your PR changes.'); + } +} + +checkPRBodyLength(); + +// Request changes to src also include changes to tests. +const allFiles = danger.git.modified_files.concat(danger.git.created_files); +const hasAppChanges = allFiles.some((p) => p.includes('src/')); +const hasTestChanges = allFiles.some((p) => p.includes('__tests__/')); + +if (hasAppChanges && !hasTestChanges) { + warn( + 'This PR does not include changes to tests, even though it affects app code.', + ); +}