semaph 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0677122d6857a85e92dc0a74346b4f130f1f715ad9cfede85ffab143540867e
4
- data.tar.gz: c6165a0966dd6cd3088fcece1d56d304188c79552c03a0d48cb3addbe1e4649f
3
+ metadata.gz: 3f87c47f0c0284d850593103961da8d6a7dc749042dc774aaa8f16f59f4fa183
4
+ data.tar.gz: 4c35a0cdfec02111a076738d6be9e2b18f1bd2a598bb3020f859840a21613556
5
5
  SHA512:
6
- metadata.gz: d2ea65f9d5fdaf2b4b0597dc3fd0205eaa7fad89b596dff1fcf6619c6d39d11c80c9b5f9acd4e375049c6e16a91bcc4df5708cfd6e1725e834c80576d1442dbf
7
- data.tar.gz: 2505c4088ef17b9efdaa9c9d2dfc80159e459dfcc5f097d4761b69b2e390cb3371b611d9a913783812b5b1dd7435063ac8db3de2fb58f90168822068bcdc2ebf
6
+ metadata.gz: 348e0df084693205e3d59a18e886674d5783cf451b362d1dbf6aa0e5acd6dcaa5715313339e3c81c7a1dffb5f590a093684f99cc668c33dbc983182abce9d4bf
7
+ data.tar.gz: a3c64e20563744c6224b0cbd7deac2fa50a8c3d0c53eceda20c8f8d9d294cb25e8307f489d0ebebfe582c1d1fad5eb25d88e897fd5ecb4e91b294eaa76200a46
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- semaph (0.4.0)
4
+ semaph (0.5.0)
5
5
  faraday
6
6
  rainbow
7
7
  shell_shock
data/README.md CHANGED
@@ -60,8 +60,6 @@ If you have only one set of credentials in `~/.sem.yml` then this will be the in
60
60
 
61
61
  From here you can `list-projects` and then `select-project` to enter a shell for that project.
62
62
 
63
- If new projects have been added/removed while you are using this shell, you can `reload-projects`.
64
-
65
63
  ### project shell
66
64
 
67
65
  🏗 foo.semaphoreci.com my-app >
@@ -71,8 +69,8 @@ substring of the git branch you want to see workflows for) and then `select-work
71
69
  (where 'index' is the number displayed for each workflow `list-workflows` - tab completion on uuids
72
70
  seemed a bad idea) to enter a shell for that specific workflow.
73
71
 
74
- You can also `open-github` (opens a web browser for the github project associated with the project), `open-project`
75
- (opens the semaphoreci project in a browser) and `reload-workflows` (to see any new/changed workflows).
72
+ You can also `open-github` (opens a web browser for the github project associated with the project) and `open-project`
73
+ (opens the semaphoreci project in a browser).
76
74
 
77
75
  ### workflow shell
78
76
 
@@ -83,16 +81,22 @@ from `semaphore.yml` plus any promotion pipelines that might be executed. You c
83
81
  what's happening with the pipeline.
84
82
 
85
83
  You can also `open-github-branch`, `open-github-commit` to see the branch/commit in a browser and
86
- `open-workflow`, `open-branch` to see the semaphore branch/workflow in a browser and `reload-pipelines` to see
87
- any changes that have happened in semaphore.
84
+ `open-workflow`, `open-branch` to see the semaphore branch/workflow in a browser.
88
85
 
89
86
  ### pipeline shell
90
87
 
91
88
  🏗 foo.semaphoreci.com my-app workflowuuid semaphore.yml >
92
89
 
93
- From this shell, you can `list-jobs` and `reload-jobs`.
90
+ From this shell, you can `list-jobs`, `poll-jobs`, `job-log` and `grep-logs`.
91
+
92
+ Job polling will stop as soon as any one job has failed and send a system notification
93
+ (as long as `terminal-notifier` is installed).
94
+
95
+ You can look at the log for a specific job (by the index presented in `list-jobs`) using `less`.
96
+
97
+ You can grep across all jobs (using `ag`) with `grep-logs` which will download the logs for all completed jobs.
94
98
 
95
- Jobs are displayed with a flattened view of blocks and jobs for compactness.
99
+ You can also open the same browser views in semaphoreci and github from this shell.
96
100
 
97
101
  ## Development
98
102
 
@@ -1,6 +1,6 @@
1
1
  module Semaph
2
2
  module Formatting
3
- TIME_FORMAT = "%Y-%m-%d %H:%M:%S".freeze
3
+ TIME_FORMAT = "%m-%d %H:%M".freeze
4
4
 
5
5
  def self.time(time)
6
6
  time.strftime(TIME_FORMAT)
@@ -3,17 +3,18 @@ require "semaph/model/pipeline_collection"
3
3
  module Semaph
4
4
  module Model
5
5
  class Workflow
6
- attr_reader :project, :raw, :id, :sha, :branch, :branch_id, :created_at
6
+ attr_reader :project, :raw, :id, :sha, :commit, :branch, :branch_id, :created_at
7
7
 
8
8
  def initialize(project, raw)
9
9
  @project = project
10
10
  @raw = raw
11
11
  @id = raw["wf_id"]
12
12
  @sha = raw["commit_sha"]
13
+ @commit = @sha.slice(0..10)
13
14
  @created_at = Time.at(raw["created_at"]["seconds"].to_i)
14
15
  @branch = raw["branch_name"]
15
16
  @branch_id = raw["branch_id"]
16
- # @summary = `git log -n 1 --format="%h %an %ci %s" #{sha}`
17
+ @commit = `git log -n 1 --format="%h %an %s" #{sha}`.chomp if `git cat-file -t #{sha} 2>&1`.chomp == "commit"
17
18
  end
18
19
 
19
20
  def pipeline_collection
@@ -23,8 +23,8 @@ module Semaph
23
23
  def add_commands
24
24
  project_collection = ::Semaph::Model::ProjectCollection.new(@client)
25
25
  @project_list_command = ProjectsListCommand.new(project_collection)
26
- add_command @project_list_command, "list-projects"
27
- add_command ProjectsSelectCommand.new(project_collection), "select-project"
26
+ add_command @project_list_command, "list-projects", "ls"
27
+ add_command ProjectsSelectCommand.new(project_collection), "select-project", "cd"
28
28
  add_command ::Semaph::Commands::ReloadCommand.new, "reload" if ENV["SEMAPH_RELOAD"]
29
29
  end
30
30
  end
@@ -13,8 +13,8 @@ module Semaph
13
13
  @organisations = organisations
14
14
  @prompt = "🏗 > "
15
15
  organisations_list_command = OrganisationsListCommand.new(organisations)
16
- add_command organisations_list_command, "list-organisations"
17
- add_command OrganisationsSelectCommand.new(organisations), "select-organisation"
16
+ add_command organisations_list_command, "list-organisations", "ls"
17
+ add_command OrganisationsSelectCommand.new(organisations), "select-organisation", "cd"
18
18
  add_command ::Semaph::Commands::ReloadCommand.new, "reload" if ENV["SEMAPH_RELOAD"]
19
19
  organisations_list_command.execute("")
20
20
  end
@@ -6,16 +6,17 @@ module Semaph
6
6
  class JobLogGrepCommand
7
7
  attr_reader :usage, :help, :job_collection
8
8
 
9
- def initialize(job_collection)
9
+ def initialize(job_collection, scope)
10
10
  @job_collection = job_collection
11
+ @scope = scope
11
12
  @usage = "<expression>"
12
- @help = "retrieve all logs and grep for text"
13
+ @help = "retrieve logs for #{scope} jobs and grep for text"
13
14
  end
14
15
 
15
16
  def execute(expression)
16
17
  base = "tmp/logs/pipeline/#{job_collection.pipeline.id}"
17
18
  FileUtils.mkdir_p(base)
18
- @job_collection.all.each do |job|
19
+ @job_collection.send(@scope).each do |job|
19
20
  unless job.finished?
20
21
  puts "skipping incomplete job #{job.id}"
21
22
  next
@@ -37,10 +37,11 @@ module Semaph
37
37
 
38
38
  def add_commands
39
39
  @jobs_list_command = JobsListCommand.new(job_collection)
40
- add_command @jobs_list_command, "list-jobs"
40
+ add_command @jobs_list_command, "list-jobs", "ls"
41
41
  add_command JobsPollCommand.new(job_collection), "poll-jobs"
42
42
  add_command JobLogCommand.new(job_collection), "job-log"
43
- add_command JobLogGrepCommand.new(job_collection), "grep-logs"
43
+ add_command JobLogGrepCommand.new(job_collection, :all), "grep-all-logs"
44
+ add_command JobLogGrepCommand.new(job_collection, :failed), "grep-failed-logs"
44
45
  add_command ::Semaph::Commands::RerunWorkflowCommand.new(workflow), "rerun"
45
46
  add_open_branch_command
46
47
  add_open_workflow_command
@@ -29,8 +29,8 @@ module Semaph
29
29
  add_github_command
30
30
  add_open_project_command
31
31
  @workflows_list_command = WorkflowsListCommand.new(workflow_collection)
32
- add_command @workflows_list_command, "list-workflows"
33
- add_command WorkflowsSelectCommand.new(workflow_collection), "select-workflow"
32
+ add_command @workflows_list_command, "list-workflows", "ls"
33
+ add_command WorkflowsSelectCommand.new(workflow_collection), "select-workflow", "cd"
34
34
  add_command ::Semaph::Commands::ReloadCommand.new, "reload" if ENV["SEMAPH_RELOAD"]
35
35
  end
36
36
 
@@ -1,9 +1,9 @@
1
+ require "semaph/formatting"
2
+
1
3
  module Semaph
2
4
  module Shells
3
5
  module Project
4
6
  class WorkflowsListCommand
5
- TIME_FORMAT = "%Y-%m-%d %H:%M:%S".freeze
6
-
7
7
  attr_reader :usage, :help
8
8
 
9
9
  def initialize(workflow_collection)
@@ -26,11 +26,9 @@ module Semaph
26
26
  def description(index, workflow)
27
27
  [
28
28
  index + 1,
29
- workflow.created_at.strftime(TIME_FORMAT),
30
- "SHA",
31
- workflow.sha,
32
- "on branch",
29
+ Semaph::Formatting.time(workflow.created_at),
33
30
  workflow.branch,
31
+ workflow.commit,
34
32
  ].join(" ")
35
33
  end
36
34
  end
@@ -33,8 +33,8 @@ module Semaph
33
33
 
34
34
  def add_commands
35
35
  @list_command = PipelinesListCommand.new(pipeline_collection)
36
- add_command @list_command, "list-pipelines"
37
- add_command PipelinesSelectCommand.new(pipeline_collection), "select-pipeline"
36
+ add_command @list_command, "list-pipelines", "ls"
37
+ add_command PipelinesSelectCommand.new(pipeline_collection), "select-pipeline", "cd"
38
38
  add_command ::Semaph::Commands::RerunWorkflowCommand.new(workflow), "rerun"
39
39
  add_command ::Semaph::Commands::StopWorkflowCommand.new(workflow), "stop"
40
40
  add_open_branch_command
@@ -1,3 +1,3 @@
1
1
  module Semaph
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.5.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semaph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Ryall
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-02 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday