semaph 0.3.0 → 0.4.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/Gemfile.lock +1 -1
- data/lib/semaph/model/job.rb +8 -0
- data/lib/semaph/model/job_collection.rb +3 -3
- data/lib/semaph/shells/pipeline/{jobs_logs_command.rb → job_log_command.rb} +15 -3
- data/lib/semaph/shells/pipeline/job_log_grep_command.rb +34 -0
- data/lib/semaph/shells/pipeline/pipeline_shell.rb +4 -2
- data/lib/semaph/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0677122d6857a85e92dc0a74346b4f130f1f715ad9cfede85ffab143540867e
|
4
|
+
data.tar.gz: c6165a0966dd6cd3088fcece1d56d304188c79552c03a0d48cb3addbe1e4649f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2ea65f9d5fdaf2b4b0597dc3fd0205eaa7fad89b596dff1fcf6619c6d39d11c80c9b5f9acd4e375049c6e16a91bcc4df5708cfd6e1725e834c80576d1442dbf
|
7
|
+
data.tar.gz: 2505c4088ef17b9efdaa9c9d2dfc80159e459dfcc5f097d4761b69b2e390cb3371b611d9a913783812b5b1dd7435063ac8db3de2fb58f90168822068bcdc2ebf
|
data/Gemfile.lock
CHANGED
data/lib/semaph/model/job.rb
CHANGED
@@ -33,6 +33,14 @@ module Semaph
|
|
33
33
|
].compact.join(" ")
|
34
34
|
end
|
35
35
|
|
36
|
+
def finished?
|
37
|
+
@status == "FINISHED"
|
38
|
+
end
|
39
|
+
|
40
|
+
def failed?
|
41
|
+
@result == "FAILED"
|
42
|
+
end
|
43
|
+
|
36
44
|
# block_state can be waiting/running/done
|
37
45
|
# block_result can be passed/failed/canceled/stopped
|
38
46
|
def block_icon
|
@@ -3,7 +3,7 @@ require "semaph/model/job"
|
|
3
3
|
module Semaph
|
4
4
|
module Model
|
5
5
|
class JobCollection
|
6
|
-
attr_reader :all
|
6
|
+
attr_reader :all, :pipeline
|
7
7
|
|
8
8
|
def initialize(pipeline)
|
9
9
|
@pipeline = pipeline
|
@@ -16,11 +16,11 @@ module Semaph
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def incomplete
|
19
|
-
@all.reject
|
19
|
+
@all.reject(&:finished?)
|
20
20
|
end
|
21
21
|
|
22
22
|
def failed
|
23
|
-
@all.select
|
23
|
+
@all.select(&:failed?)
|
24
24
|
end
|
25
25
|
|
26
26
|
private
|
@@ -1,7 +1,9 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
1
3
|
module Semaph
|
2
4
|
module Shells
|
3
5
|
module Pipeline
|
4
|
-
class
|
6
|
+
class JobLogCommand
|
5
7
|
attr_reader :usage, :help
|
6
8
|
|
7
9
|
def initialize(job_collection)
|
@@ -20,8 +22,18 @@ module Semaph
|
|
20
22
|
return
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
+
unless job.finished?
|
26
|
+
puts "This job has not finished yet"
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
base = "tmp/logs/pipeline/#{job.pipeline.id}"
|
31
|
+
FileUtils.mkdir_p(base)
|
32
|
+
filename = "#{base}/#{job.id}.log"
|
33
|
+
unless File.exist?(filename)
|
34
|
+
puts "retrieving log for job #{job.id}"
|
35
|
+
File.open(filename, "w") { |file| file.puts job.log }
|
36
|
+
end
|
25
37
|
system("less #{filename}")
|
26
38
|
end
|
27
39
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
module Semaph
|
4
|
+
module Shells
|
5
|
+
module Pipeline
|
6
|
+
class JobLogGrepCommand
|
7
|
+
attr_reader :usage, :help, :job_collection
|
8
|
+
|
9
|
+
def initialize(job_collection)
|
10
|
+
@job_collection = job_collection
|
11
|
+
@usage = "<expression>"
|
12
|
+
@help = "retrieve all logs and grep for text"
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute(expression)
|
16
|
+
base = "tmp/logs/pipeline/#{job_collection.pipeline.id}"
|
17
|
+
FileUtils.mkdir_p(base)
|
18
|
+
@job_collection.all.each do |job|
|
19
|
+
unless job.finished?
|
20
|
+
puts "skipping incomplete job #{job.id}"
|
21
|
+
next
|
22
|
+
end
|
23
|
+
filename = "#{base}/#{job.id}.log"
|
24
|
+
unless File.exist?(filename)
|
25
|
+
puts "retrieving log for job #{job.id}"
|
26
|
+
File.open(filename, "w") { |file| file.puts job.log }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
system("ag #{expression} #{base} | less")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require "semaph/commands/reload_command"
|
2
2
|
require "semaph/commands/rerun_workflow_command"
|
3
3
|
require "semaph/shells/pipeline/jobs_list_command"
|
4
|
-
require "semaph/shells/pipeline/
|
4
|
+
require "semaph/shells/pipeline/job_log_command"
|
5
|
+
require "semaph/shells/pipeline/job_log_grep_command"
|
5
6
|
require "semaph/shells/pipeline/jobs_poll_command"
|
6
7
|
require "shell_shock/context"
|
7
8
|
|
@@ -38,7 +39,8 @@ module Semaph
|
|
38
39
|
@jobs_list_command = JobsListCommand.new(job_collection)
|
39
40
|
add_command @jobs_list_command, "list-jobs"
|
40
41
|
add_command JobsPollCommand.new(job_collection), "poll-jobs"
|
41
|
-
add_command
|
42
|
+
add_command JobLogCommand.new(job_collection), "job-log"
|
43
|
+
add_command JobLogGrepCommand.new(job_collection), "grep-logs"
|
42
44
|
add_command ::Semaph::Commands::RerunWorkflowCommand.new(workflow), "rerun"
|
43
45
|
add_open_branch_command
|
44
46
|
add_open_workflow_command
|
data/lib/semaph/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semaph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Ryall
|
@@ -109,8 +109,9 @@ files:
|
|
109
109
|
- lib/semaph/shells/organisations/organisations_list_command.rb
|
110
110
|
- lib/semaph/shells/organisations/organisations_select_command.rb
|
111
111
|
- lib/semaph/shells/organisations/organisations_shell.rb
|
112
|
+
- lib/semaph/shells/pipeline/job_log_command.rb
|
113
|
+
- lib/semaph/shells/pipeline/job_log_grep_command.rb
|
112
114
|
- lib/semaph/shells/pipeline/jobs_list_command.rb
|
113
|
-
- lib/semaph/shells/pipeline/jobs_logs_command.rb
|
114
115
|
- lib/semaph/shells/pipeline/jobs_poll_command.rb
|
115
116
|
- lib/semaph/shells/pipeline/pipeline_shell.rb
|
116
117
|
- lib/semaph/shells/project/project_shell.rb
|