CiHelper 0.0.2 → 1.0.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/lib/ci_helper/bitbucket_procedure.rb +41 -28
- data/lib/ci_helper/ci_procedure.rb +29 -15
- data/lib/ci_helper/constants.rb +8 -6
- data/lib/ci_helper/issue_monitor.rb +12 -10
- data/lib/ci_helper/main_process.rb +14 -9
- data/lib/ci_helper/user_intercation_interface.rb +0 -0
- data/lib/ci_helper/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 552b3f86b048155b318564a7c0f8f1a0d7f29d99
|
4
|
+
data.tar.gz: 021e1fc98fd6f9cc251d3c7b952020c3f93cddac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80f619e46206226cef2be4f7c31ebc2c2cbd1f298a67b56ec553b0ced50de685a6a927c475724547c64592ed9c8d4c0b3626c07843e1cc01cd6559c237fd44c7
|
7
|
+
data.tar.gz: eaf0311b741bf17c71505d1e9dbf3d8efc15248b8a76279850c9fb54558cb4e83349facb1b08fadf804c8721b0a843f09617645f56b41148679ae96ea057f607
|
@@ -1,57 +1,70 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
class BitBucketProcedure
|
4
|
-
BIT_BUCKET_LOGIN_URL = 'https://bitbucket.org/account/signin/'
|
5
|
-
REDMINE_DOMAIN = 'http://redmine.raamsys.co.uk/issues/'
|
2
|
+
BIT_BUCKET_LOGIN_URL = 'https://bitbucket.org/account/signin/'
|
6
3
|
|
7
|
-
attr_reader :account, :password, :client
|
4
|
+
attr_reader :account, :password, :client, :destination, :user_description, :title
|
5
|
+
attr_reader :pull_request_page, :repository_page
|
8
6
|
|
9
7
|
def initialize(account, password)
|
10
8
|
@account = account
|
11
9
|
@password = password
|
12
|
-
@client
|
10
|
+
@client = Mechanize.new
|
13
11
|
end
|
14
12
|
|
15
13
|
def create_pull_request(result)
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
login
|
15
|
+
go_to_repo_page
|
16
|
+
go_to_pull_request_page
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
request_form.field_with(name: 'dest').options.select { |option| option.text == 'develop'}.first.select
|
23
|
-
request_form.field_with(name: 'source').options.select { |option| option.text == result.issue_number }.first.select
|
18
|
+
create_pull_requcest_page = pull_request_page.link_with(href: '/vansys/vansys/pull-request/new').click
|
19
|
+
redirect_page = create_pull_request_page.form_with(action: '/vansys/vansys/pull-request/new') do |request_form|
|
24
20
|
|
21
|
+
request_form.field_with(name: 'title').value = "issue number #{result.issue_number.to_s} auto create pull request "
|
22
|
+
request_form.field_with(name: 'dest').options.select { |option| option.text == destination.to_s }.first.select
|
23
|
+
request_form.field_with(name: 'source').options.select { |option| option.text == result.branch_name }.first.select
|
24
|
+
description = request_form.field_with(name: 'description')
|
25
|
+
description.value = "1. #{CiHelper::REDMINE_DOMAIN}#{result.issue_number.delete('t')}\n"
|
26
|
+
description.value += "2. #{result.console_link} \n"
|
27
|
+
description.value += "```\n"
|
28
|
+
description.value += "#!ruby \n"
|
25
29
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
description.value += "```\n"
|
30
|
-
description.value += "#!ruby \n"
|
30
|
+
result.failures.each do |failure|
|
31
|
+
description.value += "#{failure.to_s}\n"
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
description.value += "#{failure.to_s}\n"
|
34
|
-
end
|
34
|
+
description.value += "```\n"
|
35
35
|
|
36
|
-
|
37
|
-
|
36
|
+
description.value += user_description
|
37
|
+
end.click_button
|
38
|
+
redirect_page
|
39
|
+
end
|
38
40
|
|
41
|
+
def add_destination(destination)
|
42
|
+
@destination = destination
|
39
43
|
end
|
40
44
|
|
41
|
-
|
45
|
+
def add_user_description(description)
|
46
|
+
@user_description = description
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_pf_title(title)
|
50
|
+
@title = title
|
51
|
+
end
|
42
52
|
|
43
53
|
def login
|
44
54
|
login_page = client.get(BIT_BUCKET_LOGIN_URL)
|
45
55
|
|
46
|
-
response_page = login_page.form_with(action: '/account/signin/') do |f|
|
56
|
+
@response_page = login_page.form_with(action: '/account/signin/') do |f|
|
47
57
|
f.field_with(name: 'username').value = account
|
48
58
|
f.field_with(name: 'password').value = password
|
49
59
|
end.click_button
|
60
|
+
end
|
50
61
|
|
51
|
-
|
52
|
-
|
62
|
+
def go_to_repo_page
|
63
|
+
@repository_page = @response_page.link_with(href: '/vansys/vansys').click
|
64
|
+
end
|
53
65
|
|
54
|
-
|
66
|
+
def go_to_pull_request_page
|
67
|
+
@pull_request_page = repository_page.link_with(href: '/vansys/vansys/pull-requests').click
|
55
68
|
end
|
56
69
|
end
|
57
70
|
|
@@ -1,22 +1,23 @@
|
|
1
|
-
# this class hardcoding the procedure to the result page
|
2
|
-
|
3
1
|
require 'mechanize'
|
4
2
|
|
5
|
-
|
6
3
|
class CiProcedure
|
4
|
+
# this class hardcoding the procedure to the result page
|
7
5
|
|
8
6
|
CI_LOGIN_URL = 'http://ci.raamsys.co.uk/login?from=%2F'
|
9
7
|
CI_DOMAIN = 'http://ci.raamsys.co.uk/'
|
10
8
|
attr_accessor :result, :issue_page
|
11
|
-
attr_reader :account, :password, :mechanize,
|
9
|
+
attr_reader :account, :password, :mechanize,
|
10
|
+
:console_page, :raam_page, :main_page,
|
11
|
+
:matching_strategy
|
12
|
+
|
12
13
|
|
13
14
|
Result = Struct.new(:status, :failures)
|
14
15
|
|
15
|
-
def initialize(account, password,
|
16
|
-
@account
|
17
|
-
@password
|
18
|
-
@
|
19
|
-
@
|
16
|
+
def initialize(account, password, matching_strategy)
|
17
|
+
@account = account
|
18
|
+
@password = password
|
19
|
+
@matching_strategy = matching_strategy
|
20
|
+
@mechanize = Mechanize.new
|
20
21
|
end
|
21
22
|
|
22
23
|
def run
|
@@ -27,7 +28,8 @@ class CiProcedure
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def re_get_console_output
|
30
|
-
@issue_page
|
31
|
+
@issue_page = go_to_issue
|
32
|
+
@console_page = go_to_console_output
|
31
33
|
get_console_output
|
32
34
|
end
|
33
35
|
|
@@ -35,6 +37,18 @@ class CiProcedure
|
|
35
37
|
console_page.search("pre.console-output").text.split("\n")
|
36
38
|
end
|
37
39
|
|
40
|
+
def issue_number
|
41
|
+
branch_name[1..4]
|
42
|
+
end
|
43
|
+
|
44
|
+
def branch_name
|
45
|
+
issue_link.text.split(' ')[1]
|
46
|
+
end
|
47
|
+
|
48
|
+
def commit_hash
|
49
|
+
issue_link.text.split(' ')[2]
|
50
|
+
end
|
51
|
+
|
38
52
|
private
|
39
53
|
|
40
54
|
def login
|
@@ -58,17 +72,17 @@ class CiProcedure
|
|
58
72
|
end
|
59
73
|
|
60
74
|
def go_to_issue
|
61
|
-
|
62
|
-
|
63
|
-
link.click
|
75
|
+
fail CiHelper::Exceptions::IssueNotFound, 'you may be enter wrong ticket number ' unless issue_link
|
76
|
+
issue_link.click
|
64
77
|
end
|
65
78
|
|
66
79
|
def go_to_console_output
|
67
80
|
issue_page ? issue_page.link_with(text: 'Console Output').click : false
|
68
81
|
end
|
69
82
|
|
70
|
-
def
|
71
|
-
links
|
83
|
+
def issue_link
|
84
|
+
links = raam_page.links
|
85
|
+
@link ||= links.select { |link| link.text.match(matching_strategy) }.first
|
72
86
|
end
|
73
87
|
end
|
74
88
|
|
data/lib/ci_helper/constants.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module CiHelper
|
2
|
-
HOME
|
2
|
+
HOME = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
3
3
|
CONFIG_FILE_NAME = '.ci_helper_config.yml'
|
4
4
|
# HOOK_DIRECTORY = File.join(HOME, 'lib', 'overcommit', 'hook')
|
5
|
-
REPO_URL
|
6
|
-
BUG_REPORT_URL
|
7
|
-
WAITING_TIME
|
8
|
-
HELLO_MSG
|
5
|
+
REPO_URL = 'https://github.com/alan2112000/ci_helper'
|
6
|
+
BUG_REPORT_URL = "#{REPO_URL}/issues"
|
7
|
+
WAITING_TIME = 60
|
8
|
+
HELLO_MSG = "Hello Everybody, Congratulation You finished a issue,
|
9
9
|
unfortunately you need to pass the ci and you can get a UT passed >.^ '\n"
|
10
|
-
CI_URL
|
10
|
+
CI_URL = 'http://ci.raamsys.co.uk/job/RAAM/'
|
11
|
+
REDMINE_DOMAIN = 'http://redmine.raamsys.co.uk/issues/'
|
12
|
+
BITBUCKET_DOMAIN = 'https://bitbucket.org'
|
11
13
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
class IssueMonitor
|
2
2
|
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :issue_status
|
4
4
|
attr_reader :fail_examples, :ci_procedure, :result, :status
|
5
5
|
|
6
|
-
Result = Struct.new(:status, :failures,
|
6
|
+
Result = Struct.new(:status, :failures,
|
7
|
+
:console_link, :issue_number,
|
8
|
+
:branch_name, :commit_hash)
|
7
9
|
|
8
|
-
def initialize(account, password,
|
9
|
-
@
|
10
|
-
@ci_procedure = CiProcedure.new(account, password, ticked_number)
|
10
|
+
def initialize(account, password, match_strategy)
|
11
|
+
@ci_procedure = CiProcedure.new(account, password, match_strategy)
|
11
12
|
end
|
12
13
|
|
13
14
|
def goto_monitor_page
|
@@ -29,8 +30,8 @@ class IssueMonitor
|
|
29
30
|
|
30
31
|
def finish_test?
|
31
32
|
begin
|
32
|
-
|
33
|
-
|
33
|
+
output = ci_procedure.re_get_console_output
|
34
|
+
output.empty? ? false : true
|
34
35
|
rescue CiHelper::Exception::IssueNotFound => e
|
35
36
|
puts "#{e.message} #{issue_number}"
|
36
37
|
false
|
@@ -42,7 +43,9 @@ class IssueMonitor
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def content
|
45
|
-
Result.new(success?, fail_examples,
|
46
|
+
Result.new(success?, fail_examples,
|
47
|
+
"#{ci_procedure.console_page.uri.host}/#{ci_procedure.console_page.uri.request_uri}", ci_procedure.issue_number,
|
48
|
+
ci_procedure.branch_name, ci_procedure.commit_hash)
|
46
49
|
end
|
47
50
|
|
48
51
|
private
|
@@ -55,7 +58,7 @@ class IssueMonitor
|
|
55
58
|
|
56
59
|
console_output.each_index do |index|
|
57
60
|
|
58
|
-
if
|
61
|
+
if console_output[index].match('Finished in')
|
59
62
|
start_index = index
|
60
63
|
elsif console_output[index].match('Failed examples:')
|
61
64
|
fail_example_start_index = index
|
@@ -64,7 +67,6 @@ class IssueMonitor
|
|
64
67
|
elsif console_output[index].match('Finished: ')
|
65
68
|
result_index = index
|
66
69
|
end
|
67
|
-
|
68
70
|
end
|
69
71
|
|
70
72
|
@status = console_output[start_index, start_index + 1]
|
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
|
3
|
-
require_relative 'bitbucket_procedure'
|
4
|
-
|
2
|
+
require 'byebug'
|
5
3
|
# TODO: need to refactor this class
|
6
4
|
class MainProcess
|
7
5
|
|
@@ -19,10 +17,9 @@ class MainProcess
|
|
19
17
|
puts CiHelper::HELLO_MSG
|
20
18
|
while true
|
21
19
|
@issue_is_queued_in_ci = false
|
22
|
-
puts 'Please Input your next ticked number '
|
23
|
-
|
24
|
-
issue_monitor = IssueMonitor.new(config.ci_ac, config.ci_pass,
|
25
|
-
|
20
|
+
puts 'Please Input your next ticked number or commit hash to specifiy the multi test result in the CI'
|
21
|
+
match_strategy = gets.chop
|
22
|
+
issue_monitor = IssueMonitor.new(config.ci_ac, config.ci_pass, match_strategy)
|
26
23
|
|
27
24
|
unless issue_monitor.goto_monitor_page # no issue pull request found
|
28
25
|
# ask user to wait this issue or not
|
@@ -57,9 +54,17 @@ class MainProcess
|
|
57
54
|
user_input = gets.chop
|
58
55
|
if user_input == 'y' || user_input == 'Y'
|
59
56
|
bit_bucket_client = BitBucketProcedure.new(config.bit_ac, config.bit_pass)
|
57
|
+
puts 'Please Provide the destination'
|
58
|
+
destination = gets.chop
|
59
|
+
puts 'Please Provide the more description you want add in the text box'
|
60
|
+
user_description =gets.chop
|
61
|
+
bit_bucket_client.add_destination(destination)
|
62
|
+
bit_bucket_client.add_user_description(user_description)
|
60
63
|
bit_bucket_client.create_pull_request(issue_monitor.content)
|
61
|
-
|
62
|
-
|
64
|
+
sleep(0.5)
|
65
|
+
bit_bucket_client.go_to_pull_request_page
|
66
|
+
sleep(0.5)
|
67
|
+
puts "this is your pull request page : #{CiHelper::BITBUCKET_DOMAIN}#{bit_bucket_client.pull_request_page.link_with(class: 'execute').href}"
|
63
68
|
end
|
64
69
|
end
|
65
70
|
end
|
File without changes
|
data/lib/ci_helper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: CiHelper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alan Yu
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.7
|
19
|
+
version: '2.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.7
|
26
|
+
version: '2.7'
|
27
27
|
description: In house tool only for JCM team
|
28
28
|
email: alan21120000@gmail.com
|
29
29
|
executables:
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- lib/ci_helper/redmine_procedure.rb
|
46
46
|
- lib/ci_helper/result_parser.rb
|
47
47
|
- lib/ci_helper/user_command_line_interface.rb
|
48
|
+
- lib/ci_helper/user_intercation_interface.rb
|
48
49
|
- lib/ci_helper/utils.rb
|
49
50
|
- lib/ci_helper/version.rb
|
50
51
|
homepage: http://rubygems.org/gems/ci_helper
|