travis 1.2.8 → 1.3.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: bf0bedc3ebeb0308526c8df70e1961f840b499a3
4
- data.tar.gz: 42789765d91dc5975f884cc8f34468be355bf020
3
+ metadata.gz: 43bd32ce16eb549066ab5484c7da1736b64f60ff
4
+ data.tar.gz: 999f1b38a292b48c210df8046d798852880e12dc
5
5
  SHA512:
6
- metadata.gz: 6e57f58c84db9bbe82efac4f7f35a4111730ac1fdb1c9ae9546c3d43f98353507bef69564382e126d71dfe10885428757af12a02be6dfbe6be66fc64308bb03e
7
- data.tar.gz: 45aa4e29b71736c48bccb28e63d59609b75a0106749e8c53362108fd1e014a2b19041ac29d0179ca79fc1181bd5bfc837d97998e55e6f1663cce465059644df4
6
+ metadata.gz: 1927ceed3d07a753e7ccde4dd7e952daded43bb974c069a59d88efbf71d5d604c789bfbfd2325b213e854cbb1b71252a9194ec72e5f9ac2a8303a0797bd49f89
7
+ data.tar.gz: 64ab6d079c38d482810cfebdba22e9b3a5c7fe3cc546252d336e57c4188e9a4f9df1772e052dfe887ca82e301cd5575a9c821959cfb95544731a08dd09368db4
data/README.md CHANGED
@@ -20,6 +20,7 @@ The [travis gem](https://rubygems.org/gems/travis) includes both a command line
20
20
  * [`whatsup`](#whatsup)
21
21
  * [`whoami`](#whoami)
22
22
  * [Repository Commands](#repository-commands)
23
+ * [`branches`](#branches)
23
24
  * [`disable`](#disable)
24
25
  * [`enable`](#enable)
25
26
  * [`encrypt`](#encrypt)
@@ -28,6 +29,7 @@ The [travis gem](https://rubygems.org/gems/travis) includes both a command line
28
29
  * [`open`](#open)
29
30
  * [`pubkey`](#pubkey)
30
31
  * [`restart`](#restart)
32
+ * [`setup`](#setup)
31
33
  * [`show`](#show)
32
34
  * [`status`](#status)
33
35
  * [Ruby Library](#ruby-library)
@@ -260,6 +262,23 @@ Additionally, you can specify the Repository to talk to by providing `--repo own
260
262
 
261
263
  It will also automatically pick [Travis Pro](https://travis-ci.com) if it is a private project. You can of course override this decission with `--pro`, `--org` or `--api-endpoint URL`
262
264
 
265
+ #### `branches`
266
+
267
+ Displays the most recent build for each branch:
268
+
269
+ $ travis branches
270
+ hh-add-warning-old-style: #35 passed Add a warning if old-style encrypt is being used
271
+ hh-multiline-encrypt: #55 passed Merge branch 'master' into hh-multiline-encrypt
272
+ rkh-show-logs-history: #72 passed regenerate gemspec
273
+ rkh-debug: #75 passed what?
274
+ hh-add-clear-cache-to-global-session: #135 passed Add clear_cache(!) to Travis::Namespace
275
+ hh-annotations: #146 passed Initial annotation support
276
+ hh-remove-newlines-from-encrypted-string: #148 errored Remove all whitespace from an encrypted string
277
+ version-check: #157 passed check travis version for updates from time to time
278
+ master: #163 passed add Repository#branches and Repository#branch(name)
279
+
280
+ For more fine grained control and older builds on a specific branch, see [`history`](#history).
281
+
263
282
  #### `disable`
264
283
 
265
284
  If you want to turn of a repository temporarily or indefinitely, you can do so with the `disable` command:
@@ -453,6 +472,33 @@ Or a single job:
453
472
  $ travis restart 57.1
454
473
  job #57.1 has been restarted
455
474
 
475
+ #### `setup`
476
+
477
+ Helps you configure Travis addons.
478
+
479
+ Usage: bin/travis setup service [options]
480
+ -h, --help Display help
481
+ -i, --[no-]interactive be interactive and colorful
482
+ -E, --[no-]explode don't rescue exceptions
483
+ --skip-version-check don't check if travis client is up to date
484
+ -e, --api-endpoint URL Travis API server to talk to
485
+ --pro short-cut for --api-endpoint 'https://api.travis-ci.com/'
486
+ --org short-cut for --api-endpoint 'https://api.travis-ci.org/'
487
+ --staging talks to staging system
488
+ -t, --token [ACCESS_TOKEN] access token to use
489
+ --debug show API requests
490
+ --adapter ADAPTER Faraday adapter to use for HTTP requests
491
+ -r, --repo SLUG repository to use (will try to detect from current git clone)
492
+ -f, --force override config section if it already exists
493
+
494
+ Available services: `heroku`, `nodejitsu`, `openshift` and `sauce_connect`.
495
+
496
+ Example:
497
+
498
+ $ travis setup heroku
499
+ Deploy only from travis-ci/travis-chat? |yes|
500
+ Encrypt API key? |yes|
501
+
456
502
  #### `show`
457
503
 
458
504
  Displays general infos about the latest build:
@@ -491,6 +537,25 @@ Any other build:
491
537
  #1.5 failed: 38 sec rvm: jruby
492
538
  #1.6 failed: 27 sec rvm: rbx
493
539
 
540
+ The last build for a given branch:
541
+
542
+ $ travis show rkh-debug
543
+ Build #75: what?
544
+ State: passed
545
+ Type: push
546
+ Branch: rkh-debug
547
+ Compare URL: https://github.com/travis-ci/travis/compare/8d4aa5254359...7ef33d5e5993
548
+ Duration: 6 min 16 sec
549
+ Started: 2013-01-19 18:51:17
550
+ Finished: 2013-01-19 18:52:43
551
+
552
+ #75.1 passed: 1 min 10 sec rvm: 1.8.7
553
+ #75.2 passed: 51 sec rvm: 1.9.2
554
+ #75.3 passed: 36 sec rvm: 1.9.3
555
+ #75.4 passed: 48 sec rvm: 2.0.0
556
+ #75.5 failed: 1 min 26 sec rvm: jruby (failure allowed)
557
+ #75.6 passed: 1 min 25 sec rvm: rbx
558
+
494
559
  Or a job:
495
560
 
496
561
  $ travis show 77.3
@@ -731,6 +796,17 @@ You can restart a build, if the current user has sufficient permissions on the r
731
796
  rails.last_build.restart
732
797
  ```
733
798
 
799
+ You can also retrieve a Hash mapping branch names to the latest build on that given branch via `branches` or use the `branch` method to get the last build for a specific branch:
800
+
801
+ ``` ruby
802
+ if rails.branch('4-0-stable').green?
803
+ puts "Time for another 4.0.x release!"
804
+ end
805
+
806
+ count = rails.branches.size
807
+ puts "#{count} rails branches tested on travis"
808
+ ```
809
+
734
810
  #### Jobs
735
811
 
736
812
  Jobs behave a lot like [builds](#builds), and similar to them, you probably don't have the id ready. You can get the jobs from a build:
@@ -908,6 +984,15 @@ If you have the old `travis-cli` gem installed, you should `gem uninstall travis
908
984
 
909
985
  ## Version History
910
986
 
987
+ **1.3.0** (July 20, 2013)
988
+
989
+ * Add `travis setup [heroku|openshift|nodejitsu|sauce_connect]`
990
+ * Add `travis branches`
991
+ * Add Repository#branch and Repository#branches
992
+ * Improve `--help`
993
+ * Improve error message when calling `travis logs` with a matrix build number
994
+ * Check if travis gem is up to date from time to time (CLI only, not when used as library)
995
+
911
996
  **1.2.8** (July 19, 2013)
912
997
 
913
998
  * Make pubkey print out key in ssh encoding, add --pem flag for old format
@@ -16,6 +16,7 @@ module Travis
16
16
  module CLI
17
17
  autoload :Token, 'travis/cli/token'
18
18
  autoload :ApiCommand, 'travis/cli/api_command'
19
+ autoload :Branches, 'travis/cli/branches'
19
20
  autoload :Command, 'travis/cli/command'
20
21
  autoload :Console, 'travis/cli/console'
21
22
  autoload :Disable, 'travis/cli/disable'
@@ -32,6 +33,7 @@ module Travis
32
33
  autoload :Raw, 'travis/cli/raw'
33
34
  autoload :RepoCommand, 'travis/cli/repo_command'
34
35
  autoload :Restart, 'travis/cli/restart'
36
+ autoload :Setup, 'travis/cli/setup'
35
37
  autoload :Show, 'travis/cli/show'
36
38
  autoload :Status, 'travis/cli/status'
37
39
  autoload :Sync, 'travis/cli/sync'
@@ -0,0 +1,23 @@
1
+ require 'travis/cli'
2
+
3
+ module Travis
4
+ module CLI
5
+ class Branches < RepoCommand
6
+ def run
7
+ repository.last_on_branch.each do |build|
8
+ say [
9
+ color("#{build.branch_info}:".ljust(longest + 2), [:info, :bold]),
10
+ color("##{build.number.to_s.ljust(4)} #{build.state}".ljust(16), build.color),
11
+ build.commit.subject
12
+ ].join(" ").strip + "\n"
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def longest
19
+ repository.branches.keys.map { |b| b.size }.max
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,9 +1,11 @@
1
1
  require 'travis/cli'
2
2
  require 'travis/tools/formatter'
3
+ require 'travis/version'
3
4
 
4
5
  require 'highline'
5
6
  require 'forwardable'
6
7
  require 'yaml'
8
+ require 'timeout'
7
9
 
8
10
  module Travis
9
11
  module CLI
@@ -33,6 +35,7 @@ module Travis
33
35
  end
34
36
 
35
37
  on('-E', '--[no-]explode', "don't rescue exceptions")
38
+ on('--skip-version-check', "don't check if travis client is up to date")
36
39
 
37
40
  def self.command_name
38
41
  name[/[^:]*$/].downcase
@@ -95,9 +98,30 @@ module Travis
95
98
  def setup
96
99
  end
97
100
 
101
+ def check_version
102
+ return if skip_version_check?
103
+ return if Time.now.to_i - config['last_version_check'].to_i < 3600
104
+ version = Travis::VERSION
105
+
106
+ Timeout.timeout 1.0 do
107
+ response = Faraday.get('https://rubygems.org/api/v1/gems/travis.json', {}, 'If-None-Match' => config['etag'].to_s)
108
+ config['etag'] = response.headers['etag']
109
+ version = JSON.parse(response.body)['version'] if response.status == 200
110
+ end
111
+
112
+ if Travis::VERSION >= version
113
+ config['last_version_check'] = Time.now.to_i
114
+ else
115
+ error "Outdated CLI version (#{Travis::VERSION}, current is #{version}), " \
116
+ "run `gem install travis -v #{version}` or use --skip-version-check."
117
+ end
118
+ rescue Timeout::Error, Faraday::Error::ClientError
119
+ end
120
+
98
121
  def execute
99
122
  check_arity(method(:run), *arguments)
100
123
  load_config
124
+ check_version
101
125
  setup
102
126
  run(*arguments)
103
127
  store_config
@@ -1,6 +1,5 @@
1
1
  # encoding: utf-8
2
2
  require 'travis/cli'
3
- require 'yaml'
4
3
 
5
4
  module Travis
6
5
  module CLI
@@ -33,7 +32,7 @@ module Travis
33
32
 
34
33
  if config_key
35
34
  set_config encrypted.map { |e| { 'secure' => e } }
36
- File.write(travis_yaml, travis_config.to_yaml)
35
+ save_travis_config
37
36
  else
38
37
  list = encrypted.map { |data| format(data.inspect, " secure: %s") }
39
38
  say(list.join("\n"), template(__FILE__), :none)
@@ -42,13 +41,6 @@ module Travis
42
41
 
43
42
  private
44
43
 
45
- def travis_config
46
- @travis_config ||= begin
47
- payload = YAML.load_file(travis_yaml)
48
- payload.respond_to?(:to_hash) ? payload.to_hash : {}
49
- end
50
- end
51
-
52
44
  def set_config(result)
53
45
  parent_config[last_key] = merge_config(result)
54
46
  end
@@ -87,17 +79,6 @@ module Travis
87
79
 
88
80
  traverse_config(hash[key], *rest)
89
81
  end
90
-
91
- def travis_yaml(dir = Dir.pwd)
92
- path = File.expand_path('.travis.yml', dir)
93
- if File.exist? path
94
- path
95
- else
96
- parent = File.expand_path('..', dir)
97
- error "no .travis.yml found" if parent == dir
98
- travis_yaml(parent)
99
- end
100
- end
101
82
  end
102
83
  end
103
84
  end
@@ -4,7 +4,7 @@ module Travis
4
4
  module CLI
5
5
  class Logs < RepoCommand
6
6
  def run(number = last_build.number)
7
- error "##{number} is not a job" unless job = job(number)
7
+ error "##{number} is not a job, try #{number}.1" unless job = job(number)
8
8
  say log(job)
9
9
  end
10
10
 
@@ -1,10 +1,11 @@
1
1
  require 'travis/cli'
2
+ require 'yaml'
2
3
 
3
4
  module Travis
4
5
  module CLI
5
6
  class RepoCommand < ApiCommand
6
7
  GIT_REGEX = %r{^(?:https://|git://|git@)github\.com[:/](.*/.+?)(\.git)?$}
7
- on('-r', '--repo SLUG') { |c, slug| c.slug = slug }
8
+ on('-r', '--repo SLUG', 'repository to use (will try to detect from current git clone)') { |c, slug| c.slug = slug }
8
9
 
9
10
  attr_accessor :slug
10
11
  abstract
@@ -68,6 +69,31 @@ module Travis
68
69
  end
69
70
  end
70
71
  end
72
+
73
+ def travis_config
74
+ @travis_config ||= begin
75
+ payload = YAML.load_file(travis_yaml)
76
+ payload.respond_to?(:to_hash) ? payload.to_hash : {}
77
+ end
78
+ end
79
+
80
+ def travis_yaml(dir = Dir.pwd)
81
+ path = File.expand_path('.travis.yml', dir)
82
+ if File.exist? path
83
+ path
84
+ else
85
+ parent = File.expand_path('..', dir)
86
+ error "no .travis.yml found" if parent == dir
87
+ travis_yaml(parent)
88
+ end
89
+ end
90
+
91
+ def save_travis_config
92
+ yaml = travis_config.to_yaml
93
+ yaml.gsub! /^(\s+)('on'|true):/, "\\1on:"
94
+ yaml.gsub! /\A---\n/, ''
95
+ File.write(travis_yaml, yaml)
96
+ end
71
97
  end
72
98
  end
73
99
  end
@@ -0,0 +1,80 @@
1
+ require 'travis/cli'
2
+ require 'json'
3
+
4
+ module Travis
5
+ module CLI
6
+ class Setup < RepoCommand
7
+ on('-f', '--force', 'override config section if it already exists')
8
+
9
+ def run(service)
10
+ error "unknown service #{service}" unless respond_to? "setup_#{service}"
11
+ public_send "setup_#{service}"
12
+ end
13
+
14
+ def setup_heroku
15
+ configure 'deploy', 'provider' => 'heroku' do |config|
16
+ config['api_key'] = `heroku auth:token 2>/dev/null`.strip
17
+ config['api_key'] = ask("Heroku API token: ") { |q| q.echo = "*" }.to_s if config['api_key'].empty?
18
+ config['app'] = `heroku apps:info 2>/dev/null`.scan(/^=== (.+)$/).flatten.first
19
+ config['app'] = ask("Heroku application name: ") { |q| q.default = repository.name }.to_s if config['app'].nil?
20
+ config['on'] = { 'repo' => repository.slug } if agree("Deploy only from #{repository.slug}? ") { |q| q.default = 'yes' }
21
+ encrypt(config, 'api_key') if agree("Encrypt API key? ") { |q| q.default = 'yes' }
22
+ end
23
+ end
24
+
25
+ def setup_openshift
26
+ configure 'deploy', 'provider' => 'openshift' do |config|
27
+ config['user'] = ask("OpenShift user: ").to_s
28
+ config['password'] = ask("OpenShift password: ") { |q| q.echo = "*" }.to_s
29
+ config['app'] = ask("OpenShift application name: ") { |q| q.default = repository.name }.to_s
30
+ config['domain'] = ask("OpenShift domain: ").to_s
31
+ config['on'] = { 'repo' => repository.slug } if agree("Deploy only from #{repository.slug}? ") { |q| q.default = 'yes' }
32
+ encrypt(config, 'password') if agree("Encrypt password? ") { |q| q.default = 'yes' }
33
+ end
34
+ end
35
+
36
+ def setup_nodejitsu
37
+ configure 'deploy', 'provider' => 'nodejitsu' do |config|
38
+ jitsu_file = File.expand_path('.jitsuconf', ENV['HOME'])
39
+
40
+ if File.exist? jitsu_file
41
+ jitsu_conf = JSON.parse(File.read(jitsu_file))
42
+ config['user'] = jitsu_conf['username']
43
+ config['api_key'] = jitsu_conf['apiToken']
44
+ end
45
+
46
+ config['user'] ||= ask("Nodejitsu user: ").to_s
47
+ config['api_key'] ||= ask("Nodejitsu API token: ") { |q| q.echo = "*" }.to_s
48
+ config['on'] = { 'repo' => repository.slug } if agree("Deploy only from #{repository.slug}? ") { |q| q.default = 'yes' }
49
+ encrypt(config, 'api_key') if agree("Encrypt API key? ") { |q| q.default = 'yes' }
50
+ end
51
+ end
52
+
53
+ def setup_sauce_connect
54
+ travis_config['addons'] ||= {}
55
+ configure 'sauce_connect', {}, travis_config['addons'] do |config|
56
+ config['username'] = ask("Sauce Labs user: ").to_s
57
+ config['access_key'] = ask("Sauce Labs access key: ") { |q| q.echo = "*" }.to_s
58
+ encrypt(config, 'access_key') if agree("Encrypt access key? ") { |q| q.default = 'yes' }
59
+ end
60
+ end
61
+
62
+ alias setup_sauce_lab setup_sauce_connect
63
+ alias setup_sauce setup_sauce_connect
64
+
65
+ private
66
+
67
+ def encrypt(config, key)
68
+ encrypted = repository.encrypt(config.fetch(key))
69
+ config[key] = { 'secure' => encrypted }
70
+ end
71
+
72
+ def configure(key, value = {}, config = travis_config)
73
+ error "#{key} section already exists in .travis.yml, run with --force to override" if config.include? key and not force?
74
+ result = yield(config[key] = value)
75
+ save_travis_config
76
+ result
77
+ end
78
+ end
79
+ end
80
+ end
@@ -4,7 +4,9 @@ module Travis
4
4
  module CLI
5
5
  class Show < RepoCommand
6
6
  def run(number = last_build.number)
7
+ number = repository.branch(number).number if number !~ /^\d+(\.\d+)?$/ and repository.branch(number)
7
8
  entity = job(number) || build(number)
9
+
8
10
  error "unknown build or job #{number}" unless entity
9
11
 
10
12
  say template(__FILE__) % [
@@ -7,6 +7,9 @@ module Travis
7
7
  def run
8
8
  say Travis::VERSION
9
9
  end
10
+
11
+ def check_version
12
+ end
10
13
  end
11
14
  end
12
15
  end
@@ -16,6 +16,7 @@ module Travis
16
16
 
17
17
  one :build
18
18
  many :builds
19
+ aka :branches
19
20
 
20
21
  def restart
21
22
  session.restart(self)
@@ -64,6 +64,10 @@ module Travis
64
64
  end
65
65
  end
66
66
 
67
+ def name
68
+ slug[/[^\/]+$/]
69
+ end
70
+
67
71
  def public_key=(key)
68
72
  key = Key.new(key) unless key.is_a? Key
69
73
  set_attribute(:public_key, key)
@@ -104,6 +108,19 @@ module Travis
104
108
  builds({})
105
109
  end
106
110
 
111
+ def last_on_branch(name = nil)
112
+ return branch(name) if name
113
+ attributes['last_on_branch'] ||= session.get('branches', :repository_id => id)['branches']
114
+ end
115
+
116
+ def branches
117
+ last_on_branch.map { |b| { b.commit.branch => b } }.inject(:merge)
118
+ end
119
+
120
+ def branch(name)
121
+ last_on_branch.detect { |b| b.commit.branch == name.to_s }
122
+ end
123
+
107
124
  def each_build(params = nil, &block)
108
125
  return enum_for(__method__, params) unless block_given?
109
126
  params ||= {}
@@ -1,3 +1,3 @@
1
1
  module Travis
2
- VERSION = '1.2.8'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -21,6 +21,7 @@ module Helpers
21
21
 
22
22
  def run_cli(*args)
23
23
  args << ENV['TRAVIS_OPTS'] if ENV['TRAVIS_OPTS']
24
+ args << '--skip-version-check'
24
25
  capture do
25
26
  yield $stdin if block_given?
26
27
  $stdin.rewind
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  # general infos
4
4
  s.name = "travis"
5
- s.version = "1.2.8"
5
+ s.version = "1.3.0"
6
6
  s.description = "CLI and Ruby client library for Travis CI"
7
7
  s.homepage = "https://github.com/travis-ci/travis"
8
8
  s.summary = "Travis CI client"
@@ -46,6 +46,7 @@ Gem::Specification.new do |s|
46
46
  "lib/travis/cacert.pem",
47
47
  "lib/travis/cli.rb",
48
48
  "lib/travis/cli/api_command.rb",
49
+ "lib/travis/cli/branches.rb",
49
50
  "lib/travis/cli/command.rb",
50
51
  "lib/travis/cli/console.rb",
51
52
  "lib/travis/cli/disable.rb",
@@ -62,6 +63,7 @@ Gem::Specification.new do |s|
62
63
  "lib/travis/cli/raw.rb",
63
64
  "lib/travis/cli/repo_command.rb",
64
65
  "lib/travis/cli/restart.rb",
66
+ "lib/travis/cli/setup.rb",
65
67
  "lib/travis/cli/show.rb",
66
68
  "lib/travis/cli/status.rb",
67
69
  "lib/travis/cli/sync.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2013-07-19 00:00:00.000000000 Z
19
+ date: 2013-07-20 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: faraday
@@ -211,6 +211,7 @@ files:
211
211
  - lib/travis/cacert.pem
212
212
  - lib/travis/cli.rb
213
213
  - lib/travis/cli/api_command.rb
214
+ - lib/travis/cli/branches.rb
214
215
  - lib/travis/cli/command.rb
215
216
  - lib/travis/cli/console.rb
216
217
  - lib/travis/cli/disable.rb
@@ -227,6 +228,7 @@ files:
227
228
  - lib/travis/cli/raw.rb
228
229
  - lib/travis/cli/repo_command.rb
229
230
  - lib/travis/cli/restart.rb
231
+ - lib/travis/cli/setup.rb
230
232
  - lib/travis/cli/show.rb
231
233
  - lib/travis/cli/status.rb
232
234
  - lib/travis/cli/sync.rb