Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Configure Renovate (#897)
Browse files Browse the repository at this point in the history
* Add renovate.json

* update renovate

* fix dangerfile
  • Loading branch information
renovate[bot] authored and James Baxley committed Jul 31, 2017
1 parent a17394b commit 5fe94dc
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ labels:
color: c2e0c6
- name: feature
color: 5319e7
- name: greenkeeper
- name: dependencies
color: ededed
- name: idea
color: fbca04
Expand Down
79 changes: 44 additions & 35 deletions dangerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as fs from 'fs';

// Setup
const pr = danger.github.pr;
const commits = danger.github.commits;
const modified = danger.git.modified_files;
const bodyAndTitle = (pr.body + pr.title).toLowerCase();

Expand Down Expand Up @@ -57,44 +58,52 @@ const raiseIssueAboutPaths = (
}
};

// Rules
// When there are app-changes and it's not a PR marked as trivial, expect
// there to be CHANGELOG changes.
const changelogChanges = includes(modified, 'Changelog.md');
if (modifiedAppFiles.length > 0 && !trivialPR && !changelogChanges) {
fail('No CHANGELOG added.');
}
const authors = commits.map(x => x.author.login);
const isBot = authors.some(x => ['greenkeeper', 'renovate'].indexOf(x) > -1);

// No PR is too small to warrant a paragraph or two of summary
if (pr.body.length === 0) {
fail('Please add a description to your PR.');
}
if (!isBot) {
// Rules
// When there are app-changes and it's not a PR marked as trivial, expect
// there to be CHANGELOG changes.
const changelogChanges = includes(modified, 'Changelog.md');
if (modifiedAppFiles.length > 0 && !trivialPR && !changelogChanges) {
fail('No CHANGELOG added.');
}

const hasAppChanges = modifiedAppFiles.length > 0;
// No PR is too small to warrant a paragraph or two of summary
if (pr.body.length === 0) {
fail('Please add a description to your PR.');
}

const hasTestChanges = modifiedTestFiles.length > 0;
const hasAppChanges = modifiedAppFiles.length > 0;

// Warn when there is a big PR
const bigPRThreshold = 500;
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) {
warn(':exclamation: Big PR');
}
const hasTestChanges = modifiedTestFiles.length > 0;

// Warn if there are library changes, but not tests
if (hasAppChanges && !hasTestChanges) {
warn(
"There are library changes, but not tests. That's OK as long as you're refactoring existing code",
);
}
// Warn when there is a big PR
const bigPRThreshold = 500;
if (
danger.github.pr.additions + danger.github.pr.deletions >
bigPRThreshold
) {
warn(':exclamation: Big PR');
}

// Warn if there are library changes, but not tests
if (hasAppChanges && !hasTestChanges) {
warn(
"There are library changes, but not tests. That's OK as long as you're refactoring existing code",
);
}

// Be careful of leaving testing shortcuts in the codebase
const onlyTestFiles = modifiedTestFiles.filter(x => {
const content = fs.readFileSync(x).toString();
return (
content.includes('it.only') ||
content.includes('describe.only') ||
content.includes('fdescribe') ||
content.includes('fit(')
);
});
raiseIssueAboutPaths(fail, onlyTestFiles, 'an `only` was left in the test');
// Be careful of leaving testing shortcuts in the codebase
const onlyTestFiles = modifiedTestFiles.filter(x => {
const content = fs.readFileSync(x).toString();
return (
content.includes('it.only') ||
content.includes('describe.only') ||
content.includes('fdescribe') ||
content.includes('fit(')
);
});
raiseIssueAboutPaths(fail, onlyTestFiles, 'an `only` was left in the test');
}
12 changes: 12 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"pinVersions": true,
"semanticCommits": true,
"depTypes": [{ "depType": "dependencies", "pinVersions": false }],
"schedule": ["after 10pm and before 5am on every weekday"],
"rebaseStalePrs": true,
"prCreation": "not-pending",
"automerge": "minor",
"labels": ["tooling", "dependencies"],
"assignees": ["@jbaxleyiii"],
"reviewers": ["@jbaxleyiii"]
}

0 comments on commit 5fe94dc

Please sign in to comment.