This repository has been archived by the owner on Nov 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from contiamo/infra/dx
Infra/dx
- Loading branch information
Showing
6 changed files
with
1,341 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file tells Travis what's up | ||
language: node_js | ||
node_js: | ||
- stable | ||
|
||
notifications: | ||
email: false | ||
|
||
# This allows tests to run more efficiently without leaking memory | ||
# More info: https://facebook.github.io/jest/docs/en/troubleshooting.html#tests-are-extremely-slow-on-docker-and-or-continuous-integration-ci-server | ||
env: | ||
- JEST_MAX_WORKERS: 4 | ||
|
||
# When Travis gets notified of a new build, do this | ||
script: | ||
- yarn ci | ||
- yarn danger ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import * as child_process from "child_process"; | ||
import { danger, markdown, warn } from "danger"; | ||
import jest from "danger-plugin-jest"; | ||
import * as fs from "fs"; | ||
import { includes } from "lodash"; | ||
|
||
// Setup | ||
const pr = danger.github.pr; | ||
const modified = danger.git.modified_files; | ||
const added = danger.git.created_files; | ||
|
||
const packageChanged = includes(modified, "package.json"); | ||
const wrongLockfileChanged = includes([...modified, ...added], "package-lock.json"); | ||
|
||
if (packageChanged && wrongLockfileChanged) { | ||
fail( | ||
"This PR contains `package-lock.json`, but we expect a `yarn.lock` instead as yarn is the preferred package manager for this project. We should not have to maintain two lockfiles.", | ||
); | ||
} | ||
|
||
// 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."); | ||
} | ||
|
||
// Warn when there is a big PR | ||
const bigPRThreshold = 500; | ||
|
||
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) { | ||
warn(":exclamation: Big PR"); | ||
} | ||
|
||
// Always ensure we assign someone, so that our Slackbot can do its work correctly | ||
if (pr.assignee === null) { | ||
fail("Please assign someone to merge this PR, and optionally include people who should review."); | ||
} | ||
|
||
// Show TSLint errors inline | ||
// Yes, this is a bit lossy, we run the linter twice now, but its still a short amount of time | ||
// Perhaps we could indicate that tslint failed somehow the first time? | ||
// This process should always fail, so needs the `|| true` so it won't raise. | ||
child_process.execSync(`npm run lint -- -- --format json --out tslint-errors.json || true`); | ||
|
||
if (fs.existsSync("tslint-errors.json")) { | ||
const tslintErrors = JSON.parse(fs.readFileSync("tslint-errors.json", "utf8")) as any[]; | ||
if (tslintErrors.length) { | ||
const errors = tslintErrors.map(error => { | ||
const format = error.ruleSeverity === "ERROR" ? ":no_entry_sign:" : ":warning:"; | ||
const linkToFile = danger.github.utils.fileLinks([error.name]); | ||
return `* ${format} ${linkToFile} - ${error.ruleName} - ${error.failure}`; | ||
}); | ||
const tslintMarkdown = ` | ||
## TSLint Issues: | ||
${errors.join("\n")} | ||
`; | ||
markdown(tslintMarkdown); | ||
} | ||
} | ||
|
||
jest(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.