Skip to content
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

Adds a Danger Process command that outputs the DSL as a JSON object #341

Merged
merged 5 commits into from
Aug 26, 2017

Conversation

orta
Copy link
Member

@orta orta commented Aug 18, 2017

Re: #340

screen shot 2017-08-18 at 07 32 44

This will now take the results of the Danger PR and pass that into the STDIN of a child process. For example this Ruby Script:

#!/usr/bin/env ruby

puts 'Hello world'

str = STDIN.tty? ? 'Cannot read from STDIN' : $stdin.read
puts str

With this command danger process ./scripts/danger_runner.rb would echo first "Hello world" then output the JSON in the above screenshot. You could make a trivial version of Ruby Danger with this:

#!/usr/bin/env ruby

require 'json'
dsl_json = STDIN.tty? ? 'Cannot read from STDIN' : $stdin.read
danger = JSON.parse(dsl_json)

if danger.github.pr.body.include? "Hello world"
  # TODO: sending messages back
end

Now I need to handle sending messages back to Danger JS.

@DangerCI
Copy link

DangerCI commented Aug 18, 2017

New dependencies added: .

Generated by 🚫 dangerJS

@orta orta merged commit fa3b711 into master Aug 26, 2017
@orta orta deleted the danger-process branch August 26, 2017 18:04
@zdnk
Copy link
Contributor

zdnk commented Aug 27, 2017

Is it somehow possible to do this for danger Ruby version and then use the output of Ruby version be parsed and worked with in danger-js? Because we have private Bitbucket server which cannot be used with danger-js yet.

@orta
Copy link
Member Author

orta commented Aug 27, 2017

It's possible, as with all programming anything is possible but it's not something I plan on doing maintaining three processes that communicate with each other for this feature sounds complex. If you're looking to make Bitbucket work with Danger Process, Bitbucket support will need to be added to Danger JS.

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][danger-swift]. It takes a [JSON][swift-json] file via [STDIN][swift-stdin], [compiles
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor clarification: JSON file may be more accurate as JSON document if I'm understanding correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct, I've just updated the changelog: d0fc1eb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants