mutx 0.2.7 → 0.2.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f41948713cc0c2ab88b659a0acfccef31685804f
4
- data.tar.gz: 866f09627bb94a865d037880282c1f76128df502
3
+ metadata.gz: 53dd9362c79dd087f0f3342128442c859d9fa8a5
4
+ data.tar.gz: 6fbbf9e0df11754f8c02f552307f835b911ccc58
5
5
  SHA512:
6
- metadata.gz: e58c8804ca6e125362a4005b59a78f83e9d4e1a5b2ce66da2911ebbae23ee3b7e1241081fa7cf40c3f5e5a4f660b1c47d07916afb0fde9a07dcf90bfeaaa4cbd
7
- data.tar.gz: 8b556913a4cf8e004a6578fe75c461d24f312952904ac360dbf91027c7d2acf1d11c388744af51aabb83f9a3f30c63d0c8479f36b91e683ead1e6aa210eaa0fd
6
+ metadata.gz: c3447515919f113d8dca7459be9213174710946a8ec48cc4918f4c9bae28db2ef46b578a0b87770004c8096b5c840fbefe510b0b908e1e9d5d0ffe14973a31b6
7
+ data.tar.gz: d9e63d688b45699cb8f61fb9ba6c1144e480a92cb65600a77094b073e3b06cba06f6687fa30c0f817337b4ebdebd6683e369e1064411ecf37019b953a4021f44
@@ -47,7 +47,7 @@
47
47
  "recipients" : "your@email.com",
48
48
  "smtp_enable_start_tls_auto" : true,
49
49
  "attach_report" : false,
50
- "telegram_token" => null
50
+ "telegram_token" : null
51
51
  },
52
52
 
53
53
  "footer_text" : "The text to display on footer",
@@ -7,4 +7,4 @@ include Mutx::Alert::Script
7
7
 
8
8
  # put your code here!
9
9
 
10
- # write success! warning! or critical! to finish script
10
+ # write ok! warning! or critical! to finish script
@@ -23,27 +23,8 @@ Encoding.default_internal = Encoding::UTF_8
23
23
 
24
24
  module Mutx
25
25
 
26
-
27
- # if Dir.exist? "#{Dir.pwd}/mutx/logs"
28
-
29
- # # Creates mutx_log if it does not exist
30
- # File.open("#{Dir.pwd}/mutx/logs/mutx.log","a+"){} unless File.exist? "#{Dir.pwd}/mutx/logs/mutx.log"
31
-
32
- # # Set global conf
33
- # #Mutx::Support::Log.start
34
- # Mutx::Support::Configuration.get
35
- # $NOTIF ||= Support::Notification.new("#{Dir.pwd.split("/").last}", "#{Mutx::Support::IfConfig.ip}:#{Mutx::Support::Configuration.port}")
36
-
37
- # end
38
-
39
-
40
26
  class Base < Thor
41
27
 
42
- desc "help","If you cannot start mutx"
43
- def help
44
- Mutx::Commands.help
45
- end
46
-
47
28
  desc "install","Install Mutx on your project"
48
29
  def install
49
30
  Mutx::Commands.install
@@ -18,17 +18,15 @@ module Mutx
18
18
  stdout.each do |line|
19
19
  stringio.puts line
20
20
  end
21
- rescue Errno::EIO => e
22
- stringio.puts e.message
23
- stringio.puts e.backtrace
21
+ rescue Errno::EIO
24
22
  ensure
25
23
  Process.wait pid
26
24
  status = $?.exitstatus
27
25
  end
28
26
  end
29
27
  rescue => e
30
- stringio.puts e.message
31
- stringio.puts e.backtrace
28
+ puts e.message
29
+ puts e.backtrace
32
30
  raise e
33
31
  ensure
34
32
  @alert.update_status(status, info: stringio.string)
@@ -12,14 +12,8 @@ module Mutx
12
12
  - stop
13
13
  - restart
14
14
  - reset
15
-
16
- Note: If you stop mutx and then you want to get it up and the port you are using is already in use
17
- you could use the following commands (Ubunutu OS):
18
-
19
- $sudo netstat -tapen | grep :8080
20
-
21
- In this example we use the port 8080. This command will give you the app that is using the port.
22
- Then you could kill it getting its PID previously."
15
+ - create_alert
16
+ "
23
17
  end
24
18
  end
25
19
  end
@@ -7,7 +7,7 @@ module Mutx
7
7
  pids = (Mutx::Support::Processes.sidekiq_pids).concat(Mutx::Support::Processes.mutx_pids)
8
8
 
9
9
  if pids.size > 0
10
- puts "It seems that MuTX is already running. pids found [#{pids}]"
10
+ puts "It seems that MuTX is already running. pids found #{pids}"
11
11
  puts "Please, run `mutx stop` command before starting MuTX"
12
12
  else
13
13
  Mutx::Support::Log.start
@@ -20,10 +20,10 @@ module Mutx
20
20
  Mutx::Support::Log.debug "Starting...\n\n#{Mutx::Support::Logo.logo}" if Mutx::Support::Log
21
21
 
22
22
  Mutx::Support::Log.debug "Checking config.ru file existance" if Mutx::Support::Log
23
- raise "ERROR --- mutx/config.ru file was not found. Try with `mutx prepare` command before `mutx start`" unless File.exist?("#{Dir.pwd}/mutx/config.ru")
23
+ raise "ERROR --- mutx/config.ru file was not found.`" unless File.exist?("#{Dir.pwd}/mutx/config.ru")
24
24
 
25
25
  Mutx::Support::Log.debug "Checking unicorn.rb file existance" if Mutx::Support::Log
26
- raise "ERROR --- mutx/unicorn.rb file was not found. Try with `mutx prepare` command before `mutx start`" unless File.exist?("#{Dir.pwd}/mutx/unicorn.rb")
26
+ raise "ERROR --- mutx/unicorn.rb file was not found." unless File.exist?("#{Dir.pwd}/mutx/unicorn.rb")
27
27
 
28
28
  Mutx::Support::Logo.show
29
29
 
@@ -49,7 +49,7 @@ module Mutx
49
49
  end
50
50
  rescue
51
51
  # if mac, show option
52
- puts "Not Ubuntu OS :(\n xvfb will not work"
52
+ puts "Not Ubuntu OS...xvfb will not work"
53
53
  end
54
54
  end
55
55
 
@@ -100,17 +100,10 @@ module Mutx
100
100
  Mutx::Support::Log.debug "Mutx PIDs saved" if Mutx::Support::Log
101
101
  Dir.mkdir "#{Dir.pwd}/mutx/out" unless Dir.exist? "#{Dir.pwd}/mutx/out"
102
102
  puts "\n\n* Mutx is succesfully Started!\n".green
103
- if $IP_ADDRESS
104
- puts "\n\n You can go now to http://#{$IP_ADDRESS}:#{Mutx::Support::Configuration.port}/mutx\n\n"
105
- Mutx::Support::Log.debug "You can go now to http://#{$IP_ADDRESS}:#{Mutx::Support::Configuration.port}/mutx" if Mutx::Support::Log
106
- end
107
103
 
108
- ##Mutx::Database::MongoConnector.force_close
109
-
110
104
  rescue => e
111
105
  Mutx::Support::Log.error "Error starting Mutx: #{e}#{e.backtrace}" if Mutx::Support::Log
112
106
  puts "An error ocurred while starting Mutx. See mutx log for more information.#{e} #{e.backtrace}".red
113
- ##Mutx::Database::MongoConnector.force_close
114
107
  end
115
108
  end
116
109
  end
@@ -192,6 +192,20 @@ module Mutx
192
192
  $commits.insert_one({"_id" => self.generate_id, "log" => commit_info})
193
193
  end
194
194
 
195
+ def self.before_last_commit_webhook
196
+ data = $commits.find({}).to_a || []
197
+ unless data.empty?
198
+ data[data.size - 2]
199
+ end
200
+ end
201
+
202
+ def self.last_commit_webhook
203
+ data = $commits.find({}).to_a || []
204
+ unless data.empty?
205
+ data.last
206
+ end
207
+ end
208
+
195
209
  # Returns last saved commit info
196
210
  # $return [Hash] if exist
197
211
  def self.last_commit
@@ -168,8 +168,7 @@ module Mutx
168
168
 
169
169
  def notify_telegram(group_id, info)
170
170
  return unless group_id
171
- Notification.send_telegram(group_id, message: "Alert #{name} is #{status.upcase}")
172
- Notification.send_telegram(group_id, message: info)
171
+ Notification.send_telegram(group_id, message: "Alert *#{name}* is *#{status.upcase}*\n#{info}")
173
172
  end
174
173
 
175
174
  def notify_email(mail_to, info)
@@ -48,19 +48,6 @@ module Mutx
48
48
  on('message') { run Mutx::Routes::Message::Routes }
49
49
  on('help') { run Mutx::Routes::Help::Routes }
50
50
 
51
- on post do
52
- on "pull" do
53
- #Check for updates on the branch and make a pull if its outdated
54
- ##Mutx::Support::Git.pull unless Mutx::Support::Git.up_to_date?
55
- data_json = JSON.parse req.body.read
56
- Mutx::Support::ChangeInspector.is_there_a_change?
57
- Mutx::Support::Log.debug "#{data_json}" if Mutx::Support::Log
58
- Mutx::Support::Bundle.new.bundle_update if data_json["repository"]["language"].eql? "Ruby"
59
- res.status = 200
60
- res.write "status 200"
61
- end
62
- end
63
-
64
51
  on get do
65
52
  on "logout" do
66
53
  $result = nil
@@ -74,9 +61,7 @@ module Mutx
74
61
  $result = false
75
62
  res.redirect "http://user@mutx.garba.ninja/"
76
63
  end
77
- end
78
-
79
-
64
+ end
80
65
 
81
66
  on "screenshot/:file_name" do |file_name|
82
67
  template = Mote.parse(File.read("#{Mutx::View.path}/screenshot.mote"),self, [:file_name])
@@ -9,6 +9,7 @@ module Mutx
9
9
 
10
10
  on('input') { run Api::Input::Routes }
11
11
  on('repositories') { run Api::Repositories::Routes }
12
+ on('git') { run Api::Git::Routes }
12
13
  on('results') { run Api::Results::Routes }
13
14
  on('tasks') { run Api::Tasks::Routes }
14
15
  on('tests') { run Api::Tasks::Routes }
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+ module Mutx
3
+ module Routes
4
+ module Api
5
+ module Git
6
+ class Routes < App
7
+ define do
8
+
9
+ on get do
10
+ on "pull" do
11
+ result = Mutx::Database::MongoConnector.last_commit_webhook
12
+ result_parsed = result["log"]["commits"].join.gsub('=>', ':')
13
+ last = JSON.parse result_parsed #hash
14
+
15
+ result = Mutx::Database::MongoConnector.before_last_commit_webhook
16
+ result_parsed = result["log"]["commits"].join.gsub('=>', ':')
17
+ before_last = JSON.parse result_parsed #hash
18
+
19
+ output = {:last_commit => last, :before_last_commit => before_last}
20
+ res.write output.to_json
21
+ end
22
+ end
23
+
24
+ on post do
25
+ on "pull" do
26
+ #Check for updates on the branch and make a pull if its outdated
27
+ ##Mutx::Support::Git.pull unless Mutx::Support::Git.up_to_date?
28
+ data_json = JSON.parse req.body.read
29
+ Mutx::Support::ChangeInspector.is_there_a_change? data_json
30
+ Mutx::Support::Log.debug "#{data_json}" if Mutx::Support::Log
31
+ Mutx::Support::Bundle.new.bundle_update if data_json["repository"]["language"].eql? "Ruby"
32
+ res.status = 200
33
+ res.write "status 200"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -9,9 +9,9 @@ module Mutx
9
9
  # Consider true if git usage is false
10
10
  # @return [Boolean]
11
11
 
12
- def self.is_there_a_change?
12
+ def self.is_there_a_change? data_json
13
13
  if Mutx::Support::Configuration.use_git?
14
- if Mutx::Database::MongoConnector.last_commit != (last_repo_commit = Mutx::Support::Git.last_remote_commit)
14
+ if Mutx::Database::MongoConnector.last_commit != (last_repo_commit = data_json)#(last_repo_commit = Mutx::Support::Git.last_remote_commit)
15
15
  Mutx::Support::Log.debug "Git has been changed. Perform code update" if Mutx::Support::Log
16
16
  Mutx::Support::Git.reset_hard_and_pull
17
17
  Mutx::Database::MongoConnector.insert_commit(last_repo_commit)
@@ -1,3 +1,3 @@
1
1
  module Mutx
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
@@ -44,7 +44,11 @@ end
44
44
  <a href='#' onclick="window.open('{{ path_for(:api_results_show, result_id: result.id) }}', '_blank', 'toolbar=no, scrollbars=yes, resizable=yes, top=300, left=300, width=800, height=600');" class='btn btn-default'>
45
45
  JSON Data</a>
46
46
  <a href='#' onclick="window.open('{{ path_for(:api_results_data, result_id: result.id) }}', '_blank', 'toolbar=no, scrollbars=yes, resizable=yes, top=300, left=300, width=800, height=600');" class='btn btn-default'>
47
- Execution Data</a>
47
+ Execution Data</a>
48
+ % if result.is_cucumber? and result.has_report?
49
+ <a href='#' onclick="window.open('{{ path_for(:results_report, result_id: result.id) }}', '_blank', 'toolbar=no, scrollbars=yes, resizable=yes, top=300, left=300, width=800, height=600');" class='btn btn-default'>
50
+ Html report</a>
51
+ % end
48
52
  </div>
49
53
  </h6>
50
54
  </div>
@@ -52,25 +56,17 @@ end
52
56
  <h4>Console Output</h4>
53
57
  </div>
54
58
  <div id='result'>
55
- % if size_of_lines > 15
56
- <button type='button' class='btn btn-default' title='Go down' onclick='goToBottom()' style='float: right'><span class='glyphicon glyphicon-chevron-down' aria-hidden='true'></span> Go down</button>
57
- <br>
58
- % end
59
- <h3>
60
- <small>
61
- <pre style="height:400px; overflow:scroll; white-space:pre; word-wrap:normal;">
62
- <b style='color:Black'>{{text}}</b>
63
- </pre>
64
- </small>
65
- </h3>
59
+ <small>
60
+ <pre style="height:400px; overflow:scroll; white-space:pre; word-wrap:normal;">
61
+ {{text}}
62
+ </pre>
63
+ </small>
64
+
66
65
  % if size_of_lines > 15
67
66
  <button type='button' class='btn btn-default' title='Go up' onclick='goToTop()' style='float: right'><span class='glyphicon glyphicon-chevron-up' aria-hidden='true'></span> Go up</button><br><br>
68
67
  % end
69
68
  </div>
70
69
  <br>
71
- <div>
72
- <a onclick="goClean('{{ path_for(:tasks_show, task_name: result.task['name']) }}');" style="cursor:pointer;" class='label label-default' >Return to task</a>
73
- </div>
74
70
  <br>
75
71
  <br>
76
72
  % else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Rodriguez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-13 00:00:00.000000000 Z
11
+ date: 2017-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -424,14 +424,10 @@ files:
424
424
  - lib/mutx/background_jobs/sidekiq.rb
425
425
  - lib/mutx/background_jobs/workers/.DS_Store
426
426
  - lib/mutx/background_jobs/workers/alerts_worker.rb
427
- - lib/mutx/background_jobs/workers/connectivity_check.rb
428
427
  - lib/mutx/background_jobs/workers/email_sender.rb
429
428
  - lib/mutx/background_jobs/workers/executor.rb
430
- - lib/mutx/background_jobs/workers/garbage_cleaner.rb
431
- - lib/mutx/background_jobs/workers/listener.rb
432
429
  - lib/mutx/background_jobs/workers/mutx_cron.rb
433
430
  - lib/mutx/background_jobs/workers/notificator.rb
434
- - lib/mutx/background_jobs/workers/update_started.rb
435
431
  - lib/mutx/commands/.DS_Store
436
432
  - lib/mutx/commands/bye.rb
437
433
  - lib/mutx/commands/create_alert.rb
@@ -480,6 +476,7 @@ files:
480
476
  - lib/mutx/routes/alerts_routes.rb
481
477
  - lib/mutx/routes/api_routes.rb
482
478
  - lib/mutx/routes/api_routes/custom_params_routes.rb
479
+ - lib/mutx/routes/api_routes/git_routes.rb
483
480
  - lib/mutx/routes/api_routes/input_routes.rb
484
481
  - lib/mutx/routes/api_routes/repos_routes.rb
485
482
  - lib/mutx/routes/api_routes/results_routes.rb
@@ -1,36 +0,0 @@
1
- # encoding: utf-8
2
- require 'mutx'
3
- require 'sidetiq'
4
- require 'open-uri'
5
- #require 'sidekiq/testing/inline'
6
-
7
- module Mutx
8
- module Workers
9
- class ConnectivityCheck
10
- include Sidekiq::Worker
11
- include Sidetiq::Schedulable
12
- recurrence { minutely(2) }
13
- def perform
14
- #def self.check
15
- #Mutx::Database::MongoConnector.new Mutx::Support::Configuration.db_connection_data
16
- path = "#{Dir.pwd}/mutx/temp/connectivity_check.txt"
17
- message_lost = "Internet connection lost!"
18
- begin
19
- if open("http://www.google.com/")
20
- puts "HAY INTERNET..."
21
- contents = File.read("#{path}") if File.file?("#{path}")
22
- Mutx::Support::MailSender.new.sender(nil, "No internet connection for a while, now is ready again", "ohamra@gmail.com", "Prueba", nil, nil, nil, nil, nil) if ( (!contents.nil?) && (contents.include? "#{message_lost}") )
23
- File.delete("#{path}") if File.file?("#{path}")
24
- else
25
- raise StandardError.new "#{message_lost}"
26
- end
27
- rescue StandardError => e
28
- output = File.open("#{path}", "a+")
29
- text = "#{Time.now} - #{e.message}"
30
- output.puts "#{text}"
31
- output.close
32
- end
33
- end
34
- end#class
35
- end
36
- end
@@ -1,33 +0,0 @@
1
- # encoding: utf-8
2
- require 'mutx'
3
-
4
- module Mutx
5
- module Workers
6
- class GarbageCleaner
7
-
8
- # This worker delete all zombies files
9
- include Sidekiq::Worker
10
- def perform
11
-
12
- Mutx::Support::Configuration.get
13
- Mutx::Database::MongoConnector.new(Mutx::Support::Configuration.db_connection_data)
14
-
15
- get_present_output_files = Dir["#{Dir.pwd}/mutx/temp/*.out"].select{|file| file.start_with? "mutx_co_"}
16
- get_present_report_files = Dir["#{Dir.pwd}/mutx/temp/*.html"].select{|file| file.start_with? "mutx_report_"}
17
-
18
- get_present_output_files.each do |output_file|
19
- if result = Mutx::Results::Result.get(output_file.scan(/\d+/).first)
20
- File.delete("#{Dir.pwd}/mutx/temp/#{output_file}") if result.finished?
21
- end
22
- end
23
-
24
- get_present_report_files.each do |report_file|
25
- if result = Mutx::Results::Result.get(report_file.scan(/\d+/).first)
26
- File.delete("#{Dir.pwd}/mutx/temp/#{report_file}") if result.finished?
27
- end
28
- end
29
- ##Mutx::Database::MongoConnector.force_close
30
- end
31
- end
32
- end
33
- end
@@ -1,33 +0,0 @@
1
- # encoding: utf-8
2
- require 'mutx'
3
- require 'socket'
4
-
5
- module Mutx
6
- module Workers
7
- class Listener
8
- include Sidekiq::Worker
9
- def perform(result_id)
10
-
11
-
12
- tcp_port = result.id.to_s[-4..-1].to_i
13
-
14
- #server = TCPServer.new tcp_port # Server bound to port tcp_port
15
-
16
- ###########################
17
- #begin
18
- #
19
-
20
- server = TCPServer.new tcp_port # Server bound to port tcp_port
21
-
22
- @running = true
23
-
24
- Thread.start("#{result.mutx_command}") do |command|
25
-
26
-
27
- end
28
-
29
-
30
- end
31
- end
32
- end
33
- end
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
- require 'mutx'
3
- require 'sidetiq'
4
- #require 'sidekiq/testing/inline'
5
-
6
- module Mutx
7
- module Workers
8
- class UpdateStarted
9
- include Sidekiq::Worker
10
- include Sidetiq::Schedulable
11
- recurrence { minutely(2) }
12
- def perform
13
- started_result = nil
14
- started_result = Mutx::Database::MongoConnector.started!
15
- started_result.each do |line|
16
- puts Mutx::API::Execution.reset(line["_id"])
17
- end
18
- puts "- ==== NO Started Results Founded ====" if started_result.eql? []
19
- ##Mutx::Database::MongoConnector.force_close
20
- end
21
- end#class
22
- end
23
- end