danger-additional-logging 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +93 -0
  4. data/bin/danger +5 -0
  5. data/lib/assets/DangerfileTemplate +13 -0
  6. data/lib/danger/ci_source/appcenter.rb +55 -0
  7. data/lib/danger/ci_source/appcircle.rb +83 -0
  8. data/lib/danger/ci_source/appveyor.rb +64 -0
  9. data/lib/danger/ci_source/azure_pipelines.rb +61 -0
  10. data/lib/danger/ci_source/bamboo.rb +41 -0
  11. data/lib/danger/ci_source/bitbucket_pipelines.rb +37 -0
  12. data/lib/danger/ci_source/bitrise.rb +78 -0
  13. data/lib/danger/ci_source/buddybuild.rb +62 -0
  14. data/lib/danger/ci_source/buildkite.rb +51 -0
  15. data/lib/danger/ci_source/ci_source.rb +37 -0
  16. data/lib/danger/ci_source/circle.rb +94 -0
  17. data/lib/danger/ci_source/circle_api.rb +51 -0
  18. data/lib/danger/ci_source/cirrus.rb +31 -0
  19. data/lib/danger/ci_source/code_build.rb +71 -0
  20. data/lib/danger/ci_source/codefresh.rb +47 -0
  21. data/lib/danger/ci_source/codemagic.rb +58 -0
  22. data/lib/danger/ci_source/codeship.rb +44 -0
  23. data/lib/danger/ci_source/concourse.rb +60 -0
  24. data/lib/danger/ci_source/custom_ci_with_github.rb +49 -0
  25. data/lib/danger/ci_source/dotci.rb +50 -0
  26. data/lib/danger/ci_source/drone.rb +71 -0
  27. data/lib/danger/ci_source/github_actions.rb +44 -0
  28. data/lib/danger/ci_source/gitlab_ci.rb +89 -0
  29. data/lib/danger/ci_source/jenkins.rb +148 -0
  30. data/lib/danger/ci_source/local_git_repo.rb +117 -0
  31. data/lib/danger/ci_source/local_only_git_repo.rb +44 -0
  32. data/lib/danger/ci_source/screwdriver.rb +48 -0
  33. data/lib/danger/ci_source/semaphore.rb +37 -0
  34. data/lib/danger/ci_source/support/commits.rb +19 -0
  35. data/lib/danger/ci_source/support/find_repo_info_from_logs.rb +35 -0
  36. data/lib/danger/ci_source/support/find_repo_info_from_url.rb +43 -0
  37. data/lib/danger/ci_source/support/local_pull_request.rb +14 -0
  38. data/lib/danger/ci_source/support/no_pull_request.rb +7 -0
  39. data/lib/danger/ci_source/support/no_repo_info.rb +5 -0
  40. data/lib/danger/ci_source/support/pull_request_finder.rb +190 -0
  41. data/lib/danger/ci_source/support/remote_pull_request.rb +15 -0
  42. data/lib/danger/ci_source/support/repo_info.rb +10 -0
  43. data/lib/danger/ci_source/surf.rb +37 -0
  44. data/lib/danger/ci_source/teamcity.rb +163 -0
  45. data/lib/danger/ci_source/travis.rb +51 -0
  46. data/lib/danger/ci_source/xcode_cloud.rb +38 -0
  47. data/lib/danger/ci_source/xcode_server.rb +48 -0
  48. data/lib/danger/clients/rubygems_client.rb +14 -0
  49. data/lib/danger/commands/dangerfile/gem.rb +43 -0
  50. data/lib/danger/commands/dangerfile/init.rb +30 -0
  51. data/lib/danger/commands/dry_run.rb +54 -0
  52. data/lib/danger/commands/init.rb +297 -0
  53. data/lib/danger/commands/init_helpers/interviewer.rb +92 -0
  54. data/lib/danger/commands/local.rb +83 -0
  55. data/lib/danger/commands/local_helpers/http_cache.rb +38 -0
  56. data/lib/danger/commands/local_helpers/local_setup.rb +48 -0
  57. data/lib/danger/commands/local_helpers/pry_setup.rb +32 -0
  58. data/lib/danger/commands/plugins/plugin_json.rb +44 -0
  59. data/lib/danger/commands/plugins/plugin_lint.rb +52 -0
  60. data/lib/danger/commands/plugins/plugin_readme.rb +42 -0
  61. data/lib/danger/commands/pr.rb +93 -0
  62. data/lib/danger/commands/runner.rb +94 -0
  63. data/lib/danger/commands/staging.rb +53 -0
  64. data/lib/danger/commands/systems.rb +41 -0
  65. data/lib/danger/comment_generators/bitbucket_server.md.erb +20 -0
  66. data/lib/danger/comment_generators/bitbucket_server_inline.md.erb +15 -0
  67. data/lib/danger/comment_generators/bitbucket_server_message_group.md.erb +12 -0
  68. data/lib/danger/comment_generators/github.md.erb +55 -0
  69. data/lib/danger/comment_generators/github_inline.md.erb +26 -0
  70. data/lib/danger/comment_generators/gitlab.md.erb +40 -0
  71. data/lib/danger/comment_generators/gitlab_inline.md.erb +21 -0
  72. data/lib/danger/comment_generators/vsts.md.erb +20 -0
  73. data/lib/danger/comment_generators/vsts_inline.md.erb +17 -0
  74. data/lib/danger/core_ext/file_list.rb +18 -0
  75. data/lib/danger/core_ext/string.rb +20 -0
  76. data/lib/danger/danger_core/dangerfile.rb +348 -0
  77. data/lib/danger/danger_core/dangerfile_dsl.rb +29 -0
  78. data/lib/danger/danger_core/dangerfile_generator.rb +11 -0
  79. data/lib/danger/danger_core/environment_manager.rb +126 -0
  80. data/lib/danger/danger_core/executor.rb +91 -0
  81. data/lib/danger/danger_core/message_aggregator.rb +50 -0
  82. data/lib/danger/danger_core/message_group.rb +68 -0
  83. data/lib/danger/danger_core/messages/base.rb +57 -0
  84. data/lib/danger/danger_core/messages/markdown.rb +41 -0
  85. data/lib/danger/danger_core/messages/violation.rb +53 -0
  86. data/lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb +142 -0
  87. data/lib/danger/danger_core/plugins/dangerfile_bitbucket_server_plugin.rb +211 -0
  88. data/lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb +274 -0
  89. data/lib/danger/danger_core/plugins/dangerfile_git_plugin.rb +159 -0
  90. data/lib/danger/danger_core/plugins/dangerfile_github_plugin.rb +264 -0
  91. data/lib/danger/danger_core/plugins/dangerfile_gitlab_plugin.rb +275 -0
  92. data/lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb +43 -0
  93. data/lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb +220 -0
  94. data/lib/danger/danger_core/plugins/dangerfile_vsts_plugin.rb +191 -0
  95. data/lib/danger/danger_core/standard_error.rb +142 -0
  96. data/lib/danger/helpers/array_subclass.rb +61 -0
  97. data/lib/danger/helpers/comment.rb +32 -0
  98. data/lib/danger/helpers/comments_helper.rb +179 -0
  99. data/lib/danger/helpers/comments_parsing_helper.rb +71 -0
  100. data/lib/danger/helpers/emoji_mapper.rb +41 -0
  101. data/lib/danger/helpers/find_max_num_violations.rb +31 -0
  102. data/lib/danger/helpers/message_groups_array_helper.rb +31 -0
  103. data/lib/danger/plugin_support/gems_resolver.rb +77 -0
  104. data/lib/danger/plugin_support/plugin.rb +52 -0
  105. data/lib/danger/plugin_support/plugin_file_resolver.rb +30 -0
  106. data/lib/danger/plugin_support/plugin_linter.rb +162 -0
  107. data/lib/danger/plugin_support/plugin_parser.rb +199 -0
  108. data/lib/danger/plugin_support/templates/readme_table.html.erb +26 -0
  109. data/lib/danger/request_sources/bitbucket_cloud.rb +169 -0
  110. data/lib/danger/request_sources/bitbucket_cloud_api.rb +181 -0
  111. data/lib/danger/request_sources/bitbucket_server.rb +210 -0
  112. data/lib/danger/request_sources/bitbucket_server_api.rb +129 -0
  113. data/lib/danger/request_sources/code_insights_api.rb +142 -0
  114. data/lib/danger/request_sources/github/github.rb +535 -0
  115. data/lib/danger/request_sources/github/github_review.rb +127 -0
  116. data/lib/danger/request_sources/github/github_review_resolver.rb +17 -0
  117. data/lib/danger/request_sources/github/github_review_unsupported.rb +23 -0
  118. data/lib/danger/request_sources/gitlab.rb +557 -0
  119. data/lib/danger/request_sources/local_only.rb +50 -0
  120. data/lib/danger/request_sources/request_source.rb +97 -0
  121. data/lib/danger/request_sources/support/get_ignored_violation.rb +17 -0
  122. data/lib/danger/request_sources/vsts.rb +278 -0
  123. data/lib/danger/request_sources/vsts_api.rb +172 -0
  124. data/lib/danger/scm_source/git_repo.rb +198 -0
  125. data/lib/danger/version.rb +4 -0
  126. data/lib/danger.rb +45 -0
  127. metadata +351 -0
@@ -0,0 +1,32 @@
1
+ module Danger
2
+ class PrySetup
3
+ def initialize(cork)
4
+ @cork = cork
5
+ end
6
+
7
+ def setup_pry(dangerfile_path, command)
8
+ return dangerfile_path if dangerfile_path.empty?
9
+
10
+ validate_pry_available(command)
11
+ FileUtils.cp dangerfile_path, DANGERFILE_COPY
12
+ File.open(DANGERFILE_COPY, "a") do |f|
13
+ f.write("\nbinding.pry; File.delete(\"#{DANGERFILE_COPY}\")")
14
+ end
15
+ DANGERFILE_COPY
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :cork
21
+
22
+ DANGERFILE_COPY = "_Dangerfile.tmp".freeze
23
+
24
+ def validate_pry_available(command)
25
+ Kernel.require "pry"
26
+ rescue LoadError
27
+ cork.warn "Pry was not found, and is required for 'danger #{command} --pry'."
28
+ cork.print_warnings
29
+ abort
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,44 @@
1
+ require "danger/plugin_support/plugin_parser"
2
+ require "danger/plugin_support/plugin_file_resolver"
3
+
4
+ module Danger
5
+ class PluginJSON < CLAide::Command::Plugins
6
+ self.summary = "Lint plugins from files, gems or the current folder. Outputs JSON array representation of Plugins on success."
7
+ self.command = "json"
8
+
9
+ attr_accessor :cork
10
+
11
+ def initialize(argv)
12
+ @refs = argv.arguments! unless argv.arguments.empty?
13
+ @cork = Cork::Board.new(silent: argv.option("silent", false),
14
+ verbose: argv.option("verbose", false))
15
+ super
16
+ end
17
+
18
+ self.description = <<-DESC
19
+ Converts a collection of file paths of Danger plugins into a JSON format.
20
+ DESC
21
+
22
+ self.arguments = [
23
+ CLAide::Argument.new("Paths, Gems or Nothing", false, true)
24
+ ]
25
+
26
+ def run
27
+ file_resolver = PluginFileResolver.new(@refs)
28
+ data = file_resolver.resolve
29
+
30
+ parser = PluginParser.new(data[:paths])
31
+ parser.parse
32
+ json = parser.to_json
33
+
34
+ # Append gem metadata into every plugin
35
+ data[:gems].each do |gem_data|
36
+ json.each do |plugin|
37
+ plugin[:gem_metadata] = gem_data if plugin[:gem] == gem_data[:gem]
38
+ end
39
+ end
40
+
41
+ cork.puts json.to_json
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,52 @@
1
+ require "danger/plugin_support/plugin_parser"
2
+ require "danger/plugin_support/plugin_file_resolver"
3
+ require "danger/plugin_support/plugin_linter"
4
+
5
+ module Danger
6
+ class PluginLint < CLAide::Command::Plugins
7
+ self.summary = "Lints a plugin"
8
+ self.command = "lint"
9
+
10
+ attr_accessor :cork
11
+
12
+ def initialize(argv)
13
+ @warnings_as_errors = argv.flag?("warnings-as-errors", false)
14
+ @refs = argv.arguments! unless argv.arguments.empty?
15
+ @cork = Cork::Board.new(silent: argv.option("silent", false),
16
+ verbose: argv.option("verbose", false))
17
+ super
18
+ end
19
+
20
+ self.description = <<-DESC
21
+ Converts a collection of file paths of Danger plugins into a JSON format.
22
+ Note: Before 1.0, it will also parse the represented JSON to validate whether https://danger.systems would
23
+ show the plugin on the website.
24
+ DESC
25
+
26
+ self.arguments = [
27
+ CLAide::Argument.new("Paths, Gems or Nothing", false, true)
28
+ ]
29
+
30
+ def self.options
31
+ [
32
+ ["--warnings-as-errors", "Ensure strict linting."]
33
+ ].concat(super)
34
+ end
35
+
36
+ def run
37
+ file_resolver = PluginFileResolver.new(@refs)
38
+ data = file_resolver.resolve
39
+
40
+ parser = PluginParser.new(data[:paths], verbose: true)
41
+ parser.parse
42
+ json = parser.to_json
43
+
44
+ linter = PluginLinter.new(json)
45
+ linter.lint
46
+ linter.print_summary(cork)
47
+
48
+ abort("Failing due to errors\n".red) if linter.failed?
49
+ abort("Failing due to warnings as errors\n".red) if @warnings_as_errors && !linter.warnings.empty?
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,42 @@
1
+ require "danger/plugin_support/plugin_parser"
2
+ require "danger/plugin_support/plugin_file_resolver"
3
+ require "json"
4
+ require "erb"
5
+
6
+ module Danger
7
+ class PluginReadme < CLAide::Command::Plugins
8
+ self.summary = "Generates a README from a set of plugins"
9
+ self.command = "readme"
10
+
11
+ attr_accessor :cork, :json, :markdown
12
+
13
+ def initialize(argv)
14
+ @refs = argv.arguments! unless argv.arguments.empty?
15
+ @cork = Cork::Board.new(silent: argv.option("silent", false),
16
+ verbose: argv.option("verbose", false))
17
+ super
18
+ end
19
+
20
+ self.description = <<-DESC
21
+ Converts a collection of file paths of Danger plugins into a format usable in a README.
22
+ This is useful for Danger itself, but also for any plugins wanting to showcase their API.
23
+ DESC
24
+
25
+ self.arguments = [
26
+ CLAide::Argument.new("Paths, Gems or Nothing", false, true)
27
+ ]
28
+
29
+ def run
30
+ file_resolver = PluginFileResolver.new(@refs)
31
+ data = file_resolver.resolve
32
+
33
+ parser = PluginParser.new(data[:paths])
34
+ parser.parse
35
+
36
+ self.json = JSON.parse(parser.to_json_string)
37
+
38
+ template = File.join(Danger.gem_path, "lib/danger/plugin_support/templates/readme_table.html.erb")
39
+ cork.puts ERB.new(File.read(template), trim_mode: "-").result(binding)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,93 @@
1
+ require "danger/commands/local_helpers/http_cache"
2
+ require "danger/commands/local_helpers/pry_setup"
3
+ require "faraday/http_cache"
4
+ require "fileutils"
5
+ require "octokit"
6
+ require "tmpdir"
7
+ require "no_proxy_fix"
8
+
9
+ module Danger
10
+ class PR < Runner
11
+ self.summary = "Run the Dangerfile locally against Pull Requests (works with forks, too). Does not post to the PR. Usage: danger pr <URL>".freeze
12
+ self.command = "pr".freeze
13
+
14
+ def self.options
15
+ [
16
+ ["--clear-http-cache", "Clear the local http cache before running Danger locally."],
17
+ ["--pry", "Drop into a Pry shell after evaluating the Dangerfile."],
18
+ ["--dangerfile=<path/to/dangerfile>", "The location of your Dangerfile"],
19
+ ["--verify-ssl", "Verify SSL in Octokit"]
20
+ ]
21
+ end
22
+
23
+ def initialize(argv)
24
+ show_help = true if argv.arguments == ["-h"]
25
+
26
+ @pr_url = argv.shift_argument
27
+ @clear_http_cache = argv.flag?("clear-http-cache", false)
28
+ dangerfile = argv.option("dangerfile", "Dangerfile")
29
+ @verify_ssl = argv.flag?("verify-ssl", true)
30
+
31
+ # Currently CLAide doesn't support short option like -h https://github.com/CocoaPods/CLAide/pull/60
32
+ # when user pass in -h, mimic the behavior of passing in --help.
33
+ argv = CLAide::ARGV.new ["--help"] if show_help
34
+
35
+ super
36
+
37
+ @dangerfile_path = dangerfile if File.exist?(dangerfile)
38
+
39
+ if argv.flag?("pry", false)
40
+ @dangerfile_path = PrySetup.new(cork).setup_pry(@dangerfile_path, PR.command)
41
+ end
42
+ end
43
+
44
+ def validate!
45
+ super
46
+ unless @dangerfile_path
47
+ help! "Could not find a Dangerfile."
48
+ end
49
+ unless @pr_url
50
+ help! "Could not find a pull-request. Usage: danger pr <URL>"
51
+ end
52
+ end
53
+
54
+ def run
55
+ ENV["DANGER_USE_LOCAL_GIT"] = "YES"
56
+ ENV["LOCAL_GIT_PR_URL"] = @pr_url if @pr_url
57
+
58
+ configure_octokit(ENV["DANGER_TMPDIR"] || Dir.tmpdir)
59
+
60
+ env = EnvironmentManager.new(ENV, cork)
61
+ dm = Dangerfile.new(env, cork)
62
+
63
+ LocalSetup.new(dm, cork).setup(verbose: verbose) do
64
+ dm.run(
65
+ Danger::EnvironmentManager.danger_base_branch,
66
+ Danger::EnvironmentManager.danger_head_branch,
67
+ @dangerfile_path,
68
+ nil,
69
+ nil,
70
+ nil,
71
+ false
72
+ )
73
+ end
74
+ end
75
+
76
+ private
77
+
78
+ def configure_octokit(cache_dir)
79
+ # setup caching for Github calls to hitting the API rate limit too quickly
80
+ cache_file = File.join(cache_dir, "danger_local_cache")
81
+ cache = HTTPCache.new(cache_file, clear_cache: @clear_http_cache)
82
+ Octokit.configure do |config|
83
+ config.connection_options[:ssl] = { verify: @verify_ssl }
84
+ end
85
+ Octokit.middleware = Faraday::RackBuilder.new do |builder|
86
+ builder.use Faraday::HttpCache, store: cache, serializer: Marshal, shared_cache: false
87
+ builder.use Octokit::Middleware::FollowRedirects
88
+ builder.use Octokit::Response::RaiseError
89
+ builder.adapter Faraday.default_adapter
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,94 @@
1
+ module Danger
2
+ class Runner < CLAide::Command
3
+ require "danger/commands/init"
4
+ require "danger/commands/local"
5
+ require "danger/commands/dry_run"
6
+ require "danger/commands/staging"
7
+ require "danger/commands/systems"
8
+ require "danger/commands/pr"
9
+
10
+ # manually set claide plugins as a subcommand
11
+ require "claide_plugin"
12
+ @subcommands << CLAide::Command::Plugins
13
+ CLAide::Plugins.config =
14
+ CLAide::Plugins::Configuration.new(
15
+ "Danger",
16
+ "danger",
17
+ "https://gitlab.com/danger-systems/danger.systems/raw/master/plugins-search-generated.json",
18
+ "https://github.com/danger/danger-plugin-template"
19
+ )
20
+
21
+ require "danger/commands/plugins/plugin_lint"
22
+ require "danger/commands/plugins/plugin_json"
23
+ require "danger/commands/plugins/plugin_readme"
24
+
25
+ require "danger/commands/dangerfile/init"
26
+ require "danger/commands/dangerfile/gem"
27
+
28
+ attr_accessor :cork
29
+
30
+ self.summary = "Run the Dangerfile."
31
+ self.command = "danger"
32
+ self.version = Danger::VERSION
33
+
34
+ self.plugin_prefixes = %w(claide danger)
35
+
36
+ def initialize(argv)
37
+ dangerfile = argv.option("dangerfile", "Dangerfile")
38
+ @dangerfile_path = dangerfile if File.exist?(dangerfile)
39
+ @base = argv.option("base")
40
+ @head = argv.option("head")
41
+ @fail_on_errors = argv.option("fail-on-errors", false)
42
+ @fail_if_no_pr = argv.option("fail-if-no-pr", false)
43
+ @new_comment = argv.flag?("new-comment")
44
+ @remove_previous_comments = argv.flag?("remove-previous-comments")
45
+ @danger_id = argv.option("danger_id", "danger")
46
+ @cork = Cork::Board.new(silent: argv.option("silent", false),
47
+ verbose: argv.option("verbose", false))
48
+ adjust_colored2_output(argv)
49
+ super
50
+ end
51
+
52
+ def validate!
53
+ super
54
+ if self.instance_of?(Runner) && !@dangerfile_path
55
+ help!("Could not find a Dangerfile.")
56
+ end
57
+ end
58
+
59
+ def self.options
60
+ [
61
+ ["--base=[master|dev|stable]", "A branch/tag/commit to use as the base of the diff"],
62
+ ["--head=[master|dev|stable]", "A branch/tag/commit to use as the head"],
63
+ ["--fail-on-errors=<true|false>", "Should always fail the build process, defaults to false"],
64
+ ["--fail-if-no-pr=<true|false>", "Should fail the build process if no PR is found (useful for CircleCI), defaults to false"],
65
+ ["--dangerfile=<path/to/dangerfile>", "The location of your Dangerfile"],
66
+ ["--danger_id=<id>", "The identifier of this Danger instance"],
67
+ ["--new-comment", "Makes Danger post a new comment instead of editing its previous one"],
68
+ ["--remove-previous-comments", "Removes all previous comment and create a new one in the end of the list"]
69
+ ].concat(super)
70
+ end
71
+
72
+ def run
73
+ Executor.new(ENV).run(
74
+ base: @base,
75
+ head: @head,
76
+ dangerfile_path: @dangerfile_path,
77
+ danger_id: @danger_id,
78
+ new_comment: @new_comment,
79
+ fail_on_errors: @fail_on_errors,
80
+ fail_if_no_pr: @fail_if_no_pr,
81
+ remove_previous_comments: @remove_previous_comments
82
+ )
83
+ end
84
+
85
+ private
86
+
87
+ def adjust_colored2_output(argv)
88
+ # disable/enable colored2 output
89
+ # consider it execution wide to avoid need to wrap #run and maintain state
90
+ # ARGV#options is non-destructive way to check flags
91
+ Colored2.public_send(argv.options.fetch("ansi", true) ? "enable!" : "disable!")
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,53 @@
1
+ require "danger/commands/local_helpers/pry_setup"
2
+ require "fileutils"
3
+ require "tmpdir"
4
+
5
+ module Danger
6
+ class Staging < Runner
7
+ self.summary = "Run the Dangerfile locally against local master"
8
+ self.command = "staging"
9
+
10
+ def self.options
11
+ [
12
+ ["--pry", "Drop into a Pry shell after evaluating the Dangerfile."]
13
+ ]
14
+ end
15
+
16
+ def initialize(argv)
17
+ show_help = true if argv.arguments == ["-h"]
18
+
19
+ # Currently CLAide doesn't support short option like -h https://github.com/CocoaPods/CLAide/pull/60
20
+ # when user pass in -h, mimic the behavior of passing in --help.
21
+ argv = CLAide::ARGV.new ["--help"] if show_help
22
+
23
+ super
24
+
25
+ if argv.flag?("pry", false)
26
+ @dangerfile_path = PrySetup.new(cork).setup_pry(@dangerfile_path, Staging.command)
27
+ end
28
+ end
29
+
30
+ def validate!
31
+ super
32
+ unless @dangerfile_path
33
+ help! "Could not find a Dangerfile."
34
+ end
35
+ end
36
+
37
+ def run
38
+ ENV["DANGER_USE_LOCAL_ONLY_GIT"] = "YES"
39
+
40
+ env = EnvironmentManager.new(ENV, cork)
41
+ dm = Dangerfile.new(env, cork)
42
+
43
+ dm.run(
44
+ Danger::EnvironmentManager.danger_base_branch,
45
+ Danger::EnvironmentManager.danger_head_branch,
46
+ @dangerfile_path,
47
+ nil,
48
+ nil,
49
+ nil
50
+ )
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,41 @@
1
+ module Danger
2
+ class Systems < Runner
3
+ self.abstract_command = true
4
+ self.description = "For commands related to passing information from Danger to Danger.Systems."
5
+ self.summary = "Create data for Danger.Systems."
6
+ end
7
+
8
+ class CIDocs < Systems
9
+ self.command = "ci_docs"
10
+ self.summary = "Outputs the up-to-date CI documentation for Danger."
11
+
12
+ def run
13
+ here = File.dirname(__FILE__)
14
+ ci_source_paths = Dir.glob(here + "/../ci_source/*.rb")
15
+
16
+ require "yard"
17
+ # Pull out all the Danger::CI subclasses docs
18
+ registry = YARD::Registry.load(ci_source_paths, true)
19
+ ci_sources = registry.all(:class)
20
+ .select { |klass| klass.inheritance_tree.map(&:name).include? :CI }
21
+ .reject { |source| source.name == :CI }
22
+ .reject { |source| source.name == :LocalGitRepo }
23
+
24
+ # Fail if anything is added and not documented
25
+ cis_without_docs = ci_sources.select { |source| source.base_docstring.empty? }
26
+ unless cis_without_docs.empty?
27
+ cork.puts "Please add docs to: #{cis_without_docs.map(&:name).join(', ')}"
28
+ abort("Failed.".red)
29
+ end
30
+
31
+ # Output a JSON array of name and details
32
+ require "json"
33
+ cork.puts ci_sources.map { |ci|
34
+ {
35
+ name: ci.name,
36
+ docs: ci.docstring
37
+ }
38
+ }.to_json
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,20 @@
1
+ <%- @tables.each do |table| -%>
2
+ <%- if table[:content].any? || table[:resolved].any? -%>
3
+ | | <%= table[:count] %> <%= table[:name] %><%= "s" unless table[:count] == 1 %> |
4
+ |---|---|
5
+ <%- table[:content].each do |violation| -%>
6
+ | <%= @emoji_mapper.map(table[:emoji]) %> | <%= violation.message %> |
7
+ <%- end -%>
8
+ <%- table[:resolved].each do |message| -%>
9
+ | @emoji_mapper.map("white_check_mark") | <%= message %> |
10
+ <%- end -%>
11
+
12
+ <%- end -%>
13
+ <%- end -%>
14
+
15
+ <%- @markdowns.each do |current| -%>
16
+ <%= current %>
17
+ <%# the previous line has to be aligned far to the left, otherwise markdown can break easily %>
18
+ <%- end -%>
19
+
20
+ Generated by :no_entry_sign: [Danger](https://danger.systems/ "generated_by_<%= @danger_id %>")
@@ -0,0 +1,15 @@
1
+ <%- @tables.each do |table| -%>
2
+ <%- table[:content].each do |violation| -%>
3
+ <%= @emoji_mapper.map(table[:emoji]) if table[:emoji] %> <%= violation.message %>
4
+ <%- end -%>
5
+ <%- table[:resolved] && table[:resolved].each do |message| -%>
6
+ <%= @emoji_mapper.map("white_check_mark") %> <%= message %>
7
+ <%- end -%>
8
+ <%- end -%>
9
+
10
+ <%- @markdowns.each do |current| -%>
11
+ <%= current %>
12
+ <%# the previous line has to be aligned far to the left, otherwise markdown can break easily %>
13
+ <%- end -%>
14
+
15
+ Generated by :no_entry_sign: [Danger](https://danger.systems/ "generated_by_<%= @danger_id %>")
@@ -0,0 +1,12 @@
1
+ <%- @message_group.messages.each do |message| -%>
2
+ <%- next if message.type == :markdown -%>
3
+ <%= @emoji_mapper.from_type(message.type) -%> <%= message.message %>
4
+
5
+ <%- end -%>
6
+ <%- @resolved.each do |message| -%>
7
+ <%= @emoji_mapper.map("white_check_mark") %> <%= message %>
8
+ <%- end -%>
9
+
10
+ <%= @message_group.markdowns.map(&:message).join("\n\n") %>
11
+
12
+ Generated by :no_entry_sign: [Danger](https://danger.systems/ "generated_by_<%= @danger_id %>")
@@ -0,0 +1,55 @@
1
+ <!--
2
+ <%- @tables.each do |table| -%>
3
+ <%= pluralize(table[:name], table[:count]) %><%= ": #{truncate(table[:content].first.message)}" if table[:count] > 0 %>
4
+ <%- end -%>
5
+ <%= pluralize("Markdown", @markdowns.size) %>
6
+ -->
7
+ <%- @tables.each do |table| -%>
8
+ <%- if table[:content].any? || table[:resolved].any? -%>
9
+ <table>
10
+ <thead>
11
+ <tr>
12
+ <th width="50"></th>
13
+ <th width="100%" data-danger-table="true" data-kind="<%= table[:name] %>">
14
+ <%- if table[:count] > 0 -%>
15
+ <%= pluralize(table[:name], table[:count]) %>
16
+ <%- else -%>
17
+ :white_check_mark: <%= random_compliment %>
18
+ <%- end -%>
19
+ </th>
20
+ </tr>
21
+ </thead>
22
+ <tbody>
23
+ <%- max_num_violations = FindMaxNumViolations.new(table[:content]).call -%>
24
+ <%- table[:content].take(max_num_violations).each do |violation| -%>
25
+ <tr>
26
+ <td>:<%= table[:emoji] %>:</td>
27
+ <td data-sticky="<%= violation.sticky %>"><%= violation.message %></td>
28
+ </tr>
29
+ <%- end -%>
30
+ <%- if table[:content].length > max_num_violations -%>
31
+ <tr>
32
+ <td>:warning:</td>
33
+ <td>
34
+ Danger found <%= table[:content].length %> violations with this PR. Due to GitHub's max issue comment size, the number shown has been truncated to <%= max_num_violations %>.
35
+ </td>
36
+ </tr>
37
+ <%- end -%>
38
+ <%- table[:resolved].each do |message| -%>
39
+ <tr>
40
+ <td>:white_check_mark:</td>
41
+ <td data-sticky="true"><del><%= message %></del></td>
42
+ </tr>
43
+ <%- end -%>
44
+ </tbody>
45
+ </table>
46
+ <%- end -%>
47
+ <%- end -%>
48
+
49
+ <%- @markdowns.each do |current| -%>
50
+ <%= current %>
51
+ <%# the previous line has to be aligned far to the left, otherwise markdown can break easily %>
52
+ <%- end -%>
53
+ <p align="right" data-meta="generated_by_<%= @danger_id %>">
54
+ Generated by :no_entry_sign: <a href="https://danger.systems/">Danger</a>
55
+ </p>
@@ -0,0 +1,26 @@
1
+ <%- @tables.each do |table| -%>
2
+ <%- if table[:content].any? -%>
3
+ <table data-meta="generated_by_<%= @danger_id %>">
4
+ <tbody>
5
+ <%- table[:content].each do |violation| -%>
6
+ <tr>
7
+ <td>:<%= table[:emoji] %>:</td>
8
+ <td width="100%" data-sticky="<%= violation.sticky %>"><%= "<del>" if table[:resolved] %><%= violation.message %><%= "</del>" if table[:resolved] %></td>
9
+ </tr>
10
+ <%- end -%>
11
+ </tbody>
12
+ </table>
13
+ <%- end -%>
14
+ <%- end -%>
15
+
16
+ <%- @markdowns.each do |current| -%>
17
+ <%= current %>
18
+ <%# the previous line has to be aligned far to the left, otherwise markdown can break easily %>
19
+ <%- end -%>
20
+ <%# We need to add the generated_by_ to identify comments from danger. But with inlines %>
21
+ <%# it might be a little annoying, so we set on the table, but if we have markdown we add the footer anyway %>
22
+ <%- if @markdowns.count > 0 -%>
23
+ <p align="right" data-meta="generated_by_<%= @danger_id %>">
24
+ Generated by :no_entry_sign: <a href="http://danger.systems/">Danger</a>
25
+ </p>
26
+ <%- end -%>
@@ -0,0 +1,40 @@
1
+ <%- @tables.each do |table| -%>
2
+ <%- if table[:content].any? || table[:resolved].any? -%>
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th width="5%"></th>
7
+ <th width="95%" data-danger-table="true" data-kind="<%= table[:name] %>">
8
+ <%- if table[:count] > 0 -%>
9
+ <%= table[:count] %> <%= table[:name] %><%= "s" unless table[:count] == 1 %>
10
+ <%- else -%>
11
+ :white_check_mark: <%= random_compliment %>
12
+ <%- end -%>
13
+ </th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <%- table[:content].each do |violation| -%>
18
+ <tr>
19
+ <td>:<%= table[:emoji] %>:</td>
20
+ <td data-sticky="<%= violation.sticky %>"><%= violation.message %></td>
21
+ </tr>
22
+ <%- end -%>
23
+ <%- table[:resolved].each do |message| -%>
24
+ <tr>
25
+ <td>:white_check_mark:</td>
26
+ <td data-sticky="true"><del><%= message %></del></td>
27
+ </tr>
28
+ <%- end -%>
29
+ </tbody>
30
+ </table>
31
+ <%- end -%>
32
+ <%- end -%>
33
+
34
+ <%- @markdowns.each do |current| -%>
35
+ <%= current %>
36
+ <%# the previous line has to be aligned far to the left, otherwise markdown can break easily %>
37
+ <%- end -%>
38
+ <p align="right" data-meta="generated_by_<%= @danger_id %>">
39
+ Generated by :no_entry_sign: <a href="https://github.com/danger/danger/">Danger</a>
40
+ </p>
@@ -0,0 +1,21 @@
1
+ <%- @tables.each do |table| -%>
2
+ <%- if table[:content].any? -%>
3
+ <table data-meta="generated_by_<%= @danger_id %>">
4
+ <tbody>
5
+ <%- table[:content].each do |violation| -%>
6
+ <tr>
7
+ <td>:<%= table[:emoji] %>:</td>
8
+ <td width="100%" data-sticky="<%= violation.sticky %>"><%= "<del>" if table[:resolved] %><%= violation.message %><%= "</del>" if table[:resolved] %></td>
9
+ </tr>
10
+ <%- end -%>
11
+ </tbody>
12
+ </table>
13
+ <%- end -%>
14
+ <%- end -%>
15
+
16
+ <%- @markdowns.each do |current| -%>
17
+ <%= current %>
18
+ <%# the previous line has to be aligned far to the left, otherwise markdown can break easily %>
19
+ <%- end -%>
20
+ <%# Add the generated_by_ as a html comment to identify comments from danger. %>
21
+ <!-- "generated_by_<%= @danger_id %>" -->
@@ -0,0 +1,20 @@
1
+ <%- @tables.each do |table| -%>
2
+ <%- if table[:content].any? || table[:resolved].any? -%>
3
+ | | <%= table[:count] %> <%= table[:name] %><%= "s" unless table[:count] == 1 %> |
4
+ |---|---|
5
+ <%- table[:content].each do |violation| -%>
6
+ | <%= @emoji_mapper.map(table[:emoji]) %> | <%= violation.message %> |
7
+ <%- end -%>
8
+ <%- table[:resolved].each do |message| -%>
9
+ | @emoji_mapper.map("white_check_mark") | <%= message %> |
10
+ <%- end -%>
11
+
12
+ <%- end -%>
13
+ <%- end -%>
14
+
15
+ <%- @markdowns.each do |current| -%>
16
+ <%= current %>
17
+ <%# the previous line has to be aligned far to the left, otherwise markdown can break easily %>
18
+ <%- end -%>
19
+
20
+ Generated by :no_entry_sign: [Danger](https://danger.systems/ "generated_by_<%= @danger_id %>")