tutter-jenkins 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 +15 -0
- data/.gemspec +16 -0
- data/README.md +16 -0
- data/lib/tutter/action/jenkins.rb +48 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NzdiODU5OTQ1OTM2ZDU2NmYwZGU4YzFkOWQyYjBiMTUyOWZjMjI3YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NmExMTg2YTE3NjczZmUzMDVmNWIwZjZlYWRlMTJjMWYzMDk0MDUwYw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2U4ZWNhNTc2Zjk5MDI4ZmQzN2QwMzlhOTdkMDgxYWVlMDAzNDA5Mzk0MmIx
|
10
|
+
NjZmYzcyMDBkMTU2YzI2ZDgwNjUyYWYwNDk0MTQxMWFlNDEyZGQ4MGI4OWRm
|
11
|
+
MDZjZGMwYTBhMjZiNGI1MTlhNmQ3ZGY1MTgwMmUyOThiNzY1ZmI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OTZjMmEyZDY4MGIyNTU3ZmNlYzRmMmQyN2M5ZGM5MzliZTAwMzg4M2ViM2Yw
|
14
|
+
YmU0ZThkOGI3YjM4MzZiNzc5MTNlMTY3ZmEwZjg4NzlmMTExMTBmYTE4MWYx
|
15
|
+
OWI5NzhkYTUyNzk2ZTBjMDEzMzFlMzFhZDhhMDkxMGIzZTk2YWI=
|
data/.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = 'tutter-jenkins'
|
4
|
+
s.version = '0.0.1'
|
5
|
+
s.author = 'Alexey Lapitsky'
|
6
|
+
s.email = ['alexey@spotify.com']
|
7
|
+
s.homepage = 'https://ghe.spotify.net/io/tutter-jenkins'
|
8
|
+
s.summary = 'Merges pull requests if tests PASS'
|
9
|
+
s.description = 'This tutter action let non collaborators review and merge code without having more then read access to the project'
|
10
|
+
s.license = 'Apache 2.0'
|
11
|
+
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.require_paths = ['lib']
|
14
|
+
|
15
|
+
s.required_ruby_version = '>= 1.8.7'
|
16
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# tutter-jenkins
|
2
|
+
|
3
|
+
This action let non collaborators review
|
4
|
+
and merge code without having more then read access to the project.
|
5
|
+
|
6
|
+
1. A pull request get submitted
|
7
|
+
2. Jenkins runs the tests, comments "Test PASSed."
|
8
|
+
3. The pull request can be merged by commenting "merge, my change is covered by tests"
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
gem install tutter-jenkins
|
13
|
+
|
14
|
+
jenkins specific settings (goes into tutter.yaml)
|
15
|
+
|
16
|
+
action: 'jenkins'
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Jenkins
|
2
|
+
def initialize(settings, client, project, data)
|
3
|
+
@settings = settings
|
4
|
+
@client = client
|
5
|
+
@project = project
|
6
|
+
@data = data
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
pull_request_id = @data['issue']['number']
|
11
|
+
puts "pull request id: #{pull_request_id}"
|
12
|
+
pr = @client.pull_request @project, pull_request_id
|
13
|
+
|
14
|
+
if pr.mergeable_state != 'clean'
|
15
|
+
puts "merge state for #{@project} #{pull_request_id} is not clean. Current state: #{pr.mergeable_state}"
|
16
|
+
return false
|
17
|
+
end
|
18
|
+
|
19
|
+
# No comments, no need to go further.
|
20
|
+
if pr.comments == 0
|
21
|
+
puts 'no comments, skipping'
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
|
25
|
+
# Don't care about code we can't merge
|
26
|
+
unless pr.mergeable
|
27
|
+
puts 'not mergeable, skipping'
|
28
|
+
return false
|
29
|
+
end
|
30
|
+
|
31
|
+
# We fetch the latest commit and it's date.
|
32
|
+
last_commit = @client.pull_request_commits(@project, pull_request_id).last
|
33
|
+
last_commit_date = last_commit.commit.committer.date
|
34
|
+
|
35
|
+
comments = @client.issue_comments(@project, pull_request_id)
|
36
|
+
jenkins_last_comment = @client.issue_comments(@project, pull_request_id).select{|c| c.attrs[:user].attrs[:login] == 'jenkins'}.last
|
37
|
+
jenkins_allows_merge = jenkins_last_comment && jenkins_last_comment.body =~ /PASS/
|
38
|
+
|
39
|
+
if jenkins_allows_merge
|
40
|
+
puts "the last comment from jenkins allows the merge"
|
41
|
+
last_comment = comments.last
|
42
|
+
if last_comment.created_at > last_commit_date && last_comment.body.strip.downcase == 'merge, my change is covered by tests'
|
43
|
+
puts "merging #{pull_request_id} #{@project}"
|
44
|
+
@client.merge_pull_request(@project, pull_request_id, 'ok, shipping!')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tutter-jenkins
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexey Lapitsky
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This tutter action let non collaborators review and merge code without
|
14
|
+
having more then read access to the project
|
15
|
+
email:
|
16
|
+
- alexey@spotify.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gemspec
|
22
|
+
- README.md
|
23
|
+
- lib/tutter/action/jenkins.rb
|
24
|
+
homepage: https://ghe.spotify.net/io/tutter-jenkins
|
25
|
+
licenses:
|
26
|
+
- Apache 2.0
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.8.7
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.0.3
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Merges pull requests if tests PASS
|
48
|
+
test_files: []
|
49
|
+
has_rdoc:
|