cide 0.9.1 → 0.9.2

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: 1ea586f5df8d9c547427512c4615fbe2c343884e
4
- data.tar.gz: 91892bfa75d1067e822dbfe36ba561baf95961a2
3
+ metadata.gz: 81495b6767bc28da5ffbfd0c0193b416ca186354
4
+ data.tar.gz: 43e6044abe9fb0ff99febbea8415308688e42bf7
5
5
  SHA512:
6
- metadata.gz: 2fe876b32eea6d98b864cc93bd6c3009b229ed96d5279b5ad2e975a2476001cb144888dc75b79e2df04a584f789410e5287a3063610a8bf2b3eacc6c144e11c4
7
- data.tar.gz: 715361ce5cfefaef2ccc74d37ef09ea689bf33148477ace6982fa9b663cff9c56f5f206b35d9ef3c087498da98e51f71ad94a71f461162c24f8041523af32680
6
+ metadata.gz: fff6cb3795f75e91c6787c20b9f605c12bbf380bd2ab2bbdd5b5db73396521cd47f3ad7f4d40d68e9c87a4fc2b7bc9da6c2cf525c564678a8084db640b1848a3
7
+ data.tar.gz: 1db3d9839621779ac121782a38c2d8969c449615661e77076437b31ea7e9af0f639a420ddaafc7d9ee9c0c802f0e2e974771ba20b7048d86e0a5553655747ab9
@@ -46,6 +46,8 @@ Style/SpecialGlobalVars:
46
46
 
47
47
  # Allows for easy diffing
48
48
  # Keep them sorted alphabetically unless a meaningful order exists
49
- Style/TrailingComma:
49
+ Style/TrailingCommaInLiteral:
50
+ EnforcedStyleForMultiline: comma
51
+ Style/TrailingCommaInArguments:
50
52
  EnforcedStyleForMultiline: comma
51
53
 
data/Gemfile CHANGED
@@ -1,5 +1,2 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
-
4
- # Optional dependency, only used by `cide upload`
5
- gem 'aws-sdk', '~> 2'
@@ -1,33 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cide (0.9.0)
4
+ cide (0.9.2)
5
+ aws-sdk (~> 2)
5
6
  thor (~> 0.19)
6
7
  virtus (~> 1.0)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- activesupport (4.2.1)
12
+ activesupport (4.2.6)
12
13
  i18n (~> 0.7)
13
14
  json (~> 1.7, >= 1.7.7)
14
15
  minitest (~> 5.1)
15
16
  thread_safe (~> 0.3, >= 0.3.4)
16
17
  tzinfo (~> 1.1)
17
- ast (2.0.0)
18
- astrolabe (1.3.0)
19
- parser (>= 2.2.0.pre.3, < 3.0)
20
- aws-sdk (2.2.16)
21
- aws-sdk-resources (= 2.2.16)
22
- aws-sdk-core (2.2.16)
18
+ ast (2.2.0)
19
+ aws-sdk (2.2.31)
20
+ aws-sdk-resources (= 2.2.31)
21
+ aws-sdk-core (2.2.31)
23
22
  jmespath (~> 1.0)
24
- aws-sdk-resources (2.2.16)
25
- aws-sdk-core (= 2.2.16)
23
+ aws-sdk-resources (2.2.31)
24
+ aws-sdk-core (= 2.2.31)
26
25
  axiom-types (0.1.1)
27
26
  descendants_tracker (~> 0.0.4)
28
27
  ice_nine (~> 0.11.0)
29
28
  thread_safe (~> 0.3, >= 0.3.1)
30
- binman (4.0.0)
29
+ binman (5.1.0)
31
30
  opener (>= 0.1.0, < 1)
32
31
  coercible (1.0.0)
33
32
  descendants_tracker (~> 0.0.1)
@@ -38,42 +37,45 @@ GEM
38
37
  i18n (0.7.0)
39
38
  ice_nine (0.11.2)
40
39
  jmespath (1.1.3)
41
- json (1.8.1)
42
- md2man (4.0.0)
43
- binman (~> 4.0)
40
+ json (1.8.3)
41
+ md2man (5.1.1)
42
+ binman (~> 5.0)
44
43
  redcarpet (~> 3.0)
45
- minitest (5.4.3)
44
+ rouge (~> 1.0)
45
+ minitest (5.8.4)
46
46
  opener (0.1.0)
47
- parser (2.2.0.3)
48
- ast (>= 1.1, < 3.0)
49
- powerpack (0.1.0)
50
- rainbow (2.0.0)
51
- rake (10.4.2)
52
- redcarpet (3.3.1)
53
- rspec (3.2.0)
54
- rspec-core (~> 3.2.0)
55
- rspec-expectations (~> 3.2.0)
56
- rspec-mocks (~> 3.2.0)
57
- rspec-core (3.2.3)
58
- rspec-support (~> 3.2.0)
59
- rspec-expectations (3.2.1)
47
+ parser (2.3.0.7)
48
+ ast (~> 2.2)
49
+ powerpack (0.1.1)
50
+ rainbow (2.1.0)
51
+ rake (11.1.2)
52
+ redcarpet (3.3.4)
53
+ rouge (1.10.1)
54
+ rspec (3.4.0)
55
+ rspec-core (~> 3.4.0)
56
+ rspec-expectations (~> 3.4.0)
57
+ rspec-mocks (~> 3.4.0)
58
+ rspec-core (3.4.4)
59
+ rspec-support (~> 3.4.0)
60
+ rspec-expectations (3.4.0)
60
61
  diff-lcs (>= 1.2.0, < 2.0)
61
- rspec-support (~> 3.2.0)
62
- rspec-mocks (3.2.1)
62
+ rspec-support (~> 3.4.0)
63
+ rspec-mocks (3.4.1)
63
64
  diff-lcs (>= 1.2.0, < 2.0)
64
- rspec-support (~> 3.2.0)
65
- rspec-support (3.2.2)
66
- rubocop (0.30.0)
67
- astrolabe (~> 1.3)
68
- parser (>= 2.2.0.1, < 3.0)
65
+ rspec-support (~> 3.4.0)
66
+ rspec-support (3.4.1)
67
+ rubocop (0.39.0)
68
+ parser (>= 2.3.0.7, < 3.0)
69
69
  powerpack (~> 0.1)
70
70
  rainbow (>= 1.99.1, < 3.0)
71
- ruby-progressbar (~> 1.4)
71
+ ruby-progressbar (~> 1.7)
72
+ unicode-display_width (~> 1.0, >= 1.0.1)
72
73
  ruby-progressbar (1.7.5)
73
- thor (0.19.1)
74
+ thor (0.19.4)
74
75
  thread_safe (0.3.5)
75
76
  tzinfo (1.2.2)
76
77
  thread_safe (~> 0.1)
78
+ unicode-display_width (1.0.3)
77
79
  virtus (1.0.5)
78
80
  axiom-types (~> 0.1)
79
81
  coercible (~> 1.0)
@@ -85,7 +87,6 @@ PLATFORMS
85
87
 
86
88
  DEPENDENCIES
87
89
  activesupport
88
- aws-sdk (~> 2)
89
90
  cide!
90
91
  md2man
91
92
  rake
@@ -93,4 +94,4 @@ DEPENDENCIES
93
94
  rubocop
94
95
 
95
96
  BUNDLED WITH
96
- 1.10.6
97
+ 1.14.6
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
- *cide* - Isolated test runner with Docker
2
- =========================================
1
+ # *cide* - Isolated build tool and test runner with Docker
3
2
 
4
- *cide* is a command-line tool that runs tests in an isolated (docker)
3
+ *cide* is a command-line tool that builds packages and runs tests in an isolated (docker)
5
4
  environment. It solves a problem where Jenkins workers need all the project's
6
5
  dependencies (possibly conflicting) to be installed on the boxes. With *cide*
7
6
  each run gets its own set of temporary docker containers which are scratched
@@ -10,8 +9,7 @@ the developer machine and get the same build environment as on the CI. This
10
9
  makes configuration iterations much shorter and allows to converge on a
11
10
  working configuration faster.
12
11
 
13
- Usage
14
- -----
12
+ ## Usage
15
13
 
16
14
  Go to the target project's root and run `cide init` to populate a default
17
15
  `cide.yml`. This file contains all the instruction to build your project with
@@ -20,8 +18,7 @@ cide.
20
18
  Once the file is configured run `cide` to execute the build. All the output
21
19
  will appear in the console.
22
20
 
23
- Example
24
- -------
21
+ ## Example
25
22
 
26
23
  `cide.yml`
27
24
  ```yaml
@@ -39,8 +36,7 @@ run: bundle exec rspec
39
36
 
40
37
  See [the cide.yml man page](man/cide.yml.1.md) for the full documentation.
41
38
 
42
- Features
43
- --------
39
+ ## Features
44
40
 
45
41
  * straighforward to use, just run `cide` inside of your project
46
42
  * works on OSX with boot2docker
@@ -48,8 +44,7 @@ Features
48
44
  * can use linked containers for backend dependencies like MySQL or redis
49
45
  * artefact export
50
46
 
51
- Missing features
52
- ----------------
47
+ ## Missing features
53
48
 
54
49
  * Linked container readiness detection. Some containers take a while to boot
55
50
  up. Currently the `script/ci` must implement some sort of detection loop.
@@ -61,8 +56,7 @@ Missing features
61
56
 
62
57
  PR welcome !
63
58
 
64
- Installation
65
- ------------
59
+ ## Installation
66
60
 
67
61
  The current dependencies are [ruby
68
62
  2.0+](https://www.ruby-lang.org/en/documentation/installation/) and [docker
@@ -82,8 +76,7 @@ Then install the *cide* ruby gem:
82
76
  gem install cide
83
77
  ```
84
78
 
85
- Similar projects
86
- ----------------
79
+ ## Similar projects
87
80
 
88
81
  * [Docker Compose](https://docs.docker.com/compose/) - Docker development environment
89
82
  * [Travis CI](https://travis-ci.org/) - Great CI for Open Source projects
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'cide'
5
- s.version = '0.9.1'
6
- s.authors = ['zimbatm']
7
- s.email = ['zimbatm@zimbatm.com']
5
+ s.version = '0.9.2'
6
+ s.authors = ['pusher']
7
+ s.email = ['support@pusher.com']
8
8
  s.summary = 'Isolated test runner with Docker'
9
9
  s.description = <<DESC
10
10
  cide is a command-line tool that runs tests in an isolated (docker)
11
11
  environment. It allows to run the same command on the developer and CI
12
12
  machines.
13
13
  DESC
14
- s.homepage = 'https://zimbatm.github.io/cide'
14
+ s.homepage = 'https://pusher.github.io/cide'
15
15
  s.license = 'MIT'
16
16
 
17
17
  s.executables = ['cide']
@@ -21,6 +21,7 @@ DESC
21
21
 
22
22
  s.required_ruby_version = '>= 1.9.3'
23
23
 
24
+ s.add_runtime_dependency 'aws-sdk', '~> 2'
24
25
  s.add_runtime_dependency 'thor', '~> 0.19'
25
26
  s.add_runtime_dependency 'virtus', '~> 1.0'
26
27
  s.add_development_dependency 'activesupport'
@@ -14,12 +14,12 @@ module CIDE
14
14
  end
15
15
 
16
16
  def build(tag: nil, pull: nil, ssh_key: nil)
17
- fail ArgumentError, 'tag missing' unless tag
17
+ raise ArgumentError, 'tag missing' unless tag
18
18
 
19
19
  if config.use_ssh
20
- fail ArgumentError, 'ssh_key missing' unless ssh_key
20
+ raise ArgumentError, 'ssh_key missing' unless ssh_key
21
21
  unless File.exist?(ssh_key)
22
- fail ArgumentError, "ssh_key #{ssh_key} not found"
22
+ raise ArgumentError, "ssh_key #{ssh_key} not found"
23
23
  end
24
24
  create_tmp_file! TEMP_SSH_KEY, File.read(ssh_key)
25
25
  end
@@ -57,8 +57,6 @@ module CIDE
57
57
  default: '~/.ssh/id_rsa'
58
58
 
59
59
  def exec
60
- setup_docker
61
-
62
60
  tag = name_to_tag options.name
63
61
 
64
62
  banner 'Config'
@@ -93,7 +91,7 @@ module CIDE
93
91
 
94
92
  guest_dir = options.guest_export_dir || config.export_dir
95
93
  if guest_dir.nil?
96
- puts "Ignoring, missing export_dir"
94
+ puts 'Ignoring, missing export_dir'
97
95
  return
98
96
  end
99
97
 
@@ -141,7 +139,7 @@ module CIDE
141
139
  default: ENV['AWS_BUCKET']
142
140
 
143
141
  def package
144
- fail 'missing AWS_BUCKET' if options.upload && !options.aws_bucket
142
+ raise 'missing AWS_BUCKET' if options.upload && !options.aws_bucket
145
143
 
146
144
  tag = name_to_tag options.name
147
145
 
@@ -248,8 +246,6 @@ module CIDE
248
246
  desc: 'User to run under',
249
247
  default: 'cide'
250
248
  def debug
251
- setup_docker
252
-
253
249
  tag = name_to_tag options.name
254
250
 
255
251
  ## Config ##
@@ -287,18 +283,18 @@ module CIDE
287
283
  default: 20,
288
284
  type: :numeric
289
285
  def clean
290
- setup_docker
291
-
292
286
  days_to_keep = options[:days]
293
287
  max_images = options[:count]
294
288
 
295
- x = docker('images', '--no-trunc', capture: true)
296
- iter = x.lines.each
297
- iter.next
298
- cide_image_ids = iter
299
- .map { |line| line.split(/\s+/) }
300
- .select { |line| line[0] =~ %r{^cide[/-]} || line[0] == '<none>' }
301
- .map { |line| line[2] }
289
+ # Delete failed images
290
+ failed_filter = 'label=cide.build.complete=false'
291
+ cide_failed_image_ids = docker_image_ids(filter_by: failed_filter)
292
+ if cide_failed_image_ids.any?
293
+ docker('rmi', '--force', *cide_failed_image_ids)
294
+ end
295
+
296
+ # Retrieve all other cide images
297
+ cide_image_ids = docker_image_ids(filter_by: 'label=cide')
302
298
 
303
299
  if cide_image_ids.empty?
304
300
  puts 'No images found to be cleaned'
@@ -306,26 +302,27 @@ module CIDE
306
302
  end
307
303
 
308
304
  x = docker('inspect', *cide_image_ids, capture: true)
309
- cide_images = JSON.parse(x.strip)
305
+ cide_images =
306
+ JSON
307
+ .parse(x.strip)
310
308
  .each { |image| image['Created'] = Time.iso8601(image['Created']) }
311
309
  .sort { |a, b| a['Created'] <=> b['Created'] }
312
310
 
313
- if cide_images.size > max_images
314
- old_cide_images = cide_images[0..-max_images]
315
- .map { |image| image['Id'] }
316
- else
317
- old_times = Time.now - (days_to_keep * 24 * 60 * 60)
318
- old_cide_images = cide_images
319
- .select { |image| image['Created'] < old_times }
320
- .map { |image| image['Id'] }
321
- end
311
+ to_destroy = cide_images[max_images..-1]
312
+ leftover_images = cide_images[0..(max_images - 1)]
313
+
314
+ expire_from = Time.now - (days_to_keep * 24 * 60 * 60)
315
+ to_destroy <<
316
+ leftover_images.select { |image| image['Created'] < expire_from }
317
+
318
+ to_destroy_ids = to_destroy.map { |image| image['Id'] }
322
319
 
323
- if old_cide_images.empty?
320
+ if to_destroy_ids.empty?
324
321
  puts 'No images found to be cleaned'
325
322
  return
326
323
  end
327
324
 
328
- docker('rmi', '--force', *old_cide_images)
325
+ docker('rmi', '--force', *to_destroy_ids)
329
326
  end
330
327
 
331
328
  desc 'init', "Creates a blank #{CONFIG_FILES.first} in the project"
@@ -102,7 +102,7 @@ module CIDE
102
102
  paths = CONFIG_FILES.map { |name| File.expand_path(name, dir) }
103
103
  paths
104
104
  .find { |path| File.exist?(path) } ||
105
- fail("Config not found among these paths: #{paths.inspect}")
105
+ raise("Config not found among these paths: #{paths.inspect}")
106
106
  end
107
107
  end
108
108
  end
@@ -311,11 +311,12 @@ module CIDE
311
311
  value.each_pair do |key, value_|
312
312
  key = key.to_s
313
313
  path_ = path.append(key)
314
- if value_.nil?
315
- value_ = expect_env(path_, key)
316
- else
317
- value_ = expect_string(path_, value_)
318
- end
314
+ value_ =
315
+ if value_.nil?
316
+ expect_env(path_, key)
317
+ else
318
+ expect_string(path_, value_)
319
+ end
319
320
  hash[key.to_s] = value_ if value_
320
321
  end
321
322
  else
@@ -1,12 +1,12 @@
1
1
  module CIDE
2
2
  dir = File.expand_path('..', __FILE__)
3
- DOCKERFILE = 'Dockerfile.cide'
3
+ DOCKERFILE = 'Dockerfile.cide'.freeze
4
4
  DEFAULT_CIDEFILE = File.join(dir, 'default_cide.yml')
5
- TEMP_SSH_KEY = 'id_rsa.tmp'
6
- SSH_CONFIG_FILE = 'ssh_config'
5
+ TEMP_SSH_KEY = 'id_rsa.tmp'.freeze
6
+ SSH_CONFIG_FILE = 'ssh_config'.freeze
7
7
  SSH_CONFIG_PATH = File.join(dir, SSH_CONFIG_FILE)
8
- CONFIG_FILES = ['cide.yml', '.cide.yml']
9
- CIDE_DIR = '/cide'
8
+ CONFIG_FILES = ['cide.yml', '.cide.yml'].freeze
9
+ CIDE_DIR = '/cide'.freeze
10
10
  CIDE_SRC_DIR = File.join(CIDE_DIR, 'src')
11
11
  CIDE_SSH_DIR = File.join(CIDE_DIR, '.ssh')
12
12
  end
@@ -5,7 +5,7 @@ module CIDE
5
5
  module Docker
6
6
  # Generates a valid id for docker from any string
7
7
  def self.id(str)
8
- "#{str}".downcase.gsub(/[^a-z0-9\-_.]/, '_')
8
+ str.to_s.downcase.gsub(/[^a-z0-9\-_.]/, '_')
9
9
  end
10
10
 
11
11
  # Raised when a docker command exits with a status higher than zero
@@ -19,6 +19,15 @@ module CIDE
19
19
 
20
20
  class VersionError < StandardError; end
21
21
 
22
+ def docker_image_ids(filter_by: false)
23
+ args = ['--no-trunc']
24
+ args << ['--filter', filter_by] if filter_by
25
+ lines = docker('images', *args, capture: true).lines[1..-1]
26
+ lines
27
+ .map { |line| line.split(/\s+/) }
28
+ .map { |line| line[2] }
29
+ end
30
+
22
31
  def docker(*args, verbose: false, capture: false)
23
32
  cmd = (['docker'] + args).map(&:to_s)
24
33
  p cmd if verbose
@@ -36,30 +45,7 @@ module CIDE
36
45
  ensure
37
46
  Process.wait(pid)
38
47
  exitstatus = $?.exitstatus
39
- fail Error, exitstatus if exitstatus > 0
40
- end
41
-
42
- protected
43
-
44
- def setup_docker
45
- @setup_docker ||= (
46
- # Check docker version
47
- docker_version = nil
48
- case `docker version 2>/dev/null`
49
- when /Client version: ([^\s]+)/
50
- docker_version = $1
51
- when /\s+Version:\s+([^\s]+)/
52
- docker_version = $1
53
- else
54
- fail VersionError, 'Unknown docker version'
55
- end
56
-
57
- if Gem::Version.new(docker_version) < Gem::Version.new('1.5.0')
58
- fail VersionError, "Docker version #{$1} too old"
59
- end
60
-
61
- true
62
- )
48
+ raise Error, exitstatus if exitstatus > 0
63
49
  end
64
50
  end
65
51
  end
@@ -1,4 +1,7 @@
1
1
  FROM <%= from %>
2
+ LABEL cide=""
3
+ LABEL cide.build.complete="false"
4
+
2
5
  USER root
3
6
  RUN useradd -m -U -d <%= CIDE_DIR %> cide
4
7
 
@@ -55,3 +58,4 @@ USER root
55
58
  ADD . <%= CIDE_SRC_DIR %>
56
59
  RUN chown -R cide:cide <%= CIDE_DIR %>
57
60
  USER cide
61
+ LABEL cide.build.complete="true"
@@ -13,7 +13,7 @@ module CIDE
13
13
  tag: nil,
14
14
  user: nil
15
15
  )
16
- fail ArgumentError, 'tag missing' unless tag
16
+ raise ArgumentError, 'tag missing' unless tag
17
17
 
18
18
  @containers = []
19
19
  @id = SecureRandom.hex
@@ -54,8 +54,8 @@ module CIDE
54
54
  end
55
55
 
56
56
  def export!(guest_dir: nil, host_dir: nil)
57
- fail ArgumentError, 'guest export_dir missing' unless guest_dir
58
- fail ArgumentError, 'host export_dir missing' unless host_dir
57
+ raise ArgumentError, 'guest export_dir missing' unless guest_dir
58
+ raise ArgumentError, 'host export_dir missing' unless host_dir
59
59
 
60
60
  # FIXME: strip trailing slashes ?
61
61
  guest_dir = File.expand_path(guest_dir, CIDE_SRC_DIR)
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
- - zimbatm
7
+ - pusher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: thor
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -113,7 +127,7 @@ description: |
113
127
  environment. It allows to run the same command on the developer and CI
114
128
  machines.
115
129
  email:
116
- - zimbatm@zimbatm.com
130
+ - support@pusher.com
117
131
  executables:
118
132
  - cide
119
133
  extensions: []
@@ -158,7 +172,7 @@ files:
158
172
  - script/ci
159
173
  - spec/build_config_loader_spec.rb
160
174
  - spec/spec_helper.rb
161
- homepage: https://zimbatm.github.io/cide
175
+ homepage: https://pusher.github.io/cide
162
176
  licenses:
163
177
  - MIT
164
178
  metadata: {}
@@ -178,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
192
  version: '0'
179
193
  requirements: []
180
194
  rubyforge_project:
181
- rubygems_version: 2.6.2
195
+ rubygems_version: 2.5.2
182
196
  signing_key:
183
197
  specification_version: 4
184
198
  summary: Isolated test runner with Docker