release-conductor 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 114269a449c04251f4afb3019d27a1fa3aee9454
4
+ data.tar.gz: d84b1f047d41588e504bad2f15d8c99b803aaac8
5
+ SHA512:
6
+ metadata.gz: c2af7243fc5f70c985dd249f5efce53b7ca2840a9de88d2bafe5e4a8b5107dd9e9ffabe6eacb35425d6b21ac82d29e97870db788a69bc789c2777e191d3e3da4
7
+ data.tar.gz: def3a5ecdfa24c15abb9ff7673d29f4b993c1962de8d2c42b0a191011f151885969be6954deb09d4b0815458156c5c68db92bd5858d1a82759b6882c36a3671d
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ Gemfile.lock
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in release-conductor.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Robert Mathews
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,62 @@
1
+ # Slackistrano
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/slackistrano.png)](http://badge.fury.io/rb/slackistrano)
4
+ [![Code Climate](https://codeclimate.com/github/GoodMeasuresLLC/release-conductor.png)](https://codeclimate.com/github/GoodMeasuresLLC/release-conductor)
5
+ [![Build Status](https://travis-ci.org/GoodMeasuresLLC/release-conductor.png?branch=master)](https://travis-ci.org/GoodMeasuresLLC/release-conductor)
6
+
7
+ Mark the phase of the tickets during releases to staging and production deployments
8
+
9
+ ## Requirements
10
+
11
+ - Capistrano >= 3.1.0
12
+ - Ruby >= 2.0
13
+ - A Slack account
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'release-tickets', require: false
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ ```bash
26
+ $ bundle
27
+ ```
28
+
29
+ ## Configuration
30
+
31
+ Require the library in your application's Capfile:
32
+
33
+ ```ruby
34
+ require 'slackistrano'
35
+ ```
36
+ Note that in your ENV you must define your unfuddle account and password, like this:
37
+
38
+ export UNFUDDLE_USER=fred
39
+ export UNFUDDLE_PASSWORD=super-duper-secret
40
+
41
+ This account must have privileges to mark the tickets.
42
+
43
+
44
+ Test your setup by running:
45
+
46
+ ```bash
47
+ $ cap production release_conductor:deploy:finished
48
+ ```
49
+
50
+ ## Usage
51
+
52
+ Deploy your application like normal and the tickets should be marked.
53
+
54
+ ## TODO
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => :spec
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,37 @@
1
+ namespace :release_conductor do
2
+ namespace :deploy do
3
+ task :finished do
4
+ case fetch(:stage)
5
+ when 'beta-staging' then ReleaseConductor.punch_tickets(:staging,self,['beta'],'beta-dev')
6
+ when 'staging' then ReleaseConductor.punch_tickets(:staging,self,[nil,'code'],'code-dev')
7
+ when 'production' then ReleaseConductor.punch_tickets(:production, self,[nil,'code'],'code')
8
+ when 'beta-production' then ReleaseConductor.punch_tickets(:production, self,['beta'],'beta')
9
+ else
10
+ ReleaseConductor.testing(self)
11
+ end
12
+ end
13
+ task :testing do
14
+ ReleaseConductor.punch_tickets_to_testing(self,[nil,'code'],'code')
15
+ end
16
+ end
17
+ end
18
+
19
+ after 'deploy:finished', 'release_conductor:deploy:finished'
20
+
21
+ namespace :load do
22
+ task :defaults do
23
+ set :account, 'goodmeasures'
24
+ set :unfuddle_user, -> { ENV['UNFUDDLE_USER'] }
25
+ set :unfuddle_password, -> { ENV['UNFUDDLE_PASSWORD'] }
26
+ set :project_id, 1
27
+ set :fixed_tickets_in_development_report_id, 55
28
+ set :verified_tickets_in_staging_report_id, 66
29
+ # execute this curl to get the list of custom field values, and then get those numbers from
30
+ # there
31
+ # curl -i -u username:password -X
32
+ # GET -H 'Accept: application/xml'
33
+ # 'https://goodmeasures.unfuddle.com/api/v1/projects/1/custom_field_values.xml'
34
+ set :test_phase, 10
35
+ set :production_phase, 15
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module ReleaseConductor
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,123 @@
1
+ require 'release-conductor/version'
2
+ require 'net/https'
3
+ require 'json'
4
+
5
+ load File.expand_path("../release-conductor/tasks/release-conductor.rake", __FILE__)
6
+
7
+ module ReleaseConductor
8
+
9
+ def self.unfuddle_request(config,url,type)
10
+ uri = URI("https://#{config.fetch(:account)}.unfuddle.com#{url}")
11
+
12
+ request = case
13
+ when type == :get
14
+ Net::HTTP::Get
15
+ when type == :put
16
+ Net::HTTP::Put
17
+ else
18
+ raise "Add support for #{type}"
19
+ end.new(uri)
20
+
21
+ request.content_type='application/xml'
22
+ request.basic_auth config.fetch(:unfuddle_user),config.fetch(:unfuddle_password)
23
+
24
+ yield(request) if block_given?
25
+
26
+ Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
27
+ http.request(request)
28
+ end
29
+ end
30
+
31
+ def self.get(config,url)
32
+ response = unfuddle_request(config, url + ".json", :get) do |request|
33
+ request.content_type='application/json'
34
+ end
35
+
36
+ unless response.is_a?(Net::HTTPSuccess)
37
+ raise "failure for #{url}, got #{response.code} #{response.message}"
38
+ end
39
+
40
+ JSON.parse(response.body)
41
+ end
42
+
43
+ def self.put(config, url, body)
44
+ response = unfuddle_request(config, url, :put) do |request|
45
+ request.body = body
46
+ end
47
+
48
+ unless response.is_a?(Net::HTTPSuccess)
49
+ puts "response.body=#{response.body}"
50
+ raise "failure for #{uri}, got #{response.code} #{response.message}"
51
+ end
52
+ response.body
53
+ end
54
+
55
+ def self.run_ticket_report(config, report_id)
56
+ hash=get(config, "/api/v1/projects/#{config.fetch(:project_id)}/ticket_reports/#{report_id}/generate")
57
+ (hash["groups"].first||{})["tickets"]
58
+ end
59
+
60
+ def self.version_ids(versions)
61
+ versions.map do |version|
62
+ case version
63
+ when nil then nil
64
+ when 'code' then 3
65
+ when 'beta' then 2
66
+ else
67
+ raise 'bad version ' + version
68
+ end
69
+ end
70
+ end
71
+
72
+ def self.filter_by_versions(tickets,versions)
73
+ version_ids = self.version_ids(versions)
74
+ tickets.select do |ticket|
75
+ version_ids.include?(ticket["version_id"])
76
+ end
77
+ end
78
+
79
+ def self.set_phase(config, tickets, phase_value_id)
80
+ tickets.each do |ticket|
81
+ puts "punching ticket ##{ticket['number']}"
82
+ url = "/api/v1/projects/#{config.fetch(:project_id)}/tickets/#{ticket['id']}"
83
+
84
+ # puts "Fetching Ticket Details from #{url}"
85
+ ticket_details = get(config, url)
86
+
87
+ xml = %Q{
88
+ <ticket>
89
+ <field2-value-id>#{phase_value_id}</field2-value-id>
90
+ <summary>testing</summary>
91
+ </ticket>
92
+ }
93
+ put(config,url,xml)
94
+ end
95
+ end
96
+
97
+ def self.report(config,env)
98
+ case env
99
+ when :staging then config.fetch(:fixed_tickets_in_development_report_id)
100
+ when :production then config.fetch(:verified_tickets_in_staging_report_id)
101
+ end
102
+ end
103
+
104
+
105
+ def self.punch_tickets(env,config,versions,branch)
106
+ current_branch = `git branch`.match(/\* (\S+)\s/m)[1]
107
+ if current_branch == branch
108
+ tickets = filter_by_versions(run_ticket_report(config,report(config,env)),versions)
109
+ phase_id = config.fetch(env == :staging ? :test_phase : :production_phase)
110
+ set_phase(config, tickets, phase_id)
111
+ else
112
+ puts "ignoring as you are in branch #{current_branch} NOT #{branch}"
113
+ end
114
+ end
115
+
116
+ def self.testing(config)
117
+ ReleaseConductor.punch_tickets(:production, config,[nil,'code'],'master')
118
+ # puts filter_by_versions(
119
+ # run_ticket_report(config, config.fetch(:verified_tickets_in_staging_report_id)),['beta'])
120
+ end
121
+
122
+ end
123
+
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'release-conductor/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "release-conductor"
8
+ gem.version = ReleaseConductor::VERSION
9
+ gem.authors = ["Rob Mathews"]
10
+ gem.email = ["rob.mathews@goodmeasures.com"]
11
+ gem.description = %q{Mark the phase of unfuddle tickets in staging and production during deployments}
12
+ gem.summary = %q{Mark the phase of unfuddle tickets in staging and production during deployments}
13
+ gem.homepage = "https://github.com/GoodMeasuresLLC/release-conductor"
14
+ gem.license = 'MIT'
15
+
16
+ gem.required_ruby_version = '>= 2.0.0'
17
+
18
+ gem.files = `git ls-files`.split($/)
19
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
20
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
+ gem.require_paths = ["lib"]
22
+
23
+ gem.add_dependency 'capistrano', '>= 3.0.1'
24
+ gem.add_dependency 'json'
25
+ gem.add_development_dependency 'rake'
26
+ gem.add_development_dependency 'rspec'
27
+ gem.add_development_dependency 'byebug'
28
+ end
@@ -0,0 +1,8 @@
1
+ namespace :deploy do
2
+ task :starting do
3
+ end
4
+ task :finished do
5
+ end
6
+ task :failed do
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'capistrano/all'
4
+ require 'capistrano/setup'
5
+ load 'capistrano_deploy_stubs.rake'
6
+ require 'release-conductor'
7
+ require 'rspec'
8
+
9
+ # Requires supporting files with custom matchers and macros, etc,
10
+ # in ./support/ and its subdirectories.
11
+ Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each {|f| require f}
12
+
13
+ RSpec.configure do |config|
14
+ config.order = 'random'
15
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'byebug'
3
+
4
+ describe ReleaseConductor do
5
+ before(:each) do
6
+ Rake::Task['load:defaults'].invoke
7
+ end
8
+
9
+ it "invokes release_conductor:deploy:finished after deploy:finished" do
10
+ # expect(ReleaseConductor).
11
+ Rake::Task['deploy:finished'].execute
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: release-conductor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Rob Mathews
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
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: byebug
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
+ description: Mark the phase of unfuddle tickets in staging and production during deployments
84
+ email:
85
+ - rob.mathews@goodmeasures.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".ruby-version"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/release-conductor.rb
97
+ - lib/release-conductor/tasks/release-conductor.rake
98
+ - lib/release-conductor/version.rb
99
+ - release-conductor.gemspec
100
+ - spec/capistrano_deploy_stubs.rake
101
+ - spec/spec_helper.rb
102
+ - spec/tasks_spec.rb
103
+ homepage: https://github.com/GoodMeasuresLLC/release-conductor
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 2.0.0
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.4.5
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Mark the phase of unfuddle tickets in staging and production during deployments
127
+ test_files:
128
+ - spec/capistrano_deploy_stubs.rake
129
+ - spec/spec_helper.rb
130
+ - spec/tasks_spec.rb