danger 9.2.0 → 9.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ad61c252b1b62b1fb4e7aa07c2ef21727ada06dcfdd66e23ce70840ab37fcff
4
- data.tar.gz: a1e98cfa27d937448822f2ece399fc157b5f30358ed675f976ccc7c20b7bfb5f
3
+ metadata.gz: 28e1b237f9fc7857aca64881f72c1c247ec9f83d0f22985866f7b7b59e407551
4
+ data.tar.gz: b1ffee7037fd3e8bfd25103557ec78f51792c1f24c46f2d5ce624b38c8582761
5
5
  SHA512:
6
- metadata.gz: f4531b7f35bccbfdc0df07dedae51b009e1a9a0bcf00d566293d28c143c1a00e29f3ef8f7e47421a6ff32e48cd8b2b640866392aab161d0e95d16d9eff6ad1b6
7
- data.tar.gz: fcce02992e6488c454ca914e4a81be0d397cbd19b9f3e63cf058c05068606376020281b552cb489b9d88bf8d0958b6a99b442093d62123a095c3d4418955a1c1
6
+ metadata.gz: 1b196a2f4f291b2a961948bb56518921285142763c8265478d6050992756fb4fef2bcc33fdbfa15187e8384a16f68b20903fd41475ab55578a3dbcd5fea60d75
7
+ data.tar.gz: 81f1adb962e7031baf701487d29e37ccd7daeb499471adbc1c663e1da8db87333c312d1c9875fa6a571acba9a429d6cae3a49fac3cf2ff4270a9c157ff4df469
@@ -0,0 +1,45 @@
1
+ require "danger/request_sources/github/github"
2
+
3
+ module Danger
4
+ # ### CI Setup
5
+ #
6
+ # Custom CI with GitHub
7
+ #
8
+ # This CI source is for custom, most likely internal, CI systems that are use GitHub as source control.
9
+ # An example could be argo-workflows or tekton hosted in your own Kubernetes cluster.
10
+ #
11
+ # The following environment variables are required:
12
+ # - `CUSTOM_CI_WITH_GITHUB` - Set to any value to indicate that this is a custom CI with GitHub
13
+ #
14
+ # ### Token Setup
15
+ #
16
+ # #### GitHub
17
+ # As you own the setup, it's up to you to add the environment variable for the `DANGER_GITHUB_API_TOKEN`.
18
+ #
19
+ class CustomCIWithGithub < CI
20
+ def self.validates_as_ci?(env)
21
+ env.key? "CUSTOM_CI_WITH_GITHUB"
22
+ end
23
+
24
+ def self.validates_as_pr?(env)
25
+ value = env["GITHUB_EVENT_NAME"]
26
+ ["pull_request", "pull_request_target"].include?(value)
27
+ end
28
+
29
+ def supported_request_sources
30
+ @supported_request_sources ||= [Danger::RequestSources::GitHub]
31
+ end
32
+
33
+ def initialize(env)
34
+ self.repo_slug = env["GITHUB_REPOSITORY"]
35
+ pull_request_event = JSON.parse(File.read(env["GITHUB_EVENT_PATH"]))
36
+ self.pull_request_id = pull_request_event["number"]
37
+ self.repo_url = pull_request_event["repository"]["clone_url"]
38
+
39
+ # if environment variable DANGER_GITHUB_API_TOKEN is not set, use env GITHUB_TOKEN
40
+ if (env.key? "CUSTOM_CI_WITH_GITHUB") && (!env.key? "DANGER_GITHUB_API_TOKEN")
41
+ env["DANGER_GITHUB_API_TOKEN"] = env["GITHUB_TOKEN"]
42
+ end
43
+ end
44
+ end
45
+ end
@@ -49,7 +49,7 @@ module Danger
49
49
 
50
50
  configure_octokit(ENV["DANGER_TMPDIR"] || Dir.tmpdir)
51
51
 
52
- env = EnvironmentManager.new(ENV, cork)
52
+ env = EnvironmentManager.new(ENV, cork, @danger_id)
53
53
  dm = Dangerfile.new(env, cork)
54
54
 
55
55
  LocalSetup.new(dm, cork).setup(verbose: verbose) do
@@ -57,7 +57,7 @@ module Danger
57
57
  Danger::EnvironmentManager.danger_base_branch,
58
58
  Danger::EnvironmentManager.danger_head_branch,
59
59
  @dangerfile_path,
60
- nil,
60
+ @danger_id,
61
61
  nil,
62
62
  nil
63
63
  )
@@ -78,15 +78,20 @@ module Danger
78
78
  messages = update_inline_comments_for_kind!(:messages, messages, danger_id: danger_id)
79
79
  markdowns = update_inline_comments_for_kind!(:markdowns, markdowns, danger_id: danger_id)
80
80
 
81
- comment += generate_comment(warnings: warnings,
82
- errors: errors,
83
- messages: messages,
84
- markdowns: markdowns,
85
- previous_violations: {},
86
- danger_id: danger_id,
87
- template: "bitbucket_server")
88
-
89
- @api.post_comment(comment)
81
+ has_comments = (warnings.count > 0 || errors.count > 0 || messages.count > 0 || markdowns.count > 0)
82
+ if has_comments
83
+ comment = generate_description(warnings: warnings,
84
+ errors: errors)
85
+ comment += "\n\n"
86
+ comment += generate_comment(warnings: warnings,
87
+ errors: errors,
88
+ messages: messages,
89
+ markdowns: markdowns,
90
+ previous_violations: {},
91
+ danger_id: danger_id,
92
+ template: "bitbucket_server")
93
+ @api.post_comment(comment)
94
+ end
90
95
  end
91
96
 
92
97
  def update_pr_by_line!(message_groups:,
@@ -1,4 +1,4 @@
1
1
  module Danger
2
- VERSION = "9.2.0".freeze
2
+ VERSION = "9.3.0".freeze
3
3
  DESCRIPTION = "Like Unit Tests, but for your Team Culture.".freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.2.0
4
+ version: 9.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Orta Therox
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-28 00:00:00.000000000 Z
12
+ date: 2023-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: claide
@@ -107,14 +107,14 @@ dependencies:
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.7'
110
+ version: 1.13.0
111
111
  type: :runtime
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.7'
117
+ version: 1.13.0
118
118
  - !ruby/object:Gem::Dependency
119
119
  name: kramdown
120
120
  requirement: !ruby/object:Gem::Requirement
@@ -223,6 +223,7 @@ files:
223
223
  - lib/danger/ci_source/codemagic.rb
224
224
  - lib/danger/ci_source/codeship.rb
225
225
  - lib/danger/ci_source/concourse.rb
226
+ - lib/danger/ci_source/custom_ci_with_github.rb
226
227
  - lib/danger/ci_source/dotci.rb
227
228
  - lib/danger/ci_source/drone.rb
228
229
  - lib/danger/ci_source/github_actions.rb
@@ -343,8 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
343
344
  - !ruby/object:Gem::Version
344
345
  version: '0'
345
346
  requirements: []
346
- rubyforge_project:
347
- rubygems_version: 2.7.6.2
347
+ rubygems_version: 3.1.6
348
348
  signing_key:
349
349
  specification_version: 4
350
350
  summary: Like Unit Tests, but for your Team Culture.