danger-additional-logging 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +93 -0
- data/bin/danger +5 -0
- data/lib/assets/DangerfileTemplate +13 -0
- data/lib/danger/ci_source/appcenter.rb +55 -0
- data/lib/danger/ci_source/appcircle.rb +83 -0
- data/lib/danger/ci_source/appveyor.rb +64 -0
- data/lib/danger/ci_source/azure_pipelines.rb +61 -0
- data/lib/danger/ci_source/bamboo.rb +41 -0
- data/lib/danger/ci_source/bitbucket_pipelines.rb +37 -0
- data/lib/danger/ci_source/bitrise.rb +78 -0
- data/lib/danger/ci_source/buddybuild.rb +62 -0
- data/lib/danger/ci_source/buildkite.rb +51 -0
- data/lib/danger/ci_source/ci_source.rb +37 -0
- data/lib/danger/ci_source/circle.rb +94 -0
- data/lib/danger/ci_source/circle_api.rb +51 -0
- data/lib/danger/ci_source/cirrus.rb +31 -0
- data/lib/danger/ci_source/code_build.rb +71 -0
- data/lib/danger/ci_source/codefresh.rb +47 -0
- data/lib/danger/ci_source/codemagic.rb +58 -0
- data/lib/danger/ci_source/codeship.rb +44 -0
- data/lib/danger/ci_source/concourse.rb +60 -0
- data/lib/danger/ci_source/custom_ci_with_github.rb +49 -0
- data/lib/danger/ci_source/dotci.rb +50 -0
- data/lib/danger/ci_source/drone.rb +71 -0
- data/lib/danger/ci_source/github_actions.rb +44 -0
- data/lib/danger/ci_source/gitlab_ci.rb +89 -0
- data/lib/danger/ci_source/jenkins.rb +148 -0
- data/lib/danger/ci_source/local_git_repo.rb +117 -0
- data/lib/danger/ci_source/local_only_git_repo.rb +44 -0
- data/lib/danger/ci_source/screwdriver.rb +48 -0
- data/lib/danger/ci_source/semaphore.rb +37 -0
- data/lib/danger/ci_source/support/commits.rb +19 -0
- data/lib/danger/ci_source/support/find_repo_info_from_logs.rb +35 -0
- data/lib/danger/ci_source/support/find_repo_info_from_url.rb +43 -0
- data/lib/danger/ci_source/support/local_pull_request.rb +14 -0
- data/lib/danger/ci_source/support/no_pull_request.rb +7 -0
- data/lib/danger/ci_source/support/no_repo_info.rb +5 -0
- data/lib/danger/ci_source/support/pull_request_finder.rb +190 -0
- data/lib/danger/ci_source/support/remote_pull_request.rb +15 -0
- data/lib/danger/ci_source/support/repo_info.rb +10 -0
- data/lib/danger/ci_source/surf.rb +37 -0
- data/lib/danger/ci_source/teamcity.rb +163 -0
- data/lib/danger/ci_source/travis.rb +51 -0
- data/lib/danger/ci_source/xcode_cloud.rb +38 -0
- data/lib/danger/ci_source/xcode_server.rb +48 -0
- data/lib/danger/clients/rubygems_client.rb +14 -0
- data/lib/danger/commands/dangerfile/gem.rb +43 -0
- data/lib/danger/commands/dangerfile/init.rb +30 -0
- data/lib/danger/commands/dry_run.rb +54 -0
- data/lib/danger/commands/init.rb +297 -0
- data/lib/danger/commands/init_helpers/interviewer.rb +92 -0
- data/lib/danger/commands/local.rb +83 -0
- data/lib/danger/commands/local_helpers/http_cache.rb +38 -0
- data/lib/danger/commands/local_helpers/local_setup.rb +48 -0
- data/lib/danger/commands/local_helpers/pry_setup.rb +32 -0
- data/lib/danger/commands/plugins/plugin_json.rb +44 -0
- data/lib/danger/commands/plugins/plugin_lint.rb +52 -0
- data/lib/danger/commands/plugins/plugin_readme.rb +42 -0
- data/lib/danger/commands/pr.rb +93 -0
- data/lib/danger/commands/runner.rb +94 -0
- data/lib/danger/commands/staging.rb +53 -0
- data/lib/danger/commands/systems.rb +41 -0
- data/lib/danger/comment_generators/bitbucket_server.md.erb +20 -0
- data/lib/danger/comment_generators/bitbucket_server_inline.md.erb +15 -0
- data/lib/danger/comment_generators/bitbucket_server_message_group.md.erb +12 -0
- data/lib/danger/comment_generators/github.md.erb +55 -0
- data/lib/danger/comment_generators/github_inline.md.erb +26 -0
- data/lib/danger/comment_generators/gitlab.md.erb +40 -0
- data/lib/danger/comment_generators/gitlab_inline.md.erb +21 -0
- data/lib/danger/comment_generators/vsts.md.erb +20 -0
- data/lib/danger/comment_generators/vsts_inline.md.erb +17 -0
- data/lib/danger/core_ext/file_list.rb +18 -0
- data/lib/danger/core_ext/string.rb +20 -0
- data/lib/danger/danger_core/dangerfile.rb +348 -0
- data/lib/danger/danger_core/dangerfile_dsl.rb +29 -0
- data/lib/danger/danger_core/dangerfile_generator.rb +11 -0
- data/lib/danger/danger_core/environment_manager.rb +126 -0
- data/lib/danger/danger_core/executor.rb +91 -0
- data/lib/danger/danger_core/message_aggregator.rb +50 -0
- data/lib/danger/danger_core/message_group.rb +68 -0
- data/lib/danger/danger_core/messages/base.rb +57 -0
- data/lib/danger/danger_core/messages/markdown.rb +41 -0
- data/lib/danger/danger_core/messages/violation.rb +53 -0
- data/lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb +142 -0
- data/lib/danger/danger_core/plugins/dangerfile_bitbucket_server_plugin.rb +211 -0
- data/lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb +274 -0
- data/lib/danger/danger_core/plugins/dangerfile_git_plugin.rb +159 -0
- data/lib/danger/danger_core/plugins/dangerfile_github_plugin.rb +264 -0
- data/lib/danger/danger_core/plugins/dangerfile_gitlab_plugin.rb +275 -0
- data/lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb +43 -0
- data/lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb +220 -0
- data/lib/danger/danger_core/plugins/dangerfile_vsts_plugin.rb +191 -0
- data/lib/danger/danger_core/standard_error.rb +142 -0
- data/lib/danger/helpers/array_subclass.rb +61 -0
- data/lib/danger/helpers/comment.rb +32 -0
- data/lib/danger/helpers/comments_helper.rb +179 -0
- data/lib/danger/helpers/comments_parsing_helper.rb +71 -0
- data/lib/danger/helpers/emoji_mapper.rb +41 -0
- data/lib/danger/helpers/find_max_num_violations.rb +31 -0
- data/lib/danger/helpers/message_groups_array_helper.rb +31 -0
- data/lib/danger/plugin_support/gems_resolver.rb +77 -0
- data/lib/danger/plugin_support/plugin.rb +52 -0
- data/lib/danger/plugin_support/plugin_file_resolver.rb +30 -0
- data/lib/danger/plugin_support/plugin_linter.rb +162 -0
- data/lib/danger/plugin_support/plugin_parser.rb +199 -0
- data/lib/danger/plugin_support/templates/readme_table.html.erb +26 -0
- data/lib/danger/request_sources/bitbucket_cloud.rb +169 -0
- data/lib/danger/request_sources/bitbucket_cloud_api.rb +181 -0
- data/lib/danger/request_sources/bitbucket_server.rb +210 -0
- data/lib/danger/request_sources/bitbucket_server_api.rb +129 -0
- data/lib/danger/request_sources/code_insights_api.rb +142 -0
- data/lib/danger/request_sources/github/github.rb +535 -0
- data/lib/danger/request_sources/github/github_review.rb +127 -0
- data/lib/danger/request_sources/github/github_review_resolver.rb +17 -0
- data/lib/danger/request_sources/github/github_review_unsupported.rb +23 -0
- data/lib/danger/request_sources/gitlab.rb +557 -0
- data/lib/danger/request_sources/local_only.rb +50 -0
- data/lib/danger/request_sources/request_source.rb +97 -0
- data/lib/danger/request_sources/support/get_ignored_violation.rb +17 -0
- data/lib/danger/request_sources/vsts.rb +278 -0
- data/lib/danger/request_sources/vsts_api.rb +172 -0
- data/lib/danger/scm_source/git_repo.rb +198 -0
- data/lib/danger/version.rb +4 -0
- data/lib/danger.rb +45 -0
- metadata +351 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: faa41cd1da98139f14497b936b93a25452d36f0c757800e18c39e8061ff3f65c
|
4
|
+
data.tar.gz: b869bd4e40904ff3b8529860c1e348ae6b3cd3a9e1f73200d6a6db705cecf46c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2d6260438eaafbcb825a37eef562c80de23f5f64d34cfbf9b26a70911def271ec48534f88cd6e438cc9d1c076c3425ab35495c136cf80e1491b640c131d44e6
|
7
|
+
data.tar.gz: 1eaf11e7af48c90f4cd0e55a98e8609001aa85daabaab73d65767d2bc42bc9cf016af539a5fc84e36df4a2687329b451c0f942efa0a93789de861574620d37e5
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015-present Orta, Felix Krause
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# Danger :no_entry_sign:
|
2
|
+
|
3
|
+
[![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/orta/danger/blob/master/LICENSE)
|
4
|
+
[![Gem](https://img.shields.io/gem/v/danger.svg?style=flat)](http://rubygems.org/gems/danger)
|
5
|
+
[![CI](https://github.com/danger/danger/actions/workflows/CI.yml/badge.svg)](https://github.com/danger/danger/actions/workflows/CI.yml)
|
6
|
+
|
7
|
+
Formalize your Pull Request etiquette.
|
8
|
+
|
9
|
+
-------
|
10
|
+
|
11
|
+
<p align="center">
|
12
|
+
<a href="#what-is-danger">What is Danger?</a> •
|
13
|
+
<a href="VISION.md">Vision</a> •
|
14
|
+
<a href="#im-here-to-help-out">Helping Out</a> •
|
15
|
+
<a href="https://danger.systems/guides/creating_your_first_plugin.html">Plugin Development</a>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
-------
|
19
|
+
|
20
|
+
## What is Danger?
|
21
|
+
|
22
|
+
Danger runs after your CI, automating your team's conventions surrounding code review.
|
23
|
+
|
24
|
+
This provides another logical step in your process, through this Danger can help lint your rote tasks in daily code review.
|
25
|
+
|
26
|
+
You can use Danger to codify your team's norms, leaving humans to think about harder problems.
|
27
|
+
|
28
|
+
## For example?
|
29
|
+
|
30
|
+
You can:
|
31
|
+
|
32
|
+
* Enforce CHANGELOGs
|
33
|
+
* Enforce links to Trello/JIRA in PR/MR bodies
|
34
|
+
* Enforce using descriptive labels
|
35
|
+
* Look out for common anti-patterns
|
36
|
+
* Highlight interesting build artifacts
|
37
|
+
* Give specific files extra focus
|
38
|
+
|
39
|
+
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.
|
40
|
+
|
41
|
+
## Getting Started
|
42
|
+
|
43
|
+
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.
|
44
|
+
|
45
|
+
We keep all of the end-user documentation at [https://danger.systems](https://danger.systems).
|
46
|
+
|
47
|
+
Some quick links: [Guides Index](https://danger.systems/guides.html), [DSL Reference](https://danger.systems/reference.html), [Getting Started](https://danger.systems/guides/getting_started.html) and [What does Danger Do?](https://danger.systems/guides/what_does_danger_do.html).
|
48
|
+
|
49
|
+
## I'm here to help out!
|
50
|
+
|
51
|
+
Brilliant. So, let's get you set up.
|
52
|
+
|
53
|
+
```sh
|
54
|
+
git clone https://github.com/danger/danger.git
|
55
|
+
cd danger
|
56
|
+
bundle install
|
57
|
+
bundle exec rake spec
|
58
|
+
```
|
59
|
+
|
60
|
+
This sets everything up and runs all of the tests.
|
61
|
+
|
62
|
+
#### Theory
|
63
|
+
|
64
|
+
Danger has a [VISION.md](https://github.com/danger/danger/blob/master/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](http://artsy.github.io/blog/categories/danger/), too.
|
65
|
+
|
66
|
+
#### Documentation
|
67
|
+
|
68
|
+
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.
|
69
|
+
|
70
|
+
#### Testing
|
71
|
+
|
72
|
+
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.
|
73
|
+
|
74
|
+
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.
|
75
|
+
|
76
|
+
#### Debugging
|
77
|
+
|
78
|
+
Ruby is super dynamic. One of the best ways to debug Ruby code is by using [pry](https://pry.github.io/). 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](https://danger.systems/guides/troubleshooting.html#i-want-to-be-a-danger-wizard)."
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
require 'pry'
|
82
|
+
binding.pry
|
83
|
+
```
|
84
|
+
|
85
|
+
## License, Contributor's Guidelines and Code of Conduct
|
86
|
+
|
87
|
+
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](https://twitter.com/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.
|
88
|
+
|
89
|
+
> 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.
|
90
|
+
|
91
|
+
> This project subscribes to the [Moya Contributors Guidelines](https://github.com/Moya/contributors) which TLDR: means we give out push access easily and often.
|
92
|
+
|
93
|
+
> Contributors subscribe to the [Contributor Code of Conduct](https://contributor-covenant.org/version/1/3/0/) based on the [Contributor Covenant](https://contributor-covenant.org) version 1.3.0.
|
data/bin/danger
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Sometimes it's a README fix, or something like that - which isn't relevant for
|
2
|
+
# including in a project's CHANGELOG for example
|
3
|
+
declared_trivial = github.pr_title.include? "#trivial"
|
4
|
+
|
5
|
+
# Make it more obvious that a PR is a work in progress and shouldn't be merged yet
|
6
|
+
warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"
|
7
|
+
|
8
|
+
# Warn when there is a big PR
|
9
|
+
warn("Big PR") if git.lines_of_code > 500
|
10
|
+
|
11
|
+
# Don't let testing shortcuts get into master by accident
|
12
|
+
fail("fdescribe left in tests") if `grep -r fdescribe specs/ `.length > 1
|
13
|
+
fail("fit left in tests") if `grep -r fit specs/ `.length > 1
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# https://docs.microsoft.com/en-us/appcenter/build/custom/variables/
|
2
|
+
require "uri"
|
3
|
+
require "danger/request_sources/github/github"
|
4
|
+
|
5
|
+
module Danger
|
6
|
+
# ### CI Setup
|
7
|
+
#
|
8
|
+
# Add a script step to your appcenter-post-build.sh:
|
9
|
+
#
|
10
|
+
# ```shell
|
11
|
+
# #!/usr/bin/env bash
|
12
|
+
# bundle install
|
13
|
+
# bundle exec danger
|
14
|
+
# ```
|
15
|
+
#
|
16
|
+
# ### Token Setup
|
17
|
+
#
|
18
|
+
# Add the `DANGER_GITHUB_API_TOKEN` to your environment variables.
|
19
|
+
#
|
20
|
+
class Appcenter < CI
|
21
|
+
def self.validates_as_ci?(env)
|
22
|
+
env.key? "APPCENTER_BUILD_ID"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.validates_as_pr?(env)
|
26
|
+
return env["BUILD_REASON"] == "PullRequest"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.owner_for_github(env)
|
30
|
+
URI.parse(env["BUILD_REPOSITORY_URI"]).path.split("/")[1]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.repo_identifier_for_github(env)
|
34
|
+
repo_name = env["BUILD_REPOSITORY_NAME"]
|
35
|
+
owner = owner_for_github(env)
|
36
|
+
"#{owner}/#{repo_name}"
|
37
|
+
end
|
38
|
+
|
39
|
+
# Hopefully it's a temporary workaround (same as in Codeship integration) because App Center
|
40
|
+
# doesn't expose PR's ID. There's a future request https://github.com/Microsoft/appcenter/issues/79
|
41
|
+
def self.pr_from_env(env)
|
42
|
+
Danger::RequestSources::GitHub.new(nil, env).get_pr_from_branch(repo_identifier_for_github(env), env["BUILD_SOURCEBRANCHNAME"], owner_for_github(env))
|
43
|
+
end
|
44
|
+
|
45
|
+
def supported_request_sources
|
46
|
+
@supported_request_sources ||= [Danger::RequestSources::GitHub]
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize(env)
|
50
|
+
self.pull_request_id = self.class.pr_from_env(env)
|
51
|
+
self.repo_url = env["BUILD_REPOSITORY_URI"]
|
52
|
+
self.repo_slug = self.class.repo_identifier_for_github(env)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# https://docs.appcircle.io/environment-variables/managing-variables
|
2
|
+
# https://docs.appcircle.io/build/build-profile-configuration#environment-variables-configuration
|
3
|
+
require "danger/request_sources/github/github"
|
4
|
+
require "danger/request_sources/gitlab"
|
5
|
+
module Danger
|
6
|
+
# ### CI Setup
|
7
|
+
#
|
8
|
+
# Add a Custom Script step to your workflow and set it as a bash:
|
9
|
+
#
|
10
|
+
# ```shell
|
11
|
+
# cd $AC_REPOSITORY_DIR
|
12
|
+
# bundle install
|
13
|
+
# bundle exec danger
|
14
|
+
# ```
|
15
|
+
# ### Token Setup
|
16
|
+
#
|
17
|
+
# Login to Appcircle and select your build profile. Go to your *Config* and
|
18
|
+
# choose *Environment Variables*.
|
19
|
+
# https://docs.appcircle.io/environment-variables/managing-variables
|
20
|
+
#
|
21
|
+
# #### GitHub
|
22
|
+
# Add the `DANGER_GITHUB_API_TOKEN` to your profile's ENV.
|
23
|
+
#
|
24
|
+
# #### GitLab
|
25
|
+
# Add the `DANGER_GITLAB_API_TOKEN` to your profile's ENV.
|
26
|
+
#
|
27
|
+
# #### Bitbucket Cloud
|
28
|
+
# Add the `DANGER_BITBUCKETSERVER_USERNAME`, `DANGER_BITBUCKETSERVER_PASSWORD`
|
29
|
+
# to your profile's ENV.
|
30
|
+
#
|
31
|
+
# #### Bitbucket server
|
32
|
+
# Add the `DANGER_BITBUCKETSERVER_USERNAME`, `DANGER_BITBUCKETSERVER_PASSWORD`
|
33
|
+
# and `DANGER_BITBUCKETSERVER_HOST` to your profile's ENV.
|
34
|
+
#
|
35
|
+
class Appcircle < CI
|
36
|
+
def self.validates_as_ci?(env)
|
37
|
+
env.key? "AC_APPCIRCLE"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.validates_as_pr?(env)
|
41
|
+
return false unless env.key? "AC_PULL_NUMBER"
|
42
|
+
|
43
|
+
env["AC_PULL_NUMBER"].to_i > 0
|
44
|
+
end
|
45
|
+
|
46
|
+
def supported_request_sources
|
47
|
+
@supported_request_sources ||= [
|
48
|
+
Danger::RequestSources::GitHub,
|
49
|
+
Danger::RequestSources::BitbucketCloud,
|
50
|
+
Danger::RequestSources::BitbucketServer,
|
51
|
+
Danger::RequestSources::GitLab
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize(env)
|
56
|
+
self.pull_request_id = env["AC_PULL_NUMBER"]
|
57
|
+
self.repo_url = env["AC_GIT_URL"]
|
58
|
+
self.repo_slug = repo_slug_from(self.repo_url)
|
59
|
+
end
|
60
|
+
|
61
|
+
def repo_slug_from(url)
|
62
|
+
if url =~ URI::DEFAULT_PARSER.make_regexp
|
63
|
+
# Try to parse the URL as a valid URI. This should cover the cases of http/https/ssh URLs.
|
64
|
+
begin
|
65
|
+
uri = URI.parse(url)
|
66
|
+
return uri.path.sub(%r{^(/)}, "").sub(/(.git)$/, "")
|
67
|
+
rescue URI::InvalidURIError
|
68
|
+
# In case URL could not be parsed fallback to git URL parsing.
|
69
|
+
repo_slug_asgiturl(url)
|
70
|
+
end
|
71
|
+
else
|
72
|
+
# In case URL could not be parsed fallback to git URL parsing. git@github.com:organization/repo.git
|
73
|
+
repo_slug_asgiturl(url)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def repo_slug_asgiturl(url)
|
78
|
+
matcher_url = url
|
79
|
+
repo_matches = matcher_url.match(%r{([/:])(([^/]+/)+[^/]+?)(\.git$|$)})[2]
|
80
|
+
return repo_matches unless repo_matches.nil?
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# https://www.appveyor.com/docs/build-configuration/
|
2
|
+
module Danger
|
3
|
+
# ### CI Setup
|
4
|
+
#
|
5
|
+
# Install dependencies and add a danger step to your `appveyor.yml`.
|
6
|
+
#
|
7
|
+
# ```yaml
|
8
|
+
# install:
|
9
|
+
# - cmd: >-
|
10
|
+
# set PATH=C:\Ruby25-x64\bin;%PATH%
|
11
|
+
#
|
12
|
+
# bundle install
|
13
|
+
# after_test:
|
14
|
+
# - cmd: >-
|
15
|
+
# bundle exec danger
|
16
|
+
# ```
|
17
|
+
#
|
18
|
+
# ### Token Setup
|
19
|
+
#
|
20
|
+
# For public repositories, add your plain token to environment variables in `appveyor.yml`.
|
21
|
+
# Encrypted environment variables will not be decrypted on PR builds.
|
22
|
+
# see here: https://www.appveyor.com/docs/build-configuration/#secure-variables
|
23
|
+
#
|
24
|
+
# ```yaml
|
25
|
+
# environment:
|
26
|
+
# DANGER_GITHUB_API_TOKEN: <YOUR_TOKEN_HERE>
|
27
|
+
# ```
|
28
|
+
#
|
29
|
+
# For private repositories, enter your token in `Settings>Environment>Environment variables>Add variable` and turn on `variable encryption`.
|
30
|
+
# You will see encrypted variable text in `Settings>Export YAML` so just copy to your `appveyor.yml`.
|
31
|
+
#
|
32
|
+
# ```yaml
|
33
|
+
# environment:
|
34
|
+
# DANGER_GITHUB_API_TOKEN:
|
35
|
+
# secure: <YOUR_ENCRYPTED_TOKEN_HERE>
|
36
|
+
# ```
|
37
|
+
#
|
38
|
+
class AppVeyor < CI
|
39
|
+
def self.validates_as_ci?(env)
|
40
|
+
env.key? "APPVEYOR"
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.validates_as_pr?(env)
|
44
|
+
return false unless env.key? "APPVEYOR_PULL_REQUEST_NUMBER"
|
45
|
+
|
46
|
+
env["APPVEYOR_PULL_REQUEST_NUMBER"].to_i > 0
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize(env)
|
50
|
+
self.repo_slug = env["APPVEYOR_REPO_NAME"]
|
51
|
+
self.pull_request_id = env["APPVEYOR_PULL_REQUEST_NUMBER"]
|
52
|
+
self.repo_url = GitRepo.new.origins # AppVeyor doesn't provide a repo url env variable for now
|
53
|
+
end
|
54
|
+
|
55
|
+
def supported_request_sources
|
56
|
+
@supported_request_sources ||= [
|
57
|
+
Danger::RequestSources::GitHub,
|
58
|
+
Danger::RequestSources::BitbucketCloud,
|
59
|
+
Danger::RequestSources::BitbucketServer,
|
60
|
+
Danger::RequestSources::GitLab
|
61
|
+
]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables
|
2
|
+
require "uri"
|
3
|
+
require "danger/request_sources/github/github"
|
4
|
+
require "danger/request_sources/vsts"
|
5
|
+
|
6
|
+
module Danger
|
7
|
+
# ### CI Setup
|
8
|
+
#
|
9
|
+
# Add a script step:
|
10
|
+
#
|
11
|
+
# ```shell
|
12
|
+
# #!/usr/bin/env bash
|
13
|
+
# bundle install
|
14
|
+
# bundle exec danger
|
15
|
+
# ```
|
16
|
+
#
|
17
|
+
# ### Token Setup
|
18
|
+
#
|
19
|
+
# #### GitHub
|
20
|
+
#
|
21
|
+
# You need to add the `DANGER_GITHUB_API_TOKEN` environment variable, to do this, go to your build definition's variables tab.
|
22
|
+
# #
|
23
|
+
# #### Azure Git
|
24
|
+
#
|
25
|
+
# You need to add the `DANGER_VSTS_API_TOKEN` and `DANGER_VSTS_HOST` environment variable, to do this,
|
26
|
+
# go to your build definition's variables tab. The `DANGER_VSTS_API_TOKEN` is your vsts personal access token.
|
27
|
+
# Instructions for creating a personal access token can be found [here](https://www.visualstudio.com/en-us/docs/setup-admin/team-services/use-personal-access-tokens-to-authenticate).
|
28
|
+
# For the `DANGER_VSTS_HOST` variable the suggested value is `$(System.TeamFoundationCollectionUri)$(System.TeamProject)`
|
29
|
+
# which will automatically get your vsts domain and your project name needed for the vsts api.
|
30
|
+
#
|
31
|
+
class AzurePipelines < CI
|
32
|
+
def self.validates_as_ci?(env)
|
33
|
+
has_all_variables = ["AGENT_ID", "BUILD_SOURCEBRANCH", "BUILD_REPOSITORY_URI", "BUILD_REASON", "BUILD_REPOSITORY_NAME"].all? { |x| env[x] && !env[x].empty? }
|
34
|
+
|
35
|
+
# AGENT_ID is being used by AppCenter as well, so checking here to make sure AppCenter CI doesn't get a false positive for AzurePipelines
|
36
|
+
# Anyone working with AzurePipelines could provide a better/truly unique env key to avoid checking for AppCenter
|
37
|
+
!Danger::Appcenter.validates_as_ci?(env) &&
|
38
|
+
has_all_variables
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.validates_as_pr?(env)
|
42
|
+
return env["BUILD_REASON"] == "PullRequest"
|
43
|
+
end
|
44
|
+
|
45
|
+
def supported_request_sources
|
46
|
+
@supported_request_sources ||= [
|
47
|
+
Danger::RequestSources::GitHub,
|
48
|
+
Danger::RequestSources::GitLab,
|
49
|
+
Danger::RequestSources::BitbucketServer,
|
50
|
+
Danger::RequestSources::BitbucketCloud,
|
51
|
+
Danger::RequestSources::VSTS
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize(env)
|
56
|
+
self.pull_request_id = env["SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"] || env["SYSTEM_PULLREQUEST_PULLREQUESTID"]
|
57
|
+
self.repo_url = env["BUILD_REPOSITORY_URI"]
|
58
|
+
self.repo_slug = env["BUILD_REPOSITORY_NAME"]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "set"
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
# ### CI Setup
|
5
|
+
#
|
6
|
+
# Add a Run Script task that executes `danger` (or `bundle exec danger` if you're using Bundler
|
7
|
+
# to manage your gems) as your as part of your Bamboo plan.
|
8
|
+
# The minimum supported version is Bamboo 6.9.
|
9
|
+
#
|
10
|
+
# ### Token Setup
|
11
|
+
#
|
12
|
+
# IMPORTANT: All required Bamboo environment variables will be available
|
13
|
+
# only if the plan is run as part of a pull request. This can be achieved by selecting:
|
14
|
+
# Configure plan -> Branches -> Create plan branch: "When pull request is created".
|
15
|
+
# Otherwise, `bamboo_repository_pr_key` and `bamboo_planRepository_repositoryUrl`
|
16
|
+
# will not be available.
|
17
|
+
#
|
18
|
+
class Bamboo < CI
|
19
|
+
def supported_request_sources
|
20
|
+
@supported_request_sources ||= [
|
21
|
+
Danger::RequestSources::BitbucketServer
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.validates_as_ci?(env)
|
26
|
+
env.key? "bamboo_buildKey"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.validates_as_pr?(env)
|
30
|
+
exists = ["bamboo_repository_pr_key", "bamboo_planRepository_repositoryUrl"].all? { |x| env[x] && !env[x].empty? }
|
31
|
+
exists && env["bamboo_repository_pr_key"].to_i > 0
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize(env)
|
35
|
+
self.repo_url = env["bamboo_planRepository_repositoryUrl"]
|
36
|
+
self.pull_request_id = env["bamboo_repository_pr_key"]
|
37
|
+
repo_matches = self.repo_url.match(%r{([/:])([^/]+/[^/]+?)(\.git$|$)})
|
38
|
+
self.repo_slug = repo_matches[2] unless repo_matches.nil?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Danger
|
2
|
+
# ### CI Setup
|
3
|
+
#
|
4
|
+
# Install dependencies and add a danger step to your `bitbucket-pipelines.yml`.
|
5
|
+
#
|
6
|
+
# ```yaml
|
7
|
+
# script:
|
8
|
+
# - bundle exec danger --verbose
|
9
|
+
# ```
|
10
|
+
#
|
11
|
+
# ### Token Setup
|
12
|
+
#
|
13
|
+
# Add `DANGER_BITBUCKETCLOUD_USERNAME` and `DANGER_BITBUCKETCLOUD_PASSWORD` to your pipeline repository variable
|
14
|
+
# or instead using `DANGER_BITBUCKETCLOUD_OAUTH_KEY` and `DANGER_BITBUCKETCLOUD_OAUTH_SECRET`.
|
15
|
+
#
|
16
|
+
# You can find them in Settings > Pipelines > Repository Variables
|
17
|
+
|
18
|
+
class BitbucketPipelines < CI
|
19
|
+
def self.validates_as_ci?(env)
|
20
|
+
env.key? "BITBUCKET_BUILD_NUMBER"
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.validates_as_pr?(env)
|
24
|
+
env.key? "BITBUCKET_PR_ID"
|
25
|
+
end
|
26
|
+
|
27
|
+
def supported_request_sources
|
28
|
+
@supported_request_sources ||= [Danger::RequestSources::BitbucketCloud]
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(env)
|
32
|
+
self.repo_url = env["BITBUCKET_GIT_HTTP_ORIGIN"]
|
33
|
+
self.repo_slug = "#{env['BITBUCKET_REPO_OWNER']}/#{env['BITBUCKET_REPO_SLUG']}"
|
34
|
+
self.pull_request_id = env["BITBUCKET_PR_ID"]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# http://devcenter.bitrise.io/docs/available-environment-variables
|
2
|
+
require "danger/request_sources/github/github"
|
3
|
+
require "danger/request_sources/gitlab"
|
4
|
+
|
5
|
+
module Danger
|
6
|
+
# ### CI Setup
|
7
|
+
#
|
8
|
+
# Add a script step to your workflow:
|
9
|
+
#
|
10
|
+
# ```yml
|
11
|
+
# - script@1.1.2:
|
12
|
+
# inputs:
|
13
|
+
# - content: |-
|
14
|
+
# bundle install
|
15
|
+
# bundle exec danger
|
16
|
+
# ```
|
17
|
+
#
|
18
|
+
# ### Token Setup
|
19
|
+
#
|
20
|
+
# Add the `DANGER_GITHUB_API_TOKEN` to your workflow's [Secret App Env Vars](https://blog.bitrise.io/anyone-even-prs-can-have-secrets).
|
21
|
+
#
|
22
|
+
# ### bitbucket server and bitrise
|
23
|
+
#
|
24
|
+
# Danger will read the environment variable GIT_REPOSITORY_URL to construct the Bitbucket Server API URL
|
25
|
+
# finding the project and repo slug in the GIT_REPOSITORY_URL variable. This GIT_REPOSITORY_URL variable
|
26
|
+
# comes from the App Settings tab for your Bitrise App. If you are manually setting a repo URL in the
|
27
|
+
# Git Clone Repo step, you may need to set adjust this property in the settings tab, maybe even fake it.
|
28
|
+
# The patterns used are `(%r{\.com/(.*)})` and `(%r{\.com:(.*)})` and .split(/\.git$|$/) to remove ".git" if the URL contains it.
|
29
|
+
#
|
30
|
+
class Bitrise < CI
|
31
|
+
def self.validates_as_ci?(env)
|
32
|
+
env.key? "BITRISE_IO"
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.validates_as_pr?(env)
|
36
|
+
return !env["BITRISE_PULL_REQUEST"].to_s.empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
def supported_request_sources
|
40
|
+
@supported_request_sources ||= [
|
41
|
+
Danger::RequestSources::GitHub,
|
42
|
+
Danger::RequestSources::GitLab,
|
43
|
+
Danger::RequestSources::BitbucketServer,
|
44
|
+
Danger::RequestSources::BitbucketCloud
|
45
|
+
]
|
46
|
+
end
|
47
|
+
|
48
|
+
def initialize(env)
|
49
|
+
self.pull_request_id = env["BITRISE_PULL_REQUEST"]
|
50
|
+
self.repo_url = env["GIT_REPOSITORY_URL"]
|
51
|
+
|
52
|
+
matcher_url = self.repo_url
|
53
|
+
self.repo_slug = repo_slug_from(self.repo_url)
|
54
|
+
end
|
55
|
+
|
56
|
+
def repo_slug_from(url)
|
57
|
+
if url =~ URI::DEFAULT_PARSER.make_regexp
|
58
|
+
# Try to parse the URL as a valid URI. This should cover the cases of http/https/ssh URLs.
|
59
|
+
begin
|
60
|
+
uri = URI.parse(url)
|
61
|
+
return uri.path.sub(%r{^(/)}, "").sub(/(.git)$/, "")
|
62
|
+
rescue URI::InvalidURIError
|
63
|
+
# In case URL could not be parsed fallback to git URL parsing.
|
64
|
+
repo_slug_asgiturl(url)
|
65
|
+
end
|
66
|
+
else
|
67
|
+
# In case URL could not be parsed fallback to git URL parsing. git@github.com:organization/repo.git
|
68
|
+
repo_slug_asgiturl(url)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def repo_slug_asgiturl(url)
|
73
|
+
matcher_url = url
|
74
|
+
repo_matches = matcher_url.match(%r{([/:])(([^/]+/)+[^/]+?)(\.git$|$)})[2]
|
75
|
+
return repo_matches unless repo_matches.nil?
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Danger
|
2
|
+
# ### CI Setup
|
3
|
+
#
|
4
|
+
# Read how you can setup Danger on the buddybuild blog:
|
5
|
+
# https://www.buddybuild.com/blog/using-danger-with-buddybuild/
|
6
|
+
#
|
7
|
+
# ### Token Setup
|
8
|
+
#
|
9
|
+
# Login to buddybuild and select your app. Go to your *App Settings* and
|
10
|
+
# in the *Build Settings* menu on the left, choose *Environment Variables*.
|
11
|
+
# http://docs.buddybuild.com/docs/environment-variables
|
12
|
+
#
|
13
|
+
# #### GitHub
|
14
|
+
# Add the `DANGER_GITHUB_API_TOKEN` to your build user's ENV.
|
15
|
+
#
|
16
|
+
# #### GitLab
|
17
|
+
# Add the `DANGER_GITLAB_API_TOKEN` to your build user's ENV.
|
18
|
+
#
|
19
|
+
# #### Bitbucket Cloud
|
20
|
+
# Add the `DANGER_BITBUCKETSERVER_USERNAME`, `DANGER_BITBUCKETSERVER_PASSWORD`
|
21
|
+
# to your build user's ENV.
|
22
|
+
#
|
23
|
+
# #### Bitbucket server
|
24
|
+
# Add the `DANGER_BITBUCKETSERVER_USERNAME`, `DANGER_BITBUCKETSERVER_PASSWORD`
|
25
|
+
# and `DANGER_BITBUCKETSERVER_HOST` to your build user's ENV.
|
26
|
+
#
|
27
|
+
# ### Running Danger
|
28
|
+
#
|
29
|
+
# Once the environment variables are all available, create a custom build step
|
30
|
+
# to run Danger as part of your build process:
|
31
|
+
# http://docs.buddybuild.com/docs/custom-prebuild-and-postbuild-steps
|
32
|
+
class Buddybuild < CI
|
33
|
+
#######################################################################
|
34
|
+
def self.validates_as_ci?(env)
|
35
|
+
value = env["BUDDYBUILD_BUILD_ID"]
|
36
|
+
return !value.nil? && !env["BUDDYBUILD_BUILD_ID"].empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
#######################################################################
|
40
|
+
def self.validates_as_pr?(env)
|
41
|
+
value = env["BUDDYBUILD_PULL_REQUEST"]
|
42
|
+
return !value.nil? && !env["BUDDYBUILD_PULL_REQUEST"].empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
#######################################################################
|
46
|
+
def supported_request_sources
|
47
|
+
@supported_request_sources ||= [
|
48
|
+
Danger::RequestSources::GitHub,
|
49
|
+
Danger::RequestSources::GitLab,
|
50
|
+
Danger::RequestSources::BitbucketServer,
|
51
|
+
Danger::RequestSources::BitbucketCloud
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
#######################################################################
|
56
|
+
def initialize(env)
|
57
|
+
self.repo_slug = env["BUDDYBUILD_REPO_SLUG"]
|
58
|
+
self.pull_request_id = env["BUDDYBUILD_PULL_REQUEST"]
|
59
|
+
self.repo_url = GitRepo.new.origins # Buddybuild doesn't provide a repo url env variable for now
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|