robopigeon 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: f5f0eb12780af404e3c5d222d9468804f0b7aec1aeef45407980ee90b578d66f
4
- data.tar.gz: c9947148df1def3093400399632b4fb7225be2c679fd141841ceae2a4b49e908
3
+ metadata.gz: 25d50f00dc30aa78bd9389cee8da7d93aa04920e4db5c10433f39c2df4d97b0f
4
+ data.tar.gz: c0f86cfe9dc63bb753d4ee5e88cfe16512fce547fcdb649ffe4776282c3162dd
5
5
  SHA512:
6
- metadata.gz: f8d9516e989b6cbae9a5bd5c6fe41224569be78689288ce35e322cdb15dc35549a706bd37b29e0b3c11440ce7ca4b92a73130a27edb81e9b3579d44ca7661b49
7
- data.tar.gz: 86704bdca6792091a21231d53ee8aa8c3d5175c77a118b796baf84d05a1aa91c7907b09998b8fe02233863d908654d8e598bd243fd18df897ca7f88b2ec5241a
6
+ metadata.gz: 9f980108a24e6e081f073e9747efca1fcb4cb14f776aa911cb4a60c769529401abf140b0f09de6c68208f1d78dde56a6ea8f8ae899b8ab3d943676be34bf8a80
7
+ data.tar.gz: 94b3b6a2f9631eb610ddfb2bf13fc8f885d3962d65a5dbdcfeb7c56ad44bbdf25d298db7fdf7b08ad9b3cd463cabc65a9c88c3310fd7a0b3a21960be94af7e0e
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 0.3.0 (2019-04-8)
2
+
3
+ ### Added
4
+
5
+ - Gitlab Helper to check if files had changed since deploy
6
+ - Gitlab Helper to get a link to a diff since that last deployment
7
+ - Init adds an rspec with an example to test your jobs
8
+
9
+ ### Changed
10
+
11
+ - Tickets since deploy takes an optional argument to specify a regex match
12
+ - Creating a ticket writes out a file called 'last_created_jira_ticket' with the ticket id in it
13
+
1
14
  ## 0.2.0 (2019-03-29)
2
15
 
3
16
  ### Added (3 changes)
data/README.md CHANGED
@@ -94,6 +94,11 @@ Jenkins
94
94
  Extensions
95
95
  - [x] Create basic example dsl extension gem template
96
96
 
97
+ ### Features for future version
98
+
99
+ Variables
100
+ - [ ] Add a variable configuration block that will inject them into all of the job contexts
101
+
97
102
  PagerDuty
98
103
  - [ ] Get current oncall user from pagerduty api
99
104
 
@@ -106,8 +111,6 @@ Changelog
106
111
  - [ ] Helpers provide changes since last deployment
107
112
  - [ ] Changelog yaml front matter informs risk of change
108
113
 
109
- ### Features for future version
110
-
111
114
  GitLab
112
115
  - [ ] Wait for a merge request to be ready to merge
113
116
  - [ ] Kick off a pipeline
@@ -1,5 +1,8 @@
1
1
  module RoboPigeon::Dsl::InitialJobs
2
2
  INITIAL_FILE = "#{File.dirname(__FILE__)}/../resources/initial_robopigeon.rb".freeze
3
+ INITIAL_TEST = "#{File.dirname(__FILE__)}/../../../spec/initial_robopigeon_spec.rb".freeze
4
+ TARGET_TEST = 'spec/robopigeon_spec.rb'.freeze
5
+
3
6
  # Used to pull in environment variables for things that are mostly set via dsl
4
7
  def base
5
8
  slack do
@@ -19,6 +22,7 @@ module RoboPigeon::Dsl::InitialJobs
19
22
  desc: 'Initialize a new robopigeon project',
20
23
  action: proc do
21
24
  FileUtils.cp(INITIAL_FILE, RoboPigeon::DEFAULT_FILE)
25
+ FileUtils.cp(INITIAL_TEST, TARGET_TEST)
22
26
  end
23
27
  }
24
28
  end
@@ -17,7 +17,7 @@ module RoboPigeon::Extensions
17
17
 
18
18
  def render_to(path)
19
19
  cwd = FileUtils.pwd
20
- base = File.expand_path("#{path}/robopigeon-#{name}")
20
+ base = File.expand_path("#{path}/robopigeon_#{name}")
21
21
  FileUtils.cd "#{TEMPLATE_PATH}/#{template}"
22
22
  FileUtils.mkdir_p base.to_s
23
23
  Dir.glob('{**{,/*/**},.*}') do |file|
@@ -3,4 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in robopigeon.gemspec
4
4
  gemspec
5
5
 
6
- gem 'robopigeon', path: '../robopigeon'
6
+ <% if ENV['ROBOPIGEON_TEST'] %>
7
+ gem 'robopigeon', path: '../robopigeon'
8
+ <% end %>
@@ -1,4 +1,4 @@
1
- # RoboPigeon-<%= extension_name_upper %>
1
+ # RoboPigeon <%= extension_name_upper %>
2
2
 
3
3
  TODO: Add a description of what dsls/helpers this adds.
4
4
 
@@ -9,7 +9,7 @@ This Gem is developed against ruby 2.5, but is tested in CI against the latest v
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'robopigeon-<%= extension_name_lower %>'
12
+ gem 'robopigeon_<%= extension_name_lower %>'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -18,7 +18,7 @@ And then execute:
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install robopigeon-<%= extension_name_lower %>
21
+ $ gem install robopigeon_<%= extension_name_lower %>
22
22
 
23
23
  ## Usage
24
24
 
@@ -32,4 +32,4 @@ Then run `bundle exec rspec` to run the tests.
32
32
 
33
33
  ## Contributing
34
34
 
35
- Bug reports and pull requests are welcome on GitLab at https://gitlab.com/{gitlab_username}/robopigeon-<%= extension_name_lower %>.
35
+ Bug reports and pull requests are welcome on GitLab at https://gitlab.com/{gitlab_username}/robopigeon_<%= extension_name_lower %>.
@@ -1,6 +1,6 @@
1
- require 'robopigeon-<%= extension_name_lower %>/helper_dsl'
2
- require 'robopigeon-<%= extension_name_lower %>/dsl'
3
- require 'robopigeon-<%= extension_name_lower %>/version'
1
+ require 'robopigeon_<%= extension_name_lower %>/helper_dsl'
2
+ require 'robopigeon_<%= extension_name_lower %>/dsl'
3
+ require 'robopigeon_<%= extension_name_lower %>/version'
4
4
 
5
5
  module RoboPigeon::Dsl
6
6
  module Helpers
@@ -1,9 +1,9 @@
1
1
  lib = File.expand_path('../lib', __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'robopigeon-<%= extension_name_lower %>/version'
3
+ require 'robopigeon_<%= extension_name_lower %>/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'robopigeon-<%= extension_name_lower %>'
6
+ spec.name = 'robopigeon_<%= extension_name_lower %>'
7
7
  spec.version = RoboPigeon::<%= extension_name_upper %>::VERSION
8
8
  spec.authors = ['<%= user_name %>']
9
9
  spec.email = ['<%= user_email %>']
@@ -1,7 +1,7 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'bundler/setup'
3
3
  require 'robopigeon'
4
- require 'robopigeon-<%= extension_name_lower %>'
4
+ require 'robopigeon_<%= extension_name_lower %>'
5
5
  require 'pry'
6
6
 
7
7
  RSpec.configure do |config|
@@ -31,6 +31,19 @@ module RoboPigeon::Dsl
31
31
  get_merge_data[:target]
32
32
  end
33
33
 
34
+ RoboPigeon::Documentarian.add_command(
35
+ 'changed_since?',
36
+ block: ['helpers'],
37
+ params: [
38
+ { name: 'ref', type: 'String', example: 'd72f9e3808a9e6d59ac88e3d56b81f073c5cca37', desc: 'Git ref to compare to' },
39
+ { name: 'files', type: 'String', example: 'build.gradle', desc: 'file to check if changed' }
40
+ ],
41
+ desc: 'target branch in the last merge commit'
42
+ )
43
+ def changed_since?(ref, *files)
44
+ `git diff #{ref} -- #{files.join(' ')}`
45
+ end
46
+
34
47
  private
35
48
 
36
49
  def merge_commit_subject
@@ -15,6 +15,12 @@ module RoboPigeon::Dsl
15
15
  dep.ref
16
16
  end
17
17
 
18
+ RoboPigeon::Documentarian.add_command('deployment_diff_link', block: ['helpers'], params: [{ name: 'environment', type: 'String', desc: 'the name of a gitlab operations environment', example: 'production' }], desc: 'get a link to the changes between the last deploy and the current ref')
19
+ def deployment_diff_link(environment)
20
+ dep = RoboPigeon::GitLab::Client.get_deployment(environment)
21
+ "#{ENV['CI_PROJECT_URL']}/compare/#{dep.ref}...#{ENV['CI_COMMIT_TAG']}"
22
+ end
23
+
18
24
  RoboPigeon::Documentarian.add_command('deployment_shortlog', block: ['helpers'], params: [{ name: 'environment', type: 'String', desc: 'the name of a gitlab operations environment', example: 'production' }], desc: 'get a shortlog of changes between head and the specified environment')
19
25
  def deployment_shortlog(environment)
20
26
  dep = RoboPigeon::GitLab::Client.get_deployment(environment)
@@ -27,17 +33,25 @@ module RoboPigeon::Dsl
27
33
  dep.deployable.finished_at
28
34
  end
29
35
 
30
- RoboPigeon::Documentarian.add_command('deployment_git_log_jira_tickets',
31
- block: ['helpers'],
32
- params: [
33
- { name: 'environment', type: 'String', desc: 'the name of a gitlab operations environment', example: 'production' },
34
- { name: 'project_key', type: 'String', desc: 'the project key to search history for', example: 'TIC' }
35
- ],
36
- desc: 'returns a list of jira tickets for the given project key in history since the deployment')
37
- def tickets_in_log_since_deployment_to(environment, _project)
36
+ RoboPigeon::Documentarian.add_command('environment_link', block: ['helpers'], params: [{ name: 'environment', type: 'String', desc: 'the name of a gitlab operations environment', example: 'production' }], desc: 'get a link to the environment by name')
37
+ def environment_link(environment)
38
+ dep = RoboPigeon::GitLab::Client.get_deployment(environment)
39
+ "#{ENV['CI_PROJECT_URL']}/environments/#{dep.environment.id}"
40
+ end
41
+
42
+ RoboPigeon::Documentarian.add_command(
43
+ 'deployment_git_log_jira_tickets',
44
+ block: ['helpers'],
45
+ params: [
46
+ { name: 'environment', type: 'String', desc: 'the name of a gitlab operations environment', example: 'production' },
47
+ { name: 'project_key', type: 'String', desc: 'the project key to search history for', example: 'TIC' }
48
+ ],
49
+ desc: 'returns a list of jira tickets for the given project key in history since the deployment'
50
+ )
51
+ def tickets_in_log_since_deployment_to(environment, matcher=/[A-Za-z]+-\d+/)
38
52
  dep = RoboPigeon::GitLab::Client.get_deployment(environment)
39
53
  log = `git log #{dep.sha}..`
40
- log.scan(/[A-Za-z]+-\d+/)
54
+ log.scan(matcher)
41
55
  end
42
56
  end
43
57
  end
@@ -2,6 +2,7 @@ module RoboPigeon::Jira
2
2
  class Client
3
3
  @enabled = true
4
4
  @api_key = ENV['JIRA_TOKEN']
5
+ @last_created_ticket = File.read('last_created_jira_ticket') if File.exist?('last_created_jira_ticket')
5
6
 
6
7
  class << self
7
8
  attr_accessor :api_key, :api_url, :enabled, :last_created_ticket
@@ -49,6 +49,7 @@ module RoboPigeon::Jira
49
49
  begin
50
50
  self.ticket = JSON.parse(response.body).fetch('key')
51
51
  RoboPigeon::Jira::Client.last_created_ticket = ticket
52
+ File.write('last_created_jira_ticket', ticket)
52
53
  rescue KeyError
53
54
  raise RoboPigeon::Jira::RequiredFieldNotSet, "Response from JIRA did not contain new issue key: #{response.body}"
54
55
  end
@@ -80,10 +81,6 @@ module RoboPigeon::Jira
80
81
  self.reporter = user['name']
81
82
  end
82
83
 
83
- def description_from_template(_file)
84
- self.description = 'Content from an erb template'
85
- end
86
-
87
84
  def set_field(name, value)
88
85
  require_field(:issue_type)
89
86
  request_path = "#{ISSUE_PATH}/createmeta?projectKeys=#{project}&expand=projects.issuetypes.fields"
data/robopigeon.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  # Specify which files should be added to the gem when it is released.
27
27
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
28
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + ['spec/initial_robopigeon_spec.rb']
30
30
  end
31
31
  spec.bindir = 'exe'
32
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'robopigeon'
3
+
4
+ describe 'robopigeon.rb file' do
5
+ subject { RoboPigeon::Dsl::Root.new }
6
+ context 'version' do
7
+ it 'should print the verison to standard out' do
8
+ expect { subject.run('version') }.to output(RoboPigeon::VERSION).to_stdout
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: robopigeon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Ives
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-29 00:00:00.000000000 Z
11
+ date: 2019-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -268,13 +268,13 @@ files:
268
268
  - lib/robopigeon/extend/templates/default/.gitlab-ci.yml
269
269
  - lib/robopigeon/extend/templates/default/.rubocop.yml
270
270
  - lib/robopigeon/extend/templates/default/.version
271
- - lib/robopigeon/extend/templates/default/Gemfile
271
+ - lib/robopigeon/extend/templates/default/Gemfile.erb
272
272
  - lib/robopigeon/extend/templates/default/README.erb.md
273
- - lib/robopigeon/extend/templates/default/lib/robopigeon-extension.erb.rb
274
- - lib/robopigeon/extend/templates/default/lib/robopigeon-extension/dsl.erb.rb
275
- - lib/robopigeon/extend/templates/default/lib/robopigeon-extension/helper_dsl.erb.rb
276
- - lib/robopigeon/extend/templates/default/lib/robopigeon-extension/version.erb.rb
277
- - lib/robopigeon/extend/templates/default/robopigeon-extension.erb.gemspec
273
+ - lib/robopigeon/extend/templates/default/lib/robopigeon_extension.erb.rb
274
+ - lib/robopigeon/extend/templates/default/lib/robopigeon_extension/dsl.erb.rb
275
+ - lib/robopigeon/extend/templates/default/lib/robopigeon_extension/helper_dsl.erb.rb
276
+ - lib/robopigeon/extend/templates/default/lib/robopigeon_extension/version.erb.rb
277
+ - lib/robopigeon/extend/templates/default/robopigeon_extension.erb.gemspec
278
278
  - lib/robopigeon/extend/templates/default/spec/robopigeon-extension/dsl_spec.erb.rb
279
279
  - lib/robopigeon/extend/templates/default/spec/robopigeon-extension/helper_dsl_spec.erb.rb
280
280
  - lib/robopigeon/extend/templates/default/spec/spec_helper.erb.rb
@@ -310,6 +310,7 @@ files:
310
310
  - robopigeon
311
311
  - robopigeon.gemspec
312
312
  - robopigeon.rb
313
+ - spec/initial_robopigeon_spec.rb
313
314
  homepage: https://gitlab.com/pigeons/robopigeon
314
315
  licenses:
315
316
  - MIT