robopigeon 0.2.0 → 0.3.0
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 +4 -4
- data/.version +1 -1
- data/CHANGELOG.md +13 -0
- data/README.md +5 -2
- data/lib/robopigeon/dsl/initial_jobs.rb +4 -0
- data/lib/robopigeon/extend/template.rb +1 -1
- data/lib/robopigeon/extend/templates/default/{Gemfile → Gemfile.erb} +3 -1
- data/lib/robopigeon/extend/templates/default/README.erb.md +4 -4
- data/lib/robopigeon/extend/templates/default/lib/{robopigeon-extension → robopigeon_extension}/dsl.erb.rb +0 -0
- data/lib/robopigeon/extend/templates/default/lib/{robopigeon-extension → robopigeon_extension}/helper_dsl.erb.rb +0 -0
- data/lib/robopigeon/extend/templates/default/lib/{robopigeon-extension → robopigeon_extension}/version.erb.rb +0 -0
- data/lib/robopigeon/extend/templates/default/lib/{robopigeon-extension.erb.rb → robopigeon_extension.erb.rb} +3 -3
- data/lib/robopigeon/extend/templates/default/{robopigeon-extension.erb.gemspec → robopigeon_extension.erb.gemspec} +2 -2
- data/lib/robopigeon/extend/templates/default/spec/spec_helper.erb.rb +1 -1
- data/lib/robopigeon/git/helper_dsl.rb +13 -0
- data/lib/robopigeon/gitlab/helper_dsl.rb +23 -9
- data/lib/robopigeon/jira/client.rb +1 -0
- data/lib/robopigeon/jira/ticket.rb +1 -4
- data/robopigeon.gemspec +1 -1
- data/spec/initial_robopigeon_spec.rb +11 -0
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25d50f00dc30aa78bd9389cee8da7d93aa04920e4db5c10433f39c2df4d97b0f
|
4
|
+
data.tar.gz: c0f86cfe9dc63bb753d4ee5e88cfe16512fce547fcdb649ffe4776282c3162dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f980108a24e6e081f073e9747efca1fcb4cb14f776aa911cb4a60c769529401abf140b0f09de6c68208f1d78dde56a6ea8f8ae899b8ab3d943676be34bf8a80
|
7
|
+
data.tar.gz: 94b3b6a2f9631eb610ddfb2bf13fc8f885d3962d65a5dbdcfeb7c56ad44bbdf25d298db7fdf7b08ad9b3cd463cabc65a9c88c3310fd7a0b3a21960be94af7e0e
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
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}/
|
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|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# RoboPigeon
|
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 '
|
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
|
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}/
|
35
|
+
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/{gitlab_username}/robopigeon_<%= extension_name_lower %>.
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
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 '
|
3
|
+
require 'robopigeon_<%= extension_name_lower %>/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name = '
|
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 %>']
|
@@ -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('
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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(
|
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.
|
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-
|
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/
|
274
|
-
- lib/robopigeon/extend/templates/default/lib/
|
275
|
-
- lib/robopigeon/extend/templates/default/lib/
|
276
|
-
- lib/robopigeon/extend/templates/default/lib/
|
277
|
-
- lib/robopigeon/extend/templates/default/
|
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
|