Coder Social home page Coder Social logo

danger-mention's Introduction

Danger ๐Ÿšซ

License Gem CI

Formalize your Pull Request etiquette.


What is Danger? โ€ข Vision โ€ข Helping Out โ€ข Plugin Development


What is Danger?

Danger runs during your CI process, and gives teams the chance to automate common code review chores.

This provides another logical step in your process, through this Danger can help lint your rote tasks in daily code review.

You can use Danger to codify your teams norms. Leaving humans to think about harder problems.

For example?

You can:

  • Enforce CHANGELOGs
  • Enforce links to Trello/JIRA in PR/MR bodies
  • Enforce using descriptive labels
  • Look out for common anti-patterns
  • Highlight interesting build artifacts
  • Give specific files extra focus

Danger provides the glue to let you build out the rules specific to your team's culture, offering useful metadata and a comprehensive plugin system to share common issues.

Getting Started

Alright. So, actually, you may be in the wrong place. From here on in, this README is going to be for people who are interested in working on and improving on Danger.

We keep all of the end-user documentation at https://danger.systems.

Some quick links: Guides Index, DSL Reference, Getting Started and What does Danger Do?.

I'm here to help out!

Brilliant. So, let's get you set up.

git clone https://github.com/danger/danger.git
cd danger
bundle install
bundle exec rake spec

This sets everything up and runs all of the tests.

Theory

Danger has a VISION.md file, which sums up the ideas around what Danger is. It is the lower bounds of what Danger means. Orta has written on handling and creating Danger on the Artsy blog, too.

Documentation

The code you write may end up in the public part of the website โ€” the easiest way to tell is that it is vastly overdocumented. If you are working in a space that looks over-documented, please be extra considerate to add documentation. We expect the consumers of that documentation to be non-rubyists, thus you should avoid specific jargon and try to provide duplicate overlapping examples.

Testing

So far, we've not really figured out the right way to make tests for our CLI commands. When we have done so, they've ended up being brittle. So, ideally, try to move any logic that would go into a command into separate classes, and test those. We're okay with the command not having coverage, but ideally the classes that make up what it does will.

I'd strongly recommend using bundle exec guard to run your tests as you work. Any changes you make in the lib, or specs will have corresponding tests run instantly.

Debugging

Ruby is super dynamic. One of the best ways to debug Ruby code is by using pry. We include pry for developers: when you have a problem, copy these two lines just before your problem and follow the instructions from "I Want To Be A Danger Wizard."

require 'pry'
binding.pry

License, Contributor's Guidelines and Code of Conduct

We try to keep as much discussion as possible in GitHub issues, but also have a pretty inactive Slack --- if you'd like an invite, ping @Orta a DM on Twitter with your email. It's mostly interesting if you want to stay on top of Danger without all the emails from GitHub.

This project is open source under the MIT license, which means you have full access to the source code and can modify it to fit your own needs.

This project subscribes to the Moya Contributors Guidelines which TLDR: means we give out push access easily and often.

Contributors subscribe to the Contributor Code of Conduct based on the Contributor Covenant version 1.3.0.

danger-mention's People

Contributors

dlackty avatar krausefx avatar mikz avatar orta avatar wojteklu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

danger-mention's Issues

Missing blame information (Gitlab CI and docker)

Hi,

I keep getting this error

/usr/local/bundle/gems/danger-mention-0.6.1/lib/danger_plugin.rb:101:in `initialize':  (Danger::DSLError)
[!] Invalid `Dangerfile` file: No such file or directory @ rb_sysopen - **https://mygitlab.com/myproject/blame/development/path_to_my_file/file.ts**
  • I'm running Danger and Danger Mention in a docker image
  • blame/development this path does not exist
  • development is the name of my branch
  • Here is my Dangerfile
mention.run(2, [".gitlab-ci.yml"], ["danger"])

What do I need to do to have blame folder?

Thank you

Private repositories support

Hi there, I've been checking the code in this repo and couldn't think of a way of making this plugin available for private repositories.

Do you guys have any idea or plan to make this work with private repos?

Invalid `Dangerfile` file: 401 Unauthorized

Got the following error when I tried running mention.run or even mention.run(2, [], []) as well.

My service account that is associated with the access token has Reporter rights (tried as Developer, but same results). I am also running on a private GitLab instance. Before adding mention, danger was working fine, but I am a bit left in the dark here.

Any tips on how to debug this further?

I could read the following on the Reference page:

Note: This plugin uses the web-scraping of GitHub.com and GitLab to detect the authors to find potential reviewers. This might cause the plugin to break if either of those pages introduce design changes.

Could that be it?

Here's the raw output:

/usr/local/lib/ruby/2.3.0/open-uri.rb:359:in `open_http':  (Danger::DSLError)
[!] Invalid `Dangerfile` file: 401 Unauthorized
 #  from Dangerfile:2
 #  -------------------------------------------
 #  # Find some reviewers for this MR
 >  mention.run
 #  
 #  -------------------------------------------
	from /usr/local/lib/ruby/2.3.0/open-uri.rb:737:in `buffer_open'
	from /usr/local/lib/ruby/2.3.0/open-uri.rb:212:in `block in open_loop'
	from /usr/local/lib/ruby/2.3.0/open-uri.rb:210:in `catch'
	from /usr/local/lib/ruby/2.3.0/open-uri.rb:210:in `open_loop'
	from /usr/local/lib/ruby/2.3.0/open-uri.rb:151:in `open_uri'
	from /usr/local/lib/ruby/2.3.0/open-uri.rb:717:in `open'
	from /usr/local/lib/ruby/2.3.0/open-uri.rb:35:in `open'
	from /usr/local/bundle/gems/danger-mention-0.6.1/lib/danger_plugin.rb:101:in `parse_blame'
	from /usr/local/bundle/gems/danger-mention-0.6.1/lib/danger_plugin.rb:46:in `block in run'
	from /usr/local/bundle/gems/danger-mention-0.6.1/lib/danger_plugin.rb:45:in `each'
	from /usr/local/bundle/gems/danger-mention-0.6.1/lib/danger_plugin.rb:45:in `run'
	from Dangerfile:2:in `block in parse'
	from /usr/local/bundle/gems/danger-5.5.5/lib/danger/danger_core/dangerfile.rb:200:in `eval'
	from /usr/local/bundle/gems/danger-5.5.5/lib/danger/danger_core/dangerfile.rb:200:in `block in parse'
	from /usr/local/bundle/gems/danger-5.5.5/lib/danger/danger_core/dangerfile.rb:196:in `instance_eval'
	from /usr/local/bundle/gems/danger-5.5.5/lib/danger/danger_core/dangerfile.rb:196:in `parse'
	from /usr/local/bundle/gems/danger-5.5.5/lib/danger/danger_core/dangerfile.rb:273:in `run'
	from /usr/local/bundle/gems/danger-5.5.5/lib/danger/danger_core/executor.rb:27:in `run'
	from /usr/local/bundle/gems/danger-5.5.5/lib/danger/commands/runner.rb:66:in `run'
	from /usr/local/bundle/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
	from /usr/local/bundle/gems/danger-5.5.5/bin/danger:5:in `<top (required)>'
	from /usr/local/bundle/bin/danger:22:in `load'
	from /usr/local/bundle/bin/danger:22:in `<main>'
[!] The exception involves the following plugins:
 -  danger-mention

Something wrong with branch_for_base call (CircleCI)

Log

bundle exec danger

[!] The exception involves the following plugins:
 -  danger-mention

bundler: failed to load command: danger (/home/ubuntu/repo/vendor/bundle/ruby/2.2.0/bin/danger)
Danger::DSLError: 
[!] Invalid `Dangerfile` file: undefined method `branch_for_base' for #<Danger::Dangerfile:0x007f70336cc848>
 #  from Dangerfile:36
 #  -------------------------------------------
 #  # Mention potential reviewers
 >  mention.run
 #  -------------------------------------------

  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-4.0.5/lib/danger/danger_core/dangerfile.rb:68:in `method_missing'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-4.0.5/lib/danger/plugin_support/plugin.rb:23:in `method_missing'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-mention-0.4.0/lib/danger_plugin.rb:78:in `compose_urls'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-mention-0.4.0/lib/danger_plugin.rb:45:in `run'
  Dangerfile:36:in `block in parse'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-4.0.5/lib/danger/danger_core/dangerfile.rb:199:in `eval'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-4.0.5/lib/danger/danger_core/dangerfile.rb:199:in `block in parse'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-4.0.5/lib/danger/danger_core/dangerfile.rb:195:in `instance_eval'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-4.0.5/lib/danger/danger_core/dangerfile.rb:195:in `parse'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-4.0.5/lib/danger/danger_core/dangerfile.rb:272:in `run'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-4.0.5/lib/danger/danger_core/executor.rb:27:in `run'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-4.0.5/lib/danger/commands/runner.rb:66:in `run'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/claide-1.0.1/lib/claide/command.rb:334:in `run'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/gems/danger-4.0.5/bin/danger:5:in `<top (required)>'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/bin/danger:23:in `load'
  /home/ubuntu/repo/vendor/bundle/ruby/2.2.0/bin/danger:23:in `<top (required)>'

bundle exec danger returned exit code 1

Dangerfile

# Sometimes it's a README fix, or something like that - which isn't relevant for
# including in a project's CHANGELOG for example
# declared_trivial = github.pr_title.include? "#trivial"

# Make it more obvious that a PR is a work in progress and shouldn't be merged yet
warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"

# Warn when there is a big PR
warn("Big PR") if git.lines_of_code > 500

# Don't let testing shortcuts get into master by accident
# fail("fdescribe left in tests") if `grep -r fdescribe specs/ `.length > 1
# fail("fit left in tests") if `grep -r fit specs/ `.length > 1

# Ensure a PR has someone assigned to it
warn "This PR does not have any assignees yet." unless github.pr_json["assignee"]

# PRs should reference an issue
unless (github.pr_body.include? "Closes #" or github.pr_body.include? "Connects #")
  fail "This PR doesn't close or connect to an issue."
end

# PRs should almost always merge to dev.
unless github.branch_for_base == "dev"
  warn "This PR will not be merged into dev."
end

# Warn if TODOs are present in code
# todoist.warn_for_todos
# todoist.print_todos_table

# Lint commit message
commit_lint.check

# Mention potential reviewers
# mention.run

Gemfile

# frozen_string_literal: true
source "https://rubygems.org"

gem 'danger'
gem 'danger-todoist' # Checks for TODO etc in commits
gem 'danger-commit_lint' # Lints commit messages
gem 'danger-mention' # Mention potential reviewers

[!] Invalid `Dangerfile` file: 404 Not Found

It seems that when I submit a PR with new files, the danger plugin fails with a 404 Not Found error. You can see this here and here. If only modify existing files there are no failures as seen here. I am assuming that GitHub's response in the new file case is empty or different enough for the plugin to fail.

Please let me know if there is any additional information I can provide to help.

Thanks.

Use GitHub request Reviewers feature

Recently GitHub has added a new feature into the PR to request specific users for a review.
Would be nice to have that automated with danger.

GitLab support

Hi @wojteklu,

now that Danger supports GitLab I'd be interested in your take on supporting GitLab. I am happy to do the work if you think it can be include in the plugin in a nice way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.