Skip to content

Commit

Permalink
chore: add dangerfile.systems check
Browse files Browse the repository at this point in the history
  • Loading branch information
JackuB committed Jul 2, 2019
1 parent 6cd86de commit d625dc2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ script:
- npm test
jobs:
include:
- stage: test
script: npx danger ci --failOnErrors
name: "Danger Zone"
- stage: Release
if: branch = master AND type != pull_request
node_js: "8"
Expand Down
28 changes: 28 additions & 0 deletions dangerfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const {danger, warn, fail, message} = require('danger');

if (danger.github && danger.github.pr) {
const commitizenRegex = /^(feat|fix|chore|test|docs|perf|refactor|revert)(\(.*\))?:(.+)$/;
const ghCommits = danger.github.commits;
let willTriggerRelease = false;
for (const {commit} of ghCommits) {
const {message, url} = commit;
const firstLine = message.split('\n')[0];

if (message.startsWith('feat') || message.startsWith('fix')) {
willTriggerRelease = true;
}

const regexMatch = commitizenRegex.exec(firstLine);
if (!regexMatch) {
fail(`Commit ["${firstLine}"](${url}) is not a valid commitizen message. See [Contributing page](https://github.com/snyk/snyk/blob/master/.github/CONTRIBUTING.md#commit-types) with required commit message format.`);
}

if (firstLine.length >= 72) {
warn(`Your commit message ["${firstLine}"](${url}) is too long. Keep first line of your commit under 72 characters.`);
}
}

if (!willTriggerRelease) {
message('This PR will not trigger a new version. It doesn\'t include any commit message with `feat` or `fix`.');
}
}

0 comments on commit d625dc2

Please sign in to comment.