danger 5.5.13 → 5.6.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9973389d96fb5038948aadcc696a845877b934df
|
4
|
+
data.tar.gz: 23a75796bf999b53a9fb9cd75ab76cb0a22168b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c5986ae5c49a22d58f641e70c28db3705a38aa8c63ce8cf0cbccca87098bce89c2546144ef5431cf356f5ff5054a9cea5c91893c52767b816607e4885f95689
|
7
|
+
data.tar.gz: fe1764de97f55c1cd740bbdac32517795835de5bc19265b2eb18e58c37d215cd133bee754e2aee55afa8e0f0c3dfe6a26e6212d134f40423e4d21f72aff7dc1d
|
@@ -6,29 +6,36 @@ require "danger/request_sources/github/github"
|
|
6
6
|
module Danger
|
7
7
|
# ### CI Setup
|
8
8
|
#
|
9
|
-
# For setting up
|
10
|
-
# it
|
11
|
-
# isn't reliable.
|
9
|
+
# For setting up CircleCI, we recommend turning on "Only build pull requests" in "Advanced Settings." Without this enabled,
|
10
|
+
# it's trickier for Danger to determine whether you're in a pull request or not, as the environment metadata
|
11
|
+
# isn't as reliable.
|
12
12
|
#
|
13
|
-
#
|
14
|
-
#
|
13
|
+
# A common scenario is when CircleCI begins building a commit before the commit becomes associated with a PR
|
14
|
+
# (e.g. a developer pushes their branch to the remote repo for the first time. CircleCI spins up and begins building.
|
15
|
+
# Moments later the developer creates a PR on GitHub. Since the build process started before the PR existed,
|
16
|
+
# Danger won't be able to use the Circle-provided environment variables to retrieve PR metadata.)
|
15
17
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
18
|
+
# With "Only build pull requests" enabled, you can add `bundle exec danger` to your `config.yml` (Circle 2.0).
|
19
|
+
#
|
20
|
+
# e.g.
|
21
|
+
#
|
22
|
+
# ``` yaml
|
23
|
+
# - run: bundle exec danger --verbose
|
20
24
|
# ```
|
21
25
|
#
|
26
|
+
# And that should be it!
|
27
|
+
#
|
22
28
|
# ### Token Setup
|
23
29
|
#
|
24
|
-
#
|
30
|
+
# If "Only build pull requests" can't be enabled for your project, Danger _can_ still work by relying on CircleCI's API
|
31
|
+
# to retrieve PR metadata, which will require an API token.
|
32
|
+
#
|
33
|
+
# 1. Go to your project > Settings > API Permissions. Create a token with scope "view-builds" and a label like "DANGER_CIRCLE_CI_API_TOKEN".
|
34
|
+
# 2. Settings > Environement Variables. Add the token as a CircleCI environment variable, which exposes it to the Danger process.
|
25
35
|
#
|
26
|
-
#
|
36
|
+
# There is no difference here for OSS vs Closed, both scenarios will need this environment variable.
|
27
37
|
#
|
28
|
-
#
|
29
|
-
# the status of whether a commit is inside a PR or not. You can generate a token from inside the project set_trace_func
|
30
|
-
# then go to Permissions > "API Permissions" and generate a token with access to Status. Take that token and add
|
31
|
-
# it to Build Settings > "Environment Variables".
|
38
|
+
# With these pieces in place, Danger should be able to work as expected.
|
32
39
|
#
|
33
40
|
class CircleCI < CI
|
34
41
|
# Side note: CircleCI is complicated. The env vars for PRs are not guaranteed to exist
|
@@ -45,7 +52,7 @@ module Danger
|
|
45
52
|
return true if env["CIRCLE_PULL_REQUEST"] && !env["CIRCLE_PULL_REQUEST"].empty?
|
46
53
|
|
47
54
|
# Real-world talk, it should be worrying if none of these are in the environment
|
48
|
-
return false unless ["
|
55
|
+
return false unless ["DANGER_CIRCLE_CI_API_TOKEN", "CIRCLE_PROJECT_USERNAME", "CIRCLE_PROJECT_REPONAME", "CIRCLE_BUILD_NUM"].all? { |x| env[x] && !env[x].empty? }
|
49
56
|
|
50
57
|
# Uses the Circle API to determine if it's a PR otherwise
|
51
58
|
api = CircleAPI.new
|
@@ -16,7 +16,7 @@ module Danger
|
|
16
16
|
|
17
17
|
if url.nil? && !env["CIRCLE_PROJECT_USERNAME"].nil? && !env["CIRCLE_PROJECT_REPONAME"].nil?
|
18
18
|
repo_slug = env["CIRCLE_PROJECT_USERNAME"] + "/" + env["CIRCLE_PROJECT_REPONAME"]
|
19
|
-
token = env["DANGER_CIRCLE_CI_API_TOKEN"]
|
19
|
+
token = env["DANGER_CIRCLE_CI_API_TOKEN"]
|
20
20
|
url = fetch_pull_request_url(repo_slug, env["CIRCLE_BUILD_NUM"], token)
|
21
21
|
end
|
22
22
|
url
|
@@ -29,7 +29,9 @@ module Danger
|
|
29
29
|
# Ask the API if the commit is inside a PR
|
30
30
|
def fetch_pull_request_url(repo_slug, build_number, token)
|
31
31
|
build_json = fetch_build(repo_slug, build_number, token)
|
32
|
-
build_json[:
|
32
|
+
pull_requests = build_json[:pull_requests]
|
33
|
+
return nil unless pull_requests.first
|
34
|
+
pull_requests.first[:url]
|
33
35
|
end
|
34
36
|
|
35
37
|
# Make the API call, and parse the JSON
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# http://screwdriver.cd
|
2
|
+
# https://docs.screwdriver.cd/user-guide/environment-variables
|
3
|
+
require "danger/request_sources/github/github"
|
4
|
+
|
5
|
+
module Danger
|
6
|
+
# ### CI Setup
|
7
|
+
#
|
8
|
+
# Install dependencies and add a danger step to your screwdriver.yaml:
|
9
|
+
# ``` yml
|
10
|
+
# jobs:
|
11
|
+
# danger:
|
12
|
+
# requires: [~pr, ~commit]
|
13
|
+
# steps:
|
14
|
+
# - setup: bundle install --path vendor
|
15
|
+
# - danger: bundle exec danger
|
16
|
+
# secrets:
|
17
|
+
# - DANGER_GITHUB_API_TOKEN
|
18
|
+
# ```
|
19
|
+
#
|
20
|
+
# ### Token Setup
|
21
|
+
#
|
22
|
+
# Add the `DANGER_GITHUB_API_TOKEN` to your pipeline env as a
|
23
|
+
# [build secret](https://docs.screwdriver.cd/user-guide/configuration/secrets)
|
24
|
+
#
|
25
|
+
class Screwdriver < CI
|
26
|
+
def self.validates_as_ci?(env)
|
27
|
+
env.key? "SCREWDRIVER"
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.validates_as_pr?(env)
|
31
|
+
exists = ["SD_PULL_REQUEST", "SCM_URL"].all? { |x| env[x] && !env[x].empty? }
|
32
|
+
exists && env["SD_PULL_REQUEST"].to_i > 0
|
33
|
+
end
|
34
|
+
|
35
|
+
def supported_request_sources
|
36
|
+
@supported_request_sources ||= [Danger::RequestSources::GitHub]
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize(env)
|
40
|
+
self.repo_slug = env["SCM_URL"].split(":").last.gsub(".git", "")
|
41
|
+
self.repo_url = env["SCM_URL"]
|
42
|
+
if env["SD_PULL_REQUEST"].to_i > 0
|
43
|
+
self.pull_request_id = env["SD_PULL_REQUEST"]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -107,7 +107,7 @@ module Danger
|
|
107
107
|
# @!group Core
|
108
108
|
# Print out a generate message on the PR
|
109
109
|
#
|
110
|
-
# @param [String, Array<String> message
|
110
|
+
# @param [String, Array<String>] message
|
111
111
|
# The message to present to the user
|
112
112
|
# @param [Boolean] sticky
|
113
113
|
# Whether the message should be kept after it was fixed,
|
@@ -124,14 +124,14 @@ module Danger
|
|
124
124
|
line = options.fetch(:line, nil)
|
125
125
|
|
126
126
|
messages.flatten.each do |message|
|
127
|
-
@messages << Violation.new(message, sticky, file, line)
|
127
|
+
@messages << Violation.new(message, sticky, file, line) if message
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
131
|
# @!group Core
|
132
132
|
# Specifies a problem, but not critical
|
133
133
|
#
|
134
|
-
# @param [String, Array<String> message
|
134
|
+
# @param [String, Array<String>] message
|
135
135
|
# The message to present to the user
|
136
136
|
# @param [Boolean] sticky
|
137
137
|
# Whether the message should be kept after it was fixed,
|
@@ -149,14 +149,14 @@ module Danger
|
|
149
149
|
|
150
150
|
warnings.flatten.each do |warning|
|
151
151
|
next if should_ignore_violation(warning)
|
152
|
-
@warnings << Violation.new(warning, sticky, file, line)
|
152
|
+
@warnings << Violation.new(warning, sticky, file, line) if warning
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
156
|
# @!group Core
|
157
157
|
# Declares a CI blocking error
|
158
158
|
#
|
159
|
-
# @param [String, Array<String> message
|
159
|
+
# @param [String, Array<String>] message
|
160
160
|
# The message to present to the user
|
161
161
|
# @param [Boolean] sticky
|
162
162
|
# Whether the message should be kept after it was fixed,
|
@@ -174,7 +174,7 @@ module Danger
|
|
174
174
|
|
175
175
|
failures.flatten.each do |failure|
|
176
176
|
next if should_ignore_violation(failure)
|
177
|
-
@errors << Violation.new(failure, sticky, file, line)
|
177
|
+
@errors << Violation.new(failure, sticky, file, line) if failure
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
data/lib/danger/version.rb
CHANGED
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: 5.
|
4
|
+
version: 5.6.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: 2018-
|
12
|
+
date: 2018-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: claide
|
@@ -191,6 +191,7 @@ files:
|
|
191
191
|
- lib/danger/ci_source/gitlab_ci.rb
|
192
192
|
- lib/danger/ci_source/jenkins.rb
|
193
193
|
- lib/danger/ci_source/local_git_repo.rb
|
194
|
+
- lib/danger/ci_source/screwdriver.rb
|
194
195
|
- lib/danger/ci_source/semaphore.rb
|
195
196
|
- lib/danger/ci_source/support/commits.rb
|
196
197
|
- lib/danger/ci_source/support/find_repo_info_from_logs.rb
|
@@ -291,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
292
|
version: '0'
|
292
293
|
requirements: []
|
293
294
|
rubyforge_project:
|
294
|
-
rubygems_version: 2.
|
295
|
+
rubygems_version: 2.6.14
|
295
296
|
signing_key:
|
296
297
|
specification_version: 4
|
297
298
|
summary: Like Unit Tests, but for your Team Culture.
|