-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Adds support for using Danger on PRs #2508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
// ("/href/thing", "name") to "<a href="/href/thing">name</a>" | ||
const createLink = (href: string, text: string): string => | ||
`<a href='${href}'>${text}</a>`; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some of these ^ are functions from Danger RB, in the future I should probably move them into DangerJS too - the use case seems pretty universal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah please do!
I think these CI fails are from our usage of
|
|
||
// ["1", "2", "3"] to "1, 2 and 3" | ||
const toSentence = (array: Array<string>) : string => | ||
array.slice(0, array.length - 1).join(', ') + ' and ' + array.pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a case where the array has a length of 1? In that case this will return and 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah, definitely! Good catch.
// New JS files should have the FB copyright header | ||
const noFBCopyrightFiles = newJsFiles.filter(filepath => { | ||
const content = fs.readFileSync(filepath).toString(); | ||
return !content.includes('Facebook, Inc. All rights reserved'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we make this more complete and check that the first thing in the file is the full FB copyright header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, might need to be a regex ( the year is variable ) this was the constant part, I can build on this
@@ -43,7 +45,7 @@ | |||
"postinstall": "node ./scripts/postinstall.js && node ./scripts/build.js", | |||
"publish": "yarn run build-clean && yarn run build && lerna publish", | |||
"test": "yarn run typecheck && yarn run lint && yarn run build && yarn run jest && yarn run test-examples", | |||
"test-ci": "yarn run typecheck && yarn run lint && yarn run build && yarn run jest-coverage -- -i && yarn run test-examples && node scripts/mapCoverage.js && codecov", | |||
"test-ci": "yarn run typecheck && yarn run lint && yarn run build && yarn run jest-coverage -- -i && yarn run test-examples && node scripts/mapCoverage.js && codecov && yarn run danger", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda wish danger could replace codecov.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume codecov reads some pre-existing files to derive output? It's totally feasible ( we have ruby Danger parsing JUnit files in our iOS app )
However, as you noted below, it's the state that doesn't necessarily work. In ruby Danger, there is a plugin for persistence (https://github.com/dbgrandi/danger-mcbrain) which could get replicated as a free heroku mongo somewhere or something to keep state
I'll get the access data for the jest-bot and will report back when I added the token. A few things that would be nice (I will add more ideas some time):
Does Danger have any form of state? Can we potentially use it to compare the performance of the test run to master? |
|
@orta I added the token to travis using |
The master CI is broken, I'm gonna test without running ESLinter et al |
069bdb9
to
c7ede40
Compare
@cpojer is it possible that you didn't give the github account access token the public scope? I'm getting a 403 when I use the one in travis, but it works fine with a random Artsy OSS one |
@@ -0,0 +1,72 @@ | |||
// @flow | |||
|
|||
// const { danger, fail, warn } = require('danger'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on a release with danger/danger-js#82 to support having this uncommented ( Danger normally comments out these requires and injects the deps in at runtime. It's only there for tooling support )
I set the "Display value in build log" to "on". Is there something else I need to do? |
done! |
Generated by 🚫 dangerJS |
Rock, that looks good to me. Will see if I can get enough time today to ship the commits API, otherwise might look over the weekend for that 👍 |
Awesome! Let me know when it's ready and doesn't spam people so much any more ;) |
@orta the Flow link warning has a link to |
This reverts commit 2b81d21.
Taken from jestjs/jest#2508 This would have applied to #101
Based on jestjs/jest#2508 This would have applied to #101
* Initial Dangerfile, adds a rule for including flow and the FB header * [Danger] Use a local path for jest-runtime instead of the downloaded NPM package * [Danger] Makes the FB copyright header check correct * just run danger * Update Danger
…stjs#2525) * Cleanup travis install. We don’t need the latest npm3 any longer. * Revert "Adds support for using Danger on PRs (jestjs#2508)" This reverts commit 2b81d21.
* Initial Dangerfile, adds a rule for including flow and the FB header * [Danger] Use a local path for jest-runtime instead of the downloaded NPM package * [Danger] Makes the FB copyright header check correct * just run danger * Update Danger
…stjs#2525) * Cleanup travis install. We don’t need the latest npm3 any longer. * Revert "Adds support for using Danger on PRs (jestjs#2508)" This reverts commit 2b81d21.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Adds Danger.
With initial Danger rules:
Test plan
This Dangerfile does not have the FB Copyright Header, so once Danger is set up she should fail this build.
Discussion
Setup
This requires a bit of config by @cpojer - you will need to go through the "creating a bot account" - as this is OSS, it should be a new account with zero privileges to any repos.
After that you'll need to add a token to travis for
DANGER_GITHUB_API_TOKEN
.