// Please add your own contribution below inside the Master section, ideally with a consumer's perspective in mind.
Some UX fixes:
- Don't show warnings about not setting a commit status (unless in verbose) - orta
- Delete duplicate Danger message, due to fast Peril edits - orta
- Show Peril in the commit status if inside Peril, not just Danger - orta
- [internal] Tightened the typings on the commands, and abstracted them to share some code - orta
- Updates
diffForFile
,JSONPatchForFile
, andJSONDiffForFile
to include created and removed files - #368 - bdotdub
- Adds a blank project generated in travis 8 to test no-babel or TS integration - orta
- Improvements to
danger process
logging, and build fails correctly #363 - orta
- Improve the error handling around the babel API - #357 - orta
- Move back to the original URLs for diffs, instead of relying on PR metadata - orta
- Updates the types for
schedule
to be more accepting of what it actually takes - orta
- Fixed #348 invalid json response body error on generating a diff - felipesabino
- Potential fix for ^ that works with Peril also - orta
- Doh, makes the
danger process
command actually available via the CLI - orta
-
Adds a
danger process
command, this command takes amn argument of a process to run which expects the Danger DSL as JSON in STDIN, and will post a DangerResults object to it's STDOUT. This frees up another process to do whatever they want. So, others can make their own Danger runner.An example of this is Danger Swift. It takes a JSON document via STDIN, compiles and evaluates a Swift file then passes the results back to
danger process
via STDOUT.Another example is this simple Ruby script:
#!/usr/bin/env ruby require 'json' dsl_json = STDIN.tty? ? 'Cannot read from STDIN' : $stdin.read danger = JSON.parse(dsl_json) results = { warnings: [], messages:[], fails: [], markdowns: [] } if danger.github.pr.body.include? "Hello world" results.messages << { message: "Hey there" } end require 'json' STDOUT.write(results.to_json)
Which is basically Ruby Danger in ~10LOC. Lols.
This is the first release of the command, it's pretty untested, but it does work. - orta
-
Uses the Babel 7 alpha for all source compilation with JS, Flow+JS and TS. This worked without any changes to our internal infra which is pretty awesome. All TS tests passed. Babel 7 is still in alpha, but so is Danger 2.0 - so I'm happy to keep Danger in a pretty long alpha, till at least Babel 7 is in beta.
It also still supports using TypeScript via the "
typescript"
module, if you have that installed. - orta -
danger.github.thisPR
now uses the PR's head, not base - orta
- Uses the GitHub
diff_url
instead of thediff
version header, as it conflicted with Peril - orta - Handle exceptions in Dangerfile and report them as failures in Danger results - macklinu
- Expose a Promise object to the external GitHub API - orta
- Allow running a dangerfile entirely from memory using the
Executor
API - orta
- Removes the
jest-*
dependencies - orta
-
Support a vm2 based Dangerfile runner as an alternative to the jest infrastructure. There are a few main reasons for this:
-
I haven't been able to completely understand how Jest's internals work around all of the code-eval and pre-requisite setup, which has made it hard to work on some more complex Peril features.
-
Jest releases are every few months, personally I love this as a user of Jest, as an API consumer it can be difficult to get changes shipped.
-
The fact that both Danger/Jest make runtime changes means that you need to update them together
-
I have commit access to vm2, so getting changes done is easy
I like to think of it as having gone from Jest's runner which is a massive toolbox, to vm2 which is a tiny toolbox where I'll have to add a bunch of new tools to get everything working.
The massive downside to this is that Danger now has to have support for transpiling via Babel, or from TypeScript unlike before, where it was a freebie inside Jest. Jest handled this so well. This means that a Dangerfile which used to "just work" with no config may not. Thus, IMO, this is a breaking major semver.
Is it likely that you need to make any changes? So far, it seems probably not. At least all of the tests with Dangerfiles original from the older Jest runner pass with the new version.
This is an alpha release, because it's knowingly shipped with some breakages around babel support, specifically:
- Babel parsing of relative imports in a Dangerfile aren't working
- Some of the features which require the
regeneratorRuntime
to be set up aren't working yet
Those are blockers on a 2.0.0 release.
-
-
Exposes an internal API for reading a file from a GitHub repo as
danger.github.utils.fileContents
- ortaIdeally this is what you should be using in plugins to read files, it's what Danger uses throughout the codebase internally. This means that your plugin/dangerfile doesn't need to rely on running on the CI when instead it could run via the GitHub API.
-
Update prettier - orta
-
Removes dtslint as a dependency - sapegin/orta
- Support retrive paginated pull request commit list - kwonoj
- Add support for VSTS CI - mlabrum
- Remove the DSL duplication on the
danger
export, it wasn't needed or used. - orta - Update to TypeScript 2.4.x - orta
- Rename github test static_file to remove
:
from the filename to fix a checkout issue on windows - mlabrum
Hello readers! This represents a general stability for Danger. It is mainly a documentation release, as it corresponds to http://danger.systems/js/ being generally available. I made the initial commit back in 20 Aug 2016 and now it's 30th June 2017. It's awesome to look back through the CHANGELOG and see how things have changed.
You can find out a lot more about the 1.0, and Danger's history on my Artsy blog post on the Danger 1.0.
- Adds inline docs for all CI providers - orta
- Use HTTP for the GitHub status check target URL - macklinu
- Correct some examples in node-app - clintam
- Add support for buddybuild CI - benkraus/clintam
- Add support for GithHub Apps API (no GET /user) - clintam
- Posts status reports for passing/failing builds, if the account for danger has access - orta
- Adds prettier to the codebase - orta
- Converts a bunch of Danger's dangerfile into a plugin - danger-plugin-yarn - orta
This is my first non-trivial plugin, based on infrastructure from @macklinu. Plugins are looking great, you can get some info at https://github.com/macklinu/generator-danger-plugin.
- Docs updates for the website - orta
- Fix
danger pr
commands are not running on windows - kwonoj - Fix broken link in getting started docs - frozegnome
- Do not delete comment written from user have same userid for danger - kwonoj
- Fix link to
jest
in getting started docs - palleas - Fix yarn install instruction in getting started docs - palleas
- Update to Jest 20 - macklinu
- Change the danger.d.ts to use module exports instead of globals - orta
- Render markdown inside
message()
,warn()
, andfail()
messages. - macklinu
An example:
fail(`Missing Test Files:
- \`src/lib/components/artist/artworks/__tests__/index-tests.tsx\`
- \`src/lib/components/artwork_grids/__tests__/infinite_scroll_grid-tests.tsx\`
- \`src/lib/containers/__tests__/works_for_you-tests.tsx\`
If these files are supposed to not exist, please update your PR body to include "Skip New Tests".`)
Will result in:
Fails | |
---|---|
🚫 | Missing Test Files:
If these files are supposed to not exist, please update your PR body to include "Skip New Tests". |
-
Adds
github.api
. This is a fully authenticated client from the github npm module. - @ortaAn easy example of it's usage would be using Danger to add a label to your PR. Note that Danger will have the permissions for your account, so for OSS repos - this won't work.
danger.github.api.issues.addLabels({ owner: "danger", repo: "danger-js", number: danger.github.pr.number, labels: ["Danger Passed"] })
Yeah, that's a bit verbose, I agree. So, there's also
github.thisPR
which should simplify that. It aims to provide a lot of the values for the current PR to use with the API.const github = danger.github github.api.issues.addLabels({ ...github.thisPR, labels: ["Danger Passed"] })
You could use this API for a bunch of things, here's some quick ideas:
- Request specific reviewers when specific files change (
api.pullRequests.createReviewRequest
) - Add a label for when something passes or fails (
api.issues.addLabels
) - Verifying if someone is in your org? (
api.orgs.checkMembership
) - Updating Project tickets to show they have a PR (
api.projects.updateProject
)
- Request specific reviewers when specific files change (
-
Enhancements to
danger.git.diffForFile()
- @namuol- Removed
diffTypes
second argument in favor ofresult.added
andresult.removed
- Added
result.before
andresult.after
for easy access to full contents of the original & updated file danger.git.diffForFile
is now anasync
function
// In danger 0.16.0: const fullDiff = danger.git.diffForFile('foo.js') const addedLines = danger.git.diffForFile('foo.js', ['add']) const removedLines = danger.git.diffForFile('foo.js', ['del']) // In the latest version: const diff = await danger.git.diffForFile('foo.js') const fullDiff = diff.diff const addedLines = diff.added const removedLines = diff.removed const beforeFileContents = diff.before const afterFileContents = diff.after
- Removed
-
Update internal test fixture generation docs - namuol
- Adds a
diffTypes
option todiffForFile
- alex3165 - Add Buildkite CI source - jacobwgillespie
- When a Dangerfile fails to eval, send a message to the PR - orta
-
Updated jest-* dependencies to 19.x - orta
Updating the jest-* dependencies seems to be exhibiting strange behavior in tests for windows if you update, and use windows, can you please confirm that everything is 👍
-
Added type shapings to
JSONPatchForFile
- orta -
Replaced deprecated
lodash.isarray
package withArray.isArray
- damassi
- Moved
@types/chalk
from dependencies to devDependencies - orta - Killed some stray console logs - orta
- Updated the danger.d.ts - orta
-
TypeScript Dangerfiles are now support in Danger - orta
We use TypeScript in Danger, and a lot of my work in Artsy now uses TypeScript (see: JS2017 at Artsy), so I wanted to explore using TypeScript in Dangerfiles.
This is built on top of Jest's custom transformers, so if you are already using Jest with TypeScript, then you can change the
dangerfile.js
todangerfile.ts
and nothing should need changing ( except that you might have new warnings/errors ) (note: in changing this for Danger, I had to also add thedangerfile.ts
to the"exclude"
section of thetsconfig.json
so that it didn't change the project's root folder.)This repo is now using both a babel Dangerfile (running on Circle CI) and a TypeScript one (running on Travis) to ensure that we don't accidentally break either.
-
Created a new
danger.d.ts
for VS Code users to get auto-completion etc - orta -
Added a two new
git
DSL functions:git.JSONDiffForFile(filename)
andgit.JSONPatchForFile(filename)
.-
git.JSONPatchForFile
This will generate a rfc6902 JSON patch between two files inside your repo. These patch files are useful as a standard, but are pretty tricky to work with in something like a Dangerfile, where rule terseness takes priority.
-
git.JSONDiffForFile
This uses
JSONPatchForFile
to generate an object that represents all changes inside a Dangerfile as a single object, with keys for the changed paths. For example with a change like this:{ "dependencies": { "babel-polyfill": "^6.20.0", + "chalk": "^1.1.1", "commander": "^2.9.0", "debug": "^2.6.0" }, }
You could become aware of what has changed with a Dangerfile in a
schedule
'd function like:const packageDiff = await git.JSONDiffForFile("package.json") if (packageDiff.dependencies) { const deps = packageDiff.dependencies deps.added // ["chalk"], deps.removed // [] deps.after // { "babel-polyfill": "^6.20.0", "chalk": "^1.1.1", "commander": "^2.9.0", "debug": "^2.6.0" } deps.before // { "babel-polyfill": "^6.20.0", "commander": "^2.9.0", "debug": "^2.6.0" } }
The keys:
added
andremoved
only exist on the object if:before
andafter
are both objects - in which caseadded
andremoved
are the added or removed keysbefore
andafter
are both arrays - in which caseadded
andremoved
are the added or removed values
-
-
Exposed all global functions ( like
warn
,fail
,git
,schedule
, ... ) on thedanger
object. - ortaThis is specifically to simplify building library code. It should not affect end-users. If you want to look at making a Danger JS Plugin, I'd recommend exposing a function which takes the
danger
object and working from that. If you're interested, there is an active discussion on plugin support in the DangerJS issues. -
Improves messaging to the terminal - orta
-
Adds the ability to not have Danger post to GitHub via a flag:
danger run --text-only
- orta -
Fix a crasher with
prs.find
#181 - orta
-
Add
danger.utils
DSL, which includesdanger.utils.href()
anddanger.utils.sentence()
- macklinuWe were finding that a lot of Dangerfiles needed similar functions, so we've added a
utils
object to offer functions that are going to be used across the board. If you can think of more functions you use, we'd love to add them. Ideally you shouldn't need to use anything but Danger + utils to write your Dangerfiles.danger.utils.href("http://danger.systems", "Danger") // <a href="http://danger.systems">Danger</a> danger.utils.sentence(["A", "B", "C"]) // "A, B and C"
-
Adds
danger.github.utils
- which currently has only one function:fileLinks
- ortaMost of the time people are working with a list of files (e.g. modified, or created) and then want to present clickable links to those. As the logic to figure the URLs is very GitHub specific, we've moved that into it's own object with space to grow.
const files = danger.git.modified_files // ["lib/component/a.ts", "lib/component/b.ts"] const links = danger.github.utils.fileLinks(files) // "<a href='...'>a</a> and <a href='...'>b</a>" warn(`These files have changes: ${links}`)
- Add support for Drone - gabro
-
Added support for handling async code in a Dangerfile - deecewan
This is still a bit of a work in progress, however, there is a new function added to the DSL:
schedule
.A Dangerfile is evaluated as a script, and so async code has not worked out of the box. With the
schedule
function you can now register a section of code to evaluate across multiple tick cycles.schedule
currently handles two types of arguments, either a promise or a function with a resolve arg. Assuming you have a working Babel setup for this inside your project, you can run a Dangerfile like this:schedule(async () => { const thing = await asyncAction() if (thing) { warn('After Async Function') } });
Or if you wanted something simpler,
schedule((resolved) => { if (failed) { fail("Failed to run") } })
-
Adds new GitHub DSL elements - deecewan
-
danger.github.issue
- As a PR is an issue in GitHub terminology, the issue contains a bit more metadata. Mainly labels, so if you want to know what labels are applied to a PR, usedanger.github.issue.labels
-
danger.github.reviews
- Find out about your reviews in the new GitHub Reviewer systems, -
danger.github.requested_reviewers
- Find out who has been requested to review a PR. -
Updated TypeScript and Jest dependencies - orta
-
Add support for Github Enterprise via DANGER_GITHUB_API_BASE_URL env var - mashbourne
-
Internal changes for usage with Peril - orta
-
Add
danger pr --repl
, which drops into a Node.js REPL after evaluating the dangerfile - macklinu -
Add support for Codeship - deecewan
- Add support for Docker Cloud - camacho
- Builds which only use markdown now only show the markdown, and no violations table is shown - mxstbr
- Adds support for running Danger against a PR locally - orta
The workflow is that you find a PR that exhibits the behavior you'd like Danger to run against,
then edit the local Dangerfile.js
and run yarn run danger pr https://github.com/facebook/jest/pull/2629
.
This will post the results to your console, instead of on the PR itself.
- Danger changes to your Dangerfile are not persisted after the run - orta
- Add summary comment for danger message - kwonoj
- Add
jest-environment-node
to the Package.json - orta
-
Adds support for
git.commits
andgithub.commits
- ortaWhy two? Well github.commits contains a bunch of github specific metadata ( e.g. GitHub user creds, commit comment counts. ) Chances are, you're always going to use
git.commits
however if you want more rich data, the GitHub one is available too. Here's an example:
const merges = git.commits.filter(commit => commit.message.include("Merge Master"))
if (merges.length) { fail("Please rebase your PR")}
- Support custom dangerfile via
-d
commandline arg - kwonoj - Allow debug dump output via
DEBUG=danger:*
environment variable - kwonoj - Adds surf-build ci provider - kwonoj
- Forward environment variables to external module constructor - kwonoj
- Support
danger run -ci
to specify external CI provider - kwonoj - Adds
--verbose
todanger
, which for now will echo out all the URLs Danger has requested - orta - Migrate codebase into TypeScript from flow - kwonoj
- Handle removing all sorts of import types for Danger in the Dangerfile - orta
- A failing network request will raise an error - orta
- Fix Dangerfile parsing which broke due to Peril related changes - orta
- Tweak the npmignore, ship less random stuff to others - orta
- Fixes to the shipped Flow/TS definitions - orta
- Adds more functions the the internal Danger GitHub client - orta
- Infrastructure work to allow Peril to run a Dangerfile - orta
- Upgrade outdated ESLint packages - macklinu
- Enhance Windows OS compatibility - kwonoj
- Set exit code to 1 when running
danger
throws an error - macklinu - Add Jenkins CI source - macklinu
- Add .editorconfig - macklinu
- Adds jest-runtime to the dependencies - orta
-
You can build and run in vscode using your own custom
env/development.env
file. This is useful because you can use the debugger against a real PR. Seeenv/development.env.example
for syntax. - orta -
Uses
jest-transform
andjest-runtime
to eval and apply babel transforms.This does two things, makes it feasible to do hosted-danger and makes it possible to write your Dangerfile in a way that's consistent with the rest of your JavaScript. - orta
-
Add tests directory to .npmignore - macklinu
-
Update to Jest 18 - macklinu
- Brings back the ability to emulate a fake CI run locally via
danger
- orta
- Makes
babel-polyfill
a direct dependency, this is because it is actually an implicit dependency in the app. I'm not sure how I feel about this, I guess if we use a part of it in the babel translation of a user's Dangerfile them I'm OK with it. - orta
- Ship flow annotations with the npm module - orta
- Adds more node instances to travis - romanki + orta
- Adds support for Semaphore CI - orta
- The env vars
DANGER_TEST_REPO
andDANGER_TEST_PR
will allow you initialize the FakeCI with a repo of your choice. See README.md for more info - Improved error messaging around not including a
DANGER_GITHUB_API_TOKEN
in the ENV - nsfmc / orta - Adds support for getting the diff for a specific file from git: e.g.
// Politely ask for their name on the entry too
const changelogDiff = danger.git.diffForFile("changelog.md")
const contributorName = danger.github.pr.user.login
if (changelogDiff && changelogDiff.indexOf(contributorName) === -1) {
warn("Please add your GitHub name to the changelog entry, so we can attribute you.")
}
- Does not break commonmark on GitHub - orta
- upgrades to flow 0.35.0 and fixes associated type errors in covariant/invariant interfaces - nsfmc
- omits flow requirement for new test files - nsfmc
- adds support for circleci - nsfmc
- defines CISource properties in flow as read-only - nsfmc
danger.pr
->danger.github.pr
, I've also created interfaces for them - ortawarn
,message
,markdown
are all ported over to DangerJS - orta- Shows a HTML table for Danger message - orta
- Now offers a Flow-typed definition file, it's not shipped to their repo yet, you can make it by
npm run export-flowtype
- orta - Started turning this into a real project by adding tests - orta
- Changes some files casing, added some logs, a bit of error reporting, and verifying everything works through npm - orta
- Danger edit an existing post, and delete it when it's not relevant - orta
- Danger will post a comment on a GitHub PR with any Fails - orta
OK, first usable for others version. Only supports GitHub and Travis CI.
You can run by doing:
danger
Make sure you set a DANGER_GITHUB_API_TOKEN
on your CI - see the Ruby guide for that.
Then you can make a dangerfile.js
(has to be lowercase, deal with it.) It has access to a whopping 2 DSL attributes.
pr
git
fail(message: string)
pr
probably won't be sticking around for the long run, but if you're using a 0.0.2
release, you should be OK with that. It's the full metadata of the PR, so this JSON file.
git
currently has:
git.modified_file
git.created_files
git.deleted_files
which are string arrays of files.
fail(message: string)
will let you raise an error, and will make the process return 1 after the parsing has finished.
Overall: your Dangerfile should look something like:
import { danger } from "danger"
const hasChangelog = danger.git.modified_files.includes("changelog.md")
if (!hasChangelog) {
fail("No Changelog changes!")
}
That should do ya. I think. This doesn't support babel, and I haven't explored using other modules etc, so...
./
Not usable for others, only stubs of classes etc. - orta