diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 0000000000..37c486643f --- /dev/null +++ b/.github/workflows/danger.yml @@ -0,0 +1,15 @@ +name: "Danger" +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +jobs: + build: + name: Changelogs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + - run: npx danger@9.1.8 ci + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/dangerfile.js b/dangerfile.js new file mode 100644 index 0000000000..7ba76aa93d --- /dev/null +++ b/dangerfile.js @@ -0,0 +1,27 @@ +const files = danger.git.modified_files; +const hasChangelog = files.indexOf("CHANGELOG.md") !== -1; +const hasPyChangelog = files.indexOf("py/CHANGELOG.md") !== -1; + +const ERROR_MESSAGE = + "Please consider adding a changelog entry for the next release."; + +const DETAILS = ` +For changes exposed to the _Python package_, please add an entry to \`py/CHANGELOG.md\`. This includes, but is not limited to event normalization, PII scrubbing, and the protocol. + +For changes to the _Relay server_, please add an entry to \`CHANGELOG.md\` under the following heading: + 1. **Features**: For new user-visible functionality. + 2. **Bug Fixes**: For user-visible bug fixes. + 3. **Internal**: For features and bug fixes in internal operation, especially processing mode. + +If none of the above apply, you can opt out by adding _#skip-changelog_ to the PR description. +`; + +const skipChangelog = + danger.github && danger.github.pr.body.includes("#skip-changelog"); + +if (!hasChangelog && !hasPyChangelog && !skipChangelog) { + fail(ERROR_MESSAGE); + markdown(DETAILS); +} else { + message("Opted out of changelogs due to #skip-changelog."); +}