git-semaphore 1.1.0 → 1.2.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
  SHA1:
3
- metadata.gz: 40184be592c2c2afc8dc9ca98da908756e67df2d
4
- data.tar.gz: ee4104f83902c4e3ccbfde0514f4e00d84e36ccd
3
+ metadata.gz: 4d581bd5005d05232ba4b5a48c550869e5b0899a
4
+ data.tar.gz: 11ebd99ca6deace07ea9bae7e99e8616316f78e0
5
5
  SHA512:
6
- metadata.gz: 86e2abea939c3ad674cffdd68f01bb8d39651d281b9d51a1ef4bc9a325c5b2cea8ea5c22a4b9ed1e8e2ff782b873037921b2dc70844782422631ce69b8844fe1
7
- data.tar.gz: 041c9f620e57de36d55849665c3ff06f153870bdbe8c3a508c03dcb471705a70abe192e950064e683370ad6ebb97a585c6a9797933101fcde3de197d6a40e154
6
+ metadata.gz: 3dfe7c3bf1f6492b35649130e1dc6467841bcc6279172d0b8b7fb90bf2b8c27374a77594b66e5bd71261d650360511a3403f42baa0c0843a5bca5af1a338dfb6
7
+ data.tar.gz: e8559616dbab2c11fcc95f8d61cce38a148c1225b3af54e0989d4cbbe8df7c4dd786e02256bd77cbbe073b87c734af3ae82a5822b9fde3609bb60dc6b84353c2
data/README.md CHANGED
@@ -44,7 +44,7 @@ The following [Semaphore API][] features are supported by `git semaphore`:
44
44
  | [branch status][] | ✅ | `git semaphore --status` | list the build status for the current branch |
45
45
  | [branch history][] | ✅ | `git semaphore --history` | list the build history for the current branch |
46
46
  | [build information][] | ✅ | `git semaphore --information` | detailed information for a given build number _(ie. all commits)_ |
47
- | [build log][] | | | execution logs for a given build number _(per thread and command)_ |
47
+ | [build log][] | | `git semaphore --log` | execution logs for a given build number _(per thread and command)_ |
48
48
  | [rebuild][] | ✅ | `git semaphore --rebuild` | rebuild last revision for the current branch |
49
49
  | [launch build][] | ❌ | | launch a build for the given commit SHA |
50
50
  | [stop][] | ❌ | | stop an in-progress build |
@@ -178,6 +178,10 @@ _(the project and branch names are derived from the current git repository and t
178
178
 
179
179
  _(the project and branch names are derived from the current git repository and the current git head)_
180
180
 
181
+ ### build command and logs for the last build of a project's branch
182
+
183
+ git semaphore --log
184
+
181
185
  ## Formatting the raw `git semaphore` JSON output
182
186
 
183
187
  After installing [the indispensable jq utility][jq] (`brew install jq`), the raw JSON output generated by the various `git semaphore` commands can be formatted and queried as follows:
@@ -193,10 +197,13 @@ After installing [the indispensable jq utility][jq] (`brew install jq`), the raw
193
197
 
194
198
  # list the build duration (in minutes) for all "passed" builds of the current branch
195
199
  git semaphore --history | jq -r '.builds | .[] | select(.result == "passed") | (.build_number|tostring) + "\t" + (.duration.minutes|tostring)'
196
-
200
+
197
201
  # list all commit SHAs that triggered the latest build
198
202
  git semaphore --information | jq -r '.commits | .[] | .id'
199
203
 
204
+ # list the various thread commands for the latest build
205
+ git semaphore --log | jq '.threads | .[] | .commands | .[] | .name'
206
+
200
207
  [semaphoreci.com]: https://semaphoreci.com/
201
208
  [account settings]: https://semaphoreci.com/users/edit
202
209
  [Semaphore API]: https://semaphoreci.com/docs/api.html
data/exe/git-semaphore CHANGED
@@ -27,6 +27,7 @@ if __FILE__ == $0
27
27
  on :status, 'List the build status for the current branch'
28
28
  on :history, 'List the build history for the current branch'
29
29
  on :information, 'List the commit information for the last build'
30
+ on :log, 'List the build log for the last build'
30
31
  on :rebuild, 'Rebuild last revision for the current branch'
31
32
 
32
33
  end
@@ -73,6 +74,11 @@ if __FILE__ == $0
73
74
  exit 0
74
75
  end
75
76
 
77
+ if options.log?
78
+ puts app.log.to_json
79
+ exit 0
80
+ end
81
+
76
82
  if options.rebuild?
77
83
  puts app.rebuild
78
84
  exit 0
@@ -24,6 +24,10 @@ module Git
24
24
  get_json information_uri(project_hash_id, branch_id, build_number, auth_token)
25
25
  end
26
26
 
27
+ def self.log project_hash_id, branch_id, build_number, auth_token
28
+ get_json log_uri(project_hash_id, branch_id, build_number, auth_token)
29
+ end
30
+
27
31
  def self.rebuild project_hash_id, branch_id, auth_token
28
32
  get_json last_revision_uri(project_hash_id, branch_id, auth_token), :post
29
33
  end
@@ -70,6 +74,14 @@ module Git
70
74
 
71
75
  private_class_method :information_uri
72
76
 
77
+ def self.log_uri project_hash_id, branch_id, build_number, auth_token
78
+ # https://semaphoreci.com/docs/branches-and-builds-api.html#build_log
79
+ # GET /api/v1/projects/:hash_id/:id/builds/:number/log
80
+ request_uri(auth_token, :path => File.join('projects', project_hash_id, branch_id, 'builds', build_number, 'log'))
81
+ end
82
+
83
+ private_class_method :log_uri
84
+
73
85
  def self.last_revision_uri project_hash_id, branch_id, auth_token
74
86
  # https://semaphoreci.com/docs/branches-and-builds-api.html#rebuild
75
87
  # POST /api/v1/projects/:project_hash_id/:branch_id/build
@@ -33,6 +33,12 @@ module Git
33
33
  end
34
34
  end
35
35
 
36
+ def self.log project_hash_id, branch_id, build_number, auth_token
37
+ @log ||= Git::Semaphore.from_json_cache(log_cache(project_hash_id, branch_id, build_number)) do
38
+ API.log project_hash_id, branch_id, build_number, auth_token
39
+ end
40
+ end
41
+
36
42
  # private helper functions
37
43
 
38
44
  def self.projects_cache
@@ -65,6 +71,12 @@ module Git
65
71
 
66
72
  private_class_method :information_cache
67
73
 
74
+ def self.log_cache project_hash_id, branch_id, build_number
75
+ File.join(Git::Semaphore.cache_dir_for(project_hash_id), "#{branch_id}_#{build_number}_log.json")
76
+ end
77
+
78
+ private_class_method :log_cache
79
+
68
80
  end
69
81
  end
70
82
  end
@@ -67,6 +67,10 @@ class Git::Semaphore::App
67
67
  Git::Semaphore::API::Cache.information(project_hash_id, branch_id, build_number, @auth_token,)
68
68
  end
69
69
 
70
+ def log
71
+ Git::Semaphore::API::Cache.log(project_hash_id, branch_id, build_number, @auth_token,)
72
+ end
73
+
70
74
  def rebuild
71
75
  Git::Semaphore::API.rebuild(project_hash_id, branch_id, @auth_token)
72
76
  end
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Semaphore
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-semaphore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Vandenberk