danger-jira_sync 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c360d072f8ddd6e355f8caa61e54c35120dc13755a696c67989dc3e356255be2
4
+ data.tar.gz: 7c5d7fc9bf762c0a8c48207e6309602f296fc7fc140b079cf5de17967857c8d0
5
+ SHA512:
6
+ metadata.gz: df06871336370d27c650c8644cd1c5c37123b59d98c5abc07352a109271731f135e8313e990d4c671dc7252d94cb118e3111a08cb7bbedf0c437f0c2f39c5d01
7
+ data.tar.gz: 415ee0b570b8ce7965b3106b2d97af5b48569bb473b32338b3e4c04c64c80b904f6c747a0e1ac5204746a5bb756f218a5ae25639116294f18cd97cd71c578ada
data/.env.sample ADDED
@@ -0,0 +1,4 @@
1
+ DANGER_GITHUB_API_TOKEN=your_github_api_token
2
+ DANGER_JIRA_URL=https://your_jira_url.atlassian.net/
3
+ DANGER_JIRA_USERNAME=your_jira_email@address.com
4
+ DANGER_JIRA_API_TOKEN=replace_with_atlassian_api_token
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ .yardoc
5
+ coverage/
6
+ .env
data/.rubocop.yml ADDED
@@ -0,0 +1,152 @@
1
+ # Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+
3
+ # If you don't like these settings, just delete this file :)
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.3
7
+
8
+ Style/StringLiterals:
9
+ EnforcedStyle: double_quotes
10
+ Enabled: true
11
+
12
+ # kind_of? is a good way to check a type
13
+ Style/ClassCheck:
14
+ EnforcedStyle: kind_of?
15
+
16
+ # It's better to be more explicit about the type
17
+ Style/BracesAroundHashParameters:
18
+ Enabled: false
19
+
20
+ # specs sometimes have useless assignments, which is fine
21
+ Lint/UselessAssignment:
22
+ Exclude:
23
+ - '**/spec/**/*'
24
+
25
+ # We could potentially enable the 2 below:
26
+ Layout/IndentHash:
27
+ Enabled: false
28
+
29
+ Layout/AlignHash:
30
+ Enabled: false
31
+
32
+ # HoundCI doesn't like this rule
33
+ Layout/DotPosition:
34
+ Enabled: false
35
+
36
+ # We allow !! as it's an easy way to convert ot boolean
37
+ Style/DoubleNegation:
38
+ Enabled: false
39
+
40
+ # Cop supports --auto-correct.
41
+ Lint/UnusedBlockArgument:
42
+ Enabled: false
43
+
44
+ # We want to allow class Fastlane::Class
45
+ Style/ClassAndModuleChildren:
46
+ Enabled: false
47
+
48
+ Metrics/AbcSize:
49
+ Max: 60
50
+
51
+ # The %w might be confusing for new users
52
+ Style/WordArray:
53
+ MinSize: 19
54
+
55
+ # raise and fail are both okay
56
+ Style/SignalException:
57
+ Enabled: false
58
+
59
+ # Better too much 'return' than one missing
60
+ Style/RedundantReturn:
61
+ Enabled: false
62
+
63
+ # Having if in the same line might not always be good
64
+ Style/IfUnlessModifier:
65
+ Enabled: false
66
+
67
+ # and and or is okay
68
+ Style/AndOr:
69
+ Enabled: false
70
+
71
+ # Configuration parameters: CountComments.
72
+ Metrics/ClassLength:
73
+ Max: 350
74
+
75
+ Metrics/CyclomaticComplexity:
76
+ Max: 17
77
+
78
+ # Configuration parameters: AllowURI, URISchemes.
79
+ Metrics/LineLength:
80
+ Max: 370
81
+
82
+ # Configuration parameters: CountKeywordArgs.
83
+ Metrics/ParameterLists:
84
+ Max: 10
85
+
86
+ Metrics/PerceivedComplexity:
87
+ Max: 18
88
+
89
+ # Sometimes it's easier to read without guards
90
+ Style/GuardClause:
91
+ Enabled: false
92
+
93
+ # something = if something_else
94
+ # that's confusing
95
+ Style/ConditionalAssignment:
96
+ Enabled: false
97
+
98
+ # Better to have too much self than missing a self
99
+ Style/RedundantSelf:
100
+ Enabled: false
101
+
102
+ Metrics/MethodLength:
103
+ Max: 60
104
+
105
+ # We're not there yet
106
+ Style/Documentation:
107
+ Enabled: false
108
+
109
+ # Adds complexity
110
+ Style/IfInsideElse:
111
+ Enabled: false
112
+
113
+ # danger specific
114
+
115
+ Style/BlockComments:
116
+ Enabled: false
117
+
118
+ Layout/MultilineMethodCallIndentation:
119
+ EnforcedStyle: indented
120
+
121
+ # FIXME: 25
122
+ Metrics/BlockLength:
123
+ Max: 345
124
+ Exclude:
125
+ - "**/*_spec.rb"
126
+
127
+ Style/MixinGrouping:
128
+ Enabled: false
129
+
130
+ Naming/FileName:
131
+ Enabled: false
132
+
133
+ Layout/IndentHeredoc:
134
+ Enabled: false
135
+
136
+ Style/SpecialGlobalVars:
137
+ Enabled: false
138
+
139
+ PercentLiteralDelimiters:
140
+ PreferredDelimiters:
141
+ "%": ()
142
+ "%i": ()
143
+ "%q": ()
144
+ "%Q": ()
145
+ "%r": "{}"
146
+ "%s": ()
147
+ "%w": ()
148
+ "%W": ()
149
+ "%x": ()
150
+
151
+ Security/YAMLLoad:
152
+ Enabled: false
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ danger-jira_sync
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.0
8
+ - 2.1.3
9
+ - 2.3.1
10
+
11
+ script:
12
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in danger-jira_sync.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,177 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-jira_sync (0.0.1)
5
+ danger-plugin-api (~> 1.0)
6
+ jira-ruby (~> 1.5.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.2.0)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ addressable (2.5.2)
17
+ public_suffix (>= 2.0.2, < 4.0)
18
+ ast (2.4.0)
19
+ awesome_print (1.8.0)
20
+ claide (1.0.2)
21
+ claide-plugins (0.9.2)
22
+ cork
23
+ nap
24
+ open4 (~> 1.3)
25
+ coderay (1.1.2)
26
+ colored2 (3.1.2)
27
+ concurrent-ruby (1.0.5)
28
+ cork (0.3.0)
29
+ colored2 (~> 3.1)
30
+ crack (0.4.3)
31
+ safe_yaml (~> 1.0.0)
32
+ danger (5.6.2)
33
+ claide (~> 1.0)
34
+ claide-plugins (>= 0.9.2)
35
+ colored2 (~> 3.1)
36
+ cork (~> 0.1)
37
+ faraday (~> 0.9)
38
+ faraday-http-cache (~> 1.0)
39
+ git (~> 1)
40
+ kramdown (~> 1.5)
41
+ no_proxy_fix
42
+ octokit (~> 4.7)
43
+ terminal-table (~> 1)
44
+ danger-plugin-api (1.0.0)
45
+ danger (> 2.0)
46
+ diff-lcs (1.3)
47
+ docile (1.3.1)
48
+ dotenv (2.4.0)
49
+ faraday (0.15.2)
50
+ multipart-post (>= 1.2, < 3)
51
+ faraday-http-cache (1.3.1)
52
+ faraday (~> 0.8)
53
+ ffi (1.9.25)
54
+ formatador (0.2.5)
55
+ git (1.4.0)
56
+ guard (2.14.2)
57
+ formatador (>= 0.2.4)
58
+ listen (>= 2.7, < 4.0)
59
+ lumberjack (>= 1.0.12, < 2.0)
60
+ nenv (~> 0.1)
61
+ notiffany (~> 0.0)
62
+ pry (>= 0.9.12)
63
+ shellany (~> 0.0)
64
+ thor (>= 0.18.1)
65
+ guard-compat (1.2.1)
66
+ guard-rspec (4.7.3)
67
+ guard (~> 2.1)
68
+ guard-compat (~> 1.1)
69
+ rspec (>= 2.99.0, < 4.0)
70
+ hashdiff (0.3.7)
71
+ i18n (1.0.1)
72
+ concurrent-ruby (~> 1.0)
73
+ jaro_winkler (1.5.1)
74
+ jira-ruby (1.5.0)
75
+ activesupport
76
+ multipart-post
77
+ oauth (~> 0.5, >= 0.5.0)
78
+ json (2.1.0)
79
+ kramdown (1.17.0)
80
+ listen (3.0.7)
81
+ rb-fsevent (>= 0.9.3)
82
+ rb-inotify (>= 0.9.7)
83
+ lumberjack (1.0.13)
84
+ method_source (0.9.0)
85
+ minitest (5.11.3)
86
+ multipart-post (2.0.0)
87
+ nap (1.1.0)
88
+ nenv (0.3.0)
89
+ no_proxy_fix (0.1.2)
90
+ notiffany (0.1.1)
91
+ nenv (~> 0.1)
92
+ shellany (~> 0.0)
93
+ oauth (0.5.4)
94
+ octokit (4.9.0)
95
+ sawyer (~> 0.8.0, >= 0.5.3)
96
+ open4 (1.3.4)
97
+ parallel (1.12.1)
98
+ parser (2.5.1.0)
99
+ ast (~> 2.4.0)
100
+ powerpack (0.1.1)
101
+ pry (0.11.3)
102
+ coderay (~> 1.1.0)
103
+ method_source (~> 0.9.0)
104
+ public_suffix (3.0.2)
105
+ rainbow (3.0.0)
106
+ rake (10.5.0)
107
+ rb-fsevent (0.10.3)
108
+ rb-inotify (0.9.10)
109
+ ffi (>= 0.5.0, < 2)
110
+ rspec (3.7.0)
111
+ rspec-core (~> 3.7.0)
112
+ rspec-expectations (~> 3.7.0)
113
+ rspec-mocks (~> 3.7.0)
114
+ rspec-core (3.7.1)
115
+ rspec-support (~> 3.7.0)
116
+ rspec-expectations (3.7.0)
117
+ diff-lcs (>= 1.2.0, < 2.0)
118
+ rspec-support (~> 3.7.0)
119
+ rspec-mocks (3.7.0)
120
+ diff-lcs (>= 1.2.0, < 2.0)
121
+ rspec-support (~> 3.7.0)
122
+ rspec-support (3.7.1)
123
+ rubocop (0.57.1)
124
+ jaro_winkler (~> 1.5.1)
125
+ parallel (~> 1.10)
126
+ parser (>= 2.5)
127
+ powerpack (~> 0.1)
128
+ rainbow (>= 2.2.2, < 4.0)
129
+ ruby-progressbar (~> 1.7)
130
+ unicode-display_width (~> 1.0, >= 1.0.1)
131
+ ruby-progressbar (1.9.0)
132
+ safe_yaml (1.0.4)
133
+ sawyer (0.8.1)
134
+ addressable (>= 2.3.5, < 2.6)
135
+ faraday (~> 0.8, < 1.0)
136
+ shellany (0.0.1)
137
+ simplecov (0.16.1)
138
+ docile (~> 1.1)
139
+ json (>= 1.8, < 3)
140
+ simplecov-html (~> 0.10.0)
141
+ simplecov-html (0.10.2)
142
+ terminal-table (1.8.0)
143
+ unicode-display_width (~> 1.1, >= 1.1.1)
144
+ thor (0.20.0)
145
+ thread_safe (0.3.6)
146
+ tzinfo (1.2.5)
147
+ thread_safe (~> 0.1)
148
+ unicode-display_width (1.4.0)
149
+ vcr (4.0.0)
150
+ webmock (3.4.2)
151
+ addressable (>= 2.3.6)
152
+ crack (>= 0.3.2)
153
+ hashdiff
154
+ yard (0.9.14)
155
+
156
+ PLATFORMS
157
+ ruby
158
+
159
+ DEPENDENCIES
160
+ awesome_print
161
+ bundler (~> 1.3)
162
+ danger-jira_sync!
163
+ dotenv
164
+ guard (~> 2.14)
165
+ guard-rspec (~> 4.7)
166
+ listen (= 3.0.7)
167
+ pry
168
+ rake (~> 10.0)
169
+ rspec (~> 3.4)
170
+ rubocop
171
+ simplecov
172
+ vcr
173
+ webmock
174
+ yard
175
+
176
+ BUNDLED WITH
177
+ 1.16.2
data/Guardfile ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A guardfile for making Danger Plugins
4
+ # For more info see https://github.com/guard/guard#readme
5
+
6
+ # To run, use `bundle exec guard`.
7
+
8
+ guard :rspec, cmd: "bundle exec rspec" do
9
+ require "guard/rspec/dsl"
10
+ dsl = Guard::RSpec::Dsl.new(self)
11
+
12
+ # RSpec files
13
+ rspec = dsl.rspec
14
+ watch(rspec.spec_helper) { rspec.spec_dir }
15
+ watch(rspec.spec_support) { rspec.spec_dir }
16
+ watch(rspec.spec_files)
17
+
18
+ # Ruby files
19
+ ruby = dsl.ruby
20
+ dsl.watch_spec_files_for(ruby.lib_files)
21
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 Ben Menesini <ben.menesini@rover.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # danger-jira_sync
2
+
3
+ Jira and GitHub should be friends, and Danger brings them closer together
4
+ with jira_sync
5
+
6
+ ## Installation
7
+
8
+ Add `danger-jira_sync` to your Gemfile
9
+
10
+ gem "danger-jira_sync", git: "https://github.com/roverdotcom/danger-jira_sync"
11
+
12
+ Or, without bundler
13
+
14
+ $ gem install danger-jira_sync -s https://github.com/roverdotcom/danger-jira_sync
15
+
16
+ ## Usage
17
+
18
+ You must always configure jira_sync before it can access the Jira REST API
19
+
20
+ jira_sync.configure(
21
+ jira_url: "https://myjirainstance.atlassian.net",
22
+ jira_username: "test@example.com",
23
+ jira_api_token: "ABC123",
24
+ )
25
+
26
+ Automatically label Pull Requests with the associated Jira issue's component names and project key
27
+
28
+ jira_sync.autolabel_pull_request(%w(DEV))
29
+
30
+ ## Methods
31
+
32
+ ### `configure(jira_url:, jira_username:, jira_api_token:)`
33
+ Configures the Jira Client with your credentials
34
+
35
+ **Params**
36
+ - `jira_url [String]` - The full url to your Jira instance, e.g., "https://myjirainstance.atlassian.net"
37
+ - `jira_username [String]` - The username to use for accessing the Jira instance. Commonly, this is an email address
38
+ - `jira_api_token [String]` - The API key to use to access the Jira instance. Generate one here: https://id.atlassian.com/manage/api-tokens
39
+
40
+ **Returns**
41
+ - `[JIRA::Client]` - The underlying `JIRA::Client` instance
42
+
43
+ ### `autolabel_pull_request(issue_prefixes)`
44
+ Labels the Pull Request with Jira Project Keys and Component Names
45
+
46
+ **Params**
47
+ - `issue_prefixes [Array<String>]` - An array of issue key prefixes; this is often the project key. These must be present in the title or body of the Pull Request
48
+
49
+ **Returns**
50
+ - `[Array<String>, nil]` - The list of project & component labels that were applied or nil if no issue or labels were found
51
+
52
+
53
+ ## Development
54
+
55
+ 1. Create a [Jira Cloud developmnet environment](http://go.atlassian.com/cloud-dev)
56
+ 2. Clone this repo
57
+ 3. Run `bundle install` to setup dependencies
58
+ 4. Copy `.env.sample` to `.env` and fill in settings for GitHub and your Jira Cloud development environment
59
+ 5. Run `bundle exec rake spec` to run the tests
60
+ 6. Use `bundle exec guard` to automatically have tests run as you make changes
61
+ 7. Make your changes
62
+
63
+ # **:warning: Do not commit fixtures with your credentials in them :warning:**
64
+
65
+ Before committing, check to see if you have created or changed any fixtures in `/spec/fixtures/vcr_cassettes`. If you have, it is likely that the changed file contains your credentials. Manually remove your credentials from these fixture files
66
+
67
+ When a new HTTP request is made that [VCR](https://github.com/vcr/vcr) hasn't seen before, it will record the response from the server and play it back in subsequent HTTP requests to the same URL with the same headers. This means that if a new request is made in the tests, it will actually make a request to the server in order to record the response. For this reason, development should be done within testing environments in GitHub and Jira Cloud
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+
7
+ RSpec::Core::RakeTask.new(:specs)
8
+
9
+ task default: :specs
10
+
11
+ task :spec do
12
+ Rake::Task["specs"].invoke
13
+ Rake::Task["rubocop"].invoke
14
+ Rake::Task["spec_docs"].invoke
15
+ end
16
+
17
+ desc "Run RuboCop on the lib/specs directory"
18
+ RuboCop::RakeTask.new(:rubocop) do |task|
19
+ task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
20
+ end
21
+
22
+ desc "Ensure that the plugin passes `danger plugins lint`"
23
+ task :spec_docs do
24
+ sh "bundle exec danger plugins lint"
25
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "jira_sync/gem_version.rb"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "danger-jira_sync"
9
+ spec.version = JiraSync::VERSION
10
+ spec.authors = ["Ben Menesini"]
11
+ spec.email = ["ben.menesini@rover.com"]
12
+ spec.description = "Synchronizes information between Jira and GitHub"
13
+ spec.summary = "Synchronizes information betweeh Jira and GitHub"
14
+ spec.homepage = "https://github.com/roverdotcom/danger-jira_sync"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency "danger-plugin-api", "~> 1.0"
23
+ spec.add_runtime_dependency "jira-ruby", "~> 1.5.0"
24
+
25
+ # General ruby development
26
+ spec.add_development_dependency "bundler", "~> 1.3"
27
+ spec.add_development_dependency "dotenv"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+
30
+ # Testing support
31
+ spec.add_development_dependency "rspec", "~> 3.4"
32
+ spec.add_development_dependency "simplecov"
33
+ spec.add_development_dependency "vcr"
34
+ spec.add_development_dependency "webmock"
35
+
36
+ # Linting code and docs
37
+ spec.add_development_dependency "rubocop"
38
+ spec.add_development_dependency "yard"
39
+
40
+ # Makes testing easy via `bundle exec guard`
41
+ spec.add_development_dependency "guard", "~> 2.14"
42
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
43
+
44
+ # If you want to work on older builds of ruby
45
+ spec.add_development_dependency "listen", "3.0.7"
46
+
47
+ # Pretty print
48
+ spec.add_development_dependency "awesome_print"
49
+
50
+ # This gives you the chance to run a REPL inside your tests
51
+ # via:
52
+ #
53
+ # require 'pry'
54
+ # binding.pry
55
+ #
56
+ # This will stop test execution and let you inspect the results
57
+ spec.add_development_dependency "pry"
58
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jira_sync/gem_version"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jira_sync/plugin"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JiraSync
4
+ VERSION = "0.0.1"
5
+ end