lita-github-deploy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 161e87b39261720f98b175b21595362a04a1a12b
4
+ data.tar.gz: 0d892b7862f537d7398f97babcaf6a980fa62816
5
+ SHA512:
6
+ metadata.gz: fb64064031c022da86b0f5f666129a00b7fcd19ee9bd1cc07baa2e81c7b356664a6ad2d49bcb6abbb6a593ae71bd20544d5c6d3e840ef2cf5f00caa7c4f8d6f1
7
+ data.tar.gz: e2a7a85ce303b69140d6e46f2466090c6d27e5d79fa867f3f3508e2c6c6ac75ea3da1045ff5287f21b22d226abbb531d00bed5b486f8ce74a816b35738675e37
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ lita_config.rb
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
@@ -0,0 +1,26 @@
1
+ Metrics/AbcSize:
2
+ Max: 30
3
+
4
+ Metrics/LineLength:
5
+ Max: 120
6
+
7
+ Metrics/MethodLength:
8
+ Max: 30
9
+
10
+ Style/Documentation:
11
+ Enabled: false
12
+
13
+ Style/FileName:
14
+ Enabled: false
15
+
16
+ Style/IndentArray:
17
+ EnforcedStyle: consistent
18
+
19
+ Style/IndentHash:
20
+ EnforcedStyle: consistent
21
+
22
+ Style/SpaceInsideHashLiteralBraces:
23
+ EnforcedStyle: no_space
24
+
25
+ Style/SpecialGlobalVars:
26
+ Enabled: false
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.4
4
+ - 2.3.0
5
+ script:
6
+ - bundle exec rake
7
+ - bundle exec rubocop
8
+ before_install:
9
+ - gem update --system
10
+ services:
11
+ - redis-server
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2016 Sergey Nartimov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # lita-github-deploy
2
+
3
+ [![Build Status](https://travis-ci.org/lest/lita-github-deploy.png?branch=master)](https://travis-ci.org/lest/lita-github-deploy)
4
+ [![Coverage Status](https://coveralls.io/repos/lest/lita-github-deploy/badge.png)](https://coveralls.io/r/lest/lita-github-deploy)
5
+
6
+ [GitHub Flow](1) via [Lita](2).
7
+
8
+ ## Installation
9
+
10
+ Add lita-github-deploy to your Lita instance's Gemfile:
11
+
12
+ ``` ruby
13
+ gem 'lita-github-deploy'
14
+ ```
15
+
16
+ ## Configuration
17
+
18
+ TODO: Describe any configuration attributes the plugin exposes.
19
+
20
+ ## Usage
21
+
22
+ TODO: Describe the plugin's features and how to use them.
23
+
24
+ [1]: https://guides.github.com/overviews/flow/
25
+ [2]: https://www.lita.io
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,11 @@
1
+ require 'lita'
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join('..', '..', 'locales', '*.yml'), __FILE__
5
+ )]
6
+
7
+ require 'lita/handlers/github_deploy'
8
+
9
+ Lita::Handlers::GitHubDeploy.template_root File.expand_path(
10
+ File.join('..', '..', 'templates'), __FILE__
11
+ )
@@ -0,0 +1,41 @@
1
+ require 'octokit'
2
+
3
+ module Lita
4
+ module Handlers
5
+ class GitHubDeploy < Handler
6
+ namespace :github_deploy
7
+ config :access_token, type: String, required: true
8
+ config :apps, type: Hash, required: true
9
+
10
+ route(/^deploy\s+/, :deploy, command: true, help: {
11
+ 'deploy APP' => 'Deploy APP.',
12
+ 'deploy APP#REF' => 'Deploy REF.',
13
+ 'deploy APP to ENV' => 'Deploy to ENV'
14
+ })
15
+
16
+ def deploy(response)
17
+ app, _, env = response.args
18
+ app, ref = app.split('#')
19
+ app_config = config.apps[app]
20
+ if app_config
21
+ repo = app_config.fetch(:repo)
22
+ ref ||= app_config.fetch(:default_ref, 'master')
23
+ env ||= app_config.fetch(:default_env, 'production')
24
+ create_deployment(repo, ref, env)
25
+ response.reply("deploying #{repo}##{ref} to #{env}")
26
+ else
27
+ response.reply("#{app} not found")
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def create_deployment(repo, ref, env)
34
+ client = Octokit::Client.new(access_token: config.access_token)
35
+ client.create_deployment(repo, ref, environment: env)
36
+ end
37
+
38
+ Lita.register_handler(self)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-github-deploy'
3
+ spec.version = '0.0.1'
4
+ spec.authors = ['Sergey Nartimov']
5
+ spec.email = ['just.lest@gmail.com']
6
+ spec.summary = 'GitHub Flow via Lita.'
7
+ spec.license = 'MIT'
8
+ spec.metadata = {'lita_plugin_type' => 'handler'}
9
+
10
+ spec.files = `git ls-files`.split($/)
11
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
12
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
13
+ spec.require_paths = ['lib']
14
+
15
+ spec.add_runtime_dependency 'lita', '>= 4.7'
16
+ spec.add_runtime_dependency 'octokit', '~> 4.3'
17
+
18
+ spec.add_development_dependency 'bundler', '~> 1.3'
19
+ spec.add_development_dependency 'pry-byebug'
20
+ spec.add_development_dependency 'rake'
21
+ spec.add_development_dependency 'rack-test'
22
+ spec.add_development_dependency 'rspec', '>= 3.0.0'
23
+ spec.add_development_dependency 'webmock'
24
+ spec.add_development_dependency 'simplecov'
25
+ spec.add_development_dependency 'coveralls'
26
+ spec.add_development_dependency 'rubocop'
27
+ end
@@ -0,0 +1,4 @@
1
+ Lita.configure do |config|
2
+ config.handlers.github_deploy.access_token = 'myaccesstoken'
3
+ config.handlers.github_deploy.apps = {'myapp' => {repo: 'testuser/myapp'}}
4
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Lita::Handlers::GitHubDeploy, lita_handler: true do
4
+ before do
5
+ allow(robot.config.handlers.github_deploy).to receive_messages(
6
+ apps: {
7
+ 'myapp' => {repo: 'testuser/myapp'}
8
+ },
9
+ access_token: 'myaccesstoken'
10
+ )
11
+ end
12
+
13
+ shared_examples 'deploy' do
14
+ it 'sends create deployment request' do
15
+ stub_request(:post, 'https://api.github.com/repos/testuser/myapp/deployments')
16
+ .with(body: params,
17
+ headers: {'Authorization' => 'token myaccesstoken'})
18
+
19
+ send_command(command)
20
+
21
+ expect(replies.last).to eq(reply)
22
+ end
23
+ end
24
+
25
+ context 'deploy app' do
26
+ let(:command) { 'deploy myapp' }
27
+ let(:params) { {environment: 'production', ref: 'master'} }
28
+ let(:reply) { 'deploying testuser/myapp#master to production' }
29
+ include_examples 'deploy'
30
+ end
31
+
32
+ context 'deploy app to staging' do
33
+ let(:command) { 'deploy myapp to staging' }
34
+ let(:params) { {environment: 'staging', ref: 'master'} }
35
+ let(:reply) { 'deploying testuser/myapp#master to staging' }
36
+ include_examples 'deploy'
37
+ end
38
+
39
+ context 'deploy app#ref' do
40
+ let(:command) { 'deploy myapp#experiment' }
41
+ let(:params) { {environment: 'production', ref: 'experiment'} }
42
+ let(:reply) { 'deploying testuser/myapp#experiment to production' }
43
+ include_examples 'deploy'
44
+ end
45
+
46
+ context 'when app is not found' do
47
+ subject { replies.last }
48
+ before { send_command('deploy foobar') }
49
+
50
+ it { is_expected.to eq('foobar not found') }
51
+ end
52
+ end
@@ -0,0 +1,18 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ])
7
+ SimpleCov.start do
8
+ add_filter '/.bundle/'
9
+ add_filter '/spec/'
10
+ end
11
+
12
+ require 'lita-github-deploy'
13
+ require 'lita/rspec'
14
+ require 'webmock/rspec'
15
+
16
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
17
+ # was generated with Lita 4, the compatibility mode should be left disabled.
18
+ Lita.version_3_compatibility_mode = false
File without changes
metadata ADDED
@@ -0,0 +1,215 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-github-deploy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sergey Nartimov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: octokit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: coveralls
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description:
168
+ email:
169
+ - just.lest@gmail.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rubocop.yml"
176
+ - ".travis.yml"
177
+ - Gemfile
178
+ - LICENSE
179
+ - README.md
180
+ - Rakefile
181
+ - lib/lita-github-deploy.rb
182
+ - lib/lita/handlers/github_deploy.rb
183
+ - lita-github-deploy.gemspec
184
+ - lita_config.example.rb
185
+ - spec/lita/handlers/github_deploy_spec.rb
186
+ - spec/spec_helper.rb
187
+ - templates/.gitkeep
188
+ homepage:
189
+ licenses:
190
+ - MIT
191
+ metadata:
192
+ lita_plugin_type: handler
193
+ post_install_message:
194
+ rdoc_options: []
195
+ require_paths:
196
+ - lib
197
+ required_ruby_version: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ required_rubygems_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ requirements: []
208
+ rubyforge_project:
209
+ rubygems_version: 2.4.5.1
210
+ signing_key:
211
+ specification_version: 4
212
+ summary: GitHub Flow via Lita.
213
+ test_files:
214
+ - spec/lita/handlers/github_deploy_spec.rb
215
+ - spec/spec_helper.rb