egads 1.0.1 → 2.0.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: 37e1fd020a9d28870ef833d93bd276c14550c0f8
4
- data.tar.gz: ecaa1a3ffd459bde6121a6cab1a2d74c1abbf75c
3
+ metadata.gz: 528b9ad77f674b120f2e3d8b64a72e24a4d16f59
4
+ data.tar.gz: db4985e423a4d2d265f259c4e457423264ed3dd0
5
5
  SHA512:
6
- metadata.gz: ae11430a823ac2e4d0d3e25d6d9a780027f731914632c0680586fec49d82f91c1df2a024786878556261724a05e37f8372176e03e37ecd075ad987c8cc52f17c
7
- data.tar.gz: 030626a7e708937b55f1f81d63f1f9899fc9245f34692c657abe5c45479104d5066c62759ea24129c6ca04b69ceecc77dda7bdc450f642b9f7a9b78a2d6c9bb9
6
+ metadata.gz: 14506e0b510f897e04de81aa7805719675a79456d933f1bdf59ae3f0b5e9e5dcaca4fdc2416e1f40d48d2c397213e64b5c3a62b70e87125a9f00018a7a70d958
7
+ data.tar.gz: e4c504af004f30c2bdc69f6f8a883a7c66b865f79f77f2a844019078afbc43d47fe9a3c7f95874fcffe8a0e9b2bcca7a2b79e00bde2f8ae1b7cdd21480b25899
data/README.md CHANGED
@@ -31,8 +31,9 @@ Commands are either *porcelain* commands that you should call directly as part o
31
31
 
32
32
  ### Local commands
33
33
 
34
+ * `egads check [SHA]` - checks if a deployable tarball of the current commit exists on S3.
34
35
  * `egads build [SHA]` - makes a deployable tarball of the current commit and upload it to S3 (if missing).
35
- * `egads upload SHA` - (plumbing, called by `build`) Uploads a pre-built tarball
36
+ * `egads upload SHA` - (plumbing, called by `build`) Uploads a pre-built tarball.
36
37
 
37
38
  ### Remote commands
38
39
 
@@ -9,7 +9,7 @@ Capistrano::Configuration.instance.load do
9
9
  namespace :deploy do
10
10
  desc "Deploy"
11
11
  task :default do
12
- deploy.upload
12
+ deploy.check
13
13
  deploy.stage
14
14
  deploy.release
15
15
  end
@@ -32,9 +32,12 @@ Capistrano::Configuration.instance.load do
32
32
  end
33
33
 
34
34
  desc "Checks that a deployable tarball is on S3; creates it if missing"
35
- task :upload do
36
- `bundle exec egads build #{full_sha}`
37
- abort "Failed to upload build" if $?.exitstatus != 0
35
+ task :check do
36
+ logger.info "Checking tarball for #{full_sha}"
37
+ logger.info "To build the tarball locally, run `bundle exec egads build #{full_sha}"
38
+ logger.info "Waiting for tarball..."
39
+ `bundle exec egads check --wait #{full_sha}`
40
+ abort "Failed to check build" if $?.exitstatus != 0
38
41
  end
39
42
  end
40
43
  end
@@ -1,5 +1,7 @@
1
1
  module Egads
2
2
  class Command < Thor
3
+ require 'egads/local_helpers'
4
+ require 'egads/command/check'
3
5
  require 'egads/command/build'
4
6
  require 'egads/command/upload'
5
7
  require 'egads/command/extract'
@@ -7,6 +9,7 @@ module Egads
7
9
  require 'egads/command/release'
8
10
  require 'egads/command/trim'
9
11
 
12
+ register(Check, 'check', 'check [REV]', '[local] Checks if a deployable tarball of the current commit already exists on S3')
10
13
  register(Build, 'build', 'build [REV]', '[local] Compiles a deployable tarball of the current commit and uploads it to S3')
11
14
  register(Upload, 'upload', 'upload SHA', '[local, plumbing] Uploads a tarball for SHA to S3')
12
15
  register(Extract, 'extract', 'extract SHA', '[remote, plumbing] Downloads tarball for SHA from S3 and extracts it to the filesystem')
@@ -1,17 +1,16 @@
1
1
  module Egads
2
2
  class Build < Group
3
3
  include Thor::Actions
4
+ include Egads::LocalHelpers
4
5
 
5
6
  desc "[local] Compiles a deployable tarball of the current commit and uploads it to S3"
6
7
  class_option :force, type: :boolean, aliases: '-f', default: false, banner: "Build and overwrite existing tarball on S3"
7
- class_option :wait, type: :boolean, aliases: '-w', default: false, banner: "Wait for the build to exist. Poll S3 every 2 seconds."
8
8
  class_option 'no-upload', type: :boolean, default: false, banner: "Don't upload the tarball to S3"
9
9
  argument :rev, type: :string, default: 'HEAD', desc: 'git revision to build'
10
10
 
11
11
  def check_build
12
12
  say_status :rev, "#{rev} parsed to #{sha}"
13
13
 
14
- wait_for_build if options[:wait]
15
14
  unless should_build?
16
15
  say_status :done, "Tarball for #{sha} already exists. Pass --force to rebuild."
17
16
  exit 0
@@ -52,18 +51,6 @@ module Egads
52
51
  end
53
52
 
54
53
  module BuildHelpers
55
- def sha
56
- @sha ||= run_with_code("git rev-parse --verify #{rev}").strip
57
- end
58
-
59
- def short_sha
60
- sha[0,7]
61
- end
62
-
63
- def tarball
64
- @tarball ||= S3Tarball.new(sha)
65
- end
66
-
67
54
  def should_build?
68
55
  options[:force] || !tarball.exists?
69
56
  end
@@ -97,17 +84,6 @@ module Egads
97
84
  false
98
85
  end
99
86
 
100
- def wait_for_build
101
- say_status :wait, "Waiting for tarball to exist...", :yellow
102
- loop do
103
- start = Time.now
104
- break if tarball.exists?
105
- printf '.'
106
- sleep [2 - (Time.now - start), 0].max
107
- end
108
- printf "\n"
109
- end
110
-
111
87
  end
112
88
  include BuildHelpers
113
89
  end
@@ -0,0 +1,37 @@
1
+ module Egads
2
+ class Check < Group
3
+ include Thor::Actions
4
+ include Egads::LocalHelpers
5
+
6
+ desc "[local] Checks if a deployable tarball of the current commit already exists on S3"
7
+ class_option :wait, type: :boolean, aliases: '-w', default: false, banner: "Wait for the build to exist. Poll S3 every 2 seconds."
8
+ argument :rev, type: :string, default: 'HEAD', desc: 'git revision to check'
9
+
10
+ def check
11
+ say_status :rev, "#{rev} parsed to #{sha}"
12
+
13
+ wait_for_build if options[:wait]
14
+
15
+ if tarball.exists?
16
+ say_status :exists, "Tarball for #{sha} exists"
17
+ exit 0
18
+ else
19
+ say_status :missing, "Tarball for #{sha} does not exist", :red
20
+ exit 1
21
+ end
22
+ end
23
+
24
+ protected
25
+ def wait_for_build
26
+ say_status :wait, "Waiting for tarball to exist...", :yellow
27
+ loop do
28
+ start = Time.now
29
+ break if tarball.exists?
30
+ printf '.'
31
+ sleep [1 - (Time.now - start), 0].max
32
+ end
33
+ printf "\n"
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,17 @@
1
+ module Egads
2
+ # Some helper methods for `check` and `upload`
3
+ module LocalHelpers
4
+ def sha
5
+ @sha ||= run_with_code("git rev-parse --verify #{rev}").strip
6
+ end
7
+
8
+ def short_sha
9
+ sha[0,7]
10
+ end
11
+
12
+ def tarball
13
+ @tarball ||= S3Tarball.new(sha)
14
+ end
15
+
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Egads
2
- VERSION = '1.0.1'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -9,21 +9,21 @@ describe "Egads::Build" do
9
9
  end
10
10
 
11
11
  it 'takes one argument' do
12
- subject.arguments.size.must_equal 1
12
+ subject.arguments.size.must_equal 1
13
13
  end
14
14
 
15
15
  it 'has a rev argument' do
16
- rev = subject.arguments.detect{|arg| arg.name == 'rev'}
17
- rev.default.must_equal 'HEAD'
18
- rev.required.must_equal false
16
+ rev = subject.arguments.detect{|arg| arg.name == 'rev'}
17
+ rev.default.must_equal 'HEAD'
18
+ rev.required.must_equal false
19
19
  end
20
20
 
21
21
  end
22
22
 
23
23
  describe "Egags::Build instance" do
24
- subject { Egads::Build.new }
25
-
26
- it "has rev HEAD" do
27
- subject.rev.must_equal 'HEAD'
28
- end
29
- end
24
+ subject { Egads::Build.new }
25
+
26
+ it "has rev HEAD" do
27
+ subject.rev.must_equal 'HEAD'
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe "Egads::Check" do
4
+ setup_configs!
5
+ subject { Egads::Check }
6
+
7
+ it 'should run the correct tasks' do
8
+ subject.commands.keys.must_equal %w(check)
9
+ end
10
+
11
+ it 'takes one argument' do
12
+ subject.arguments.size.must_equal 1
13
+ end
14
+
15
+ it 'has a rev argument' do
16
+ rev = subject.arguments.detect{|arg| arg.name == 'rev'}
17
+ rev.default.must_equal 'HEAD'
18
+ rev.required.must_equal false
19
+ end
20
+
21
+ end
22
+
23
+ describe "Egags::Build instance" do
24
+ subject { Egads::Check.new }
25
+
26
+ it "has rev HEAD" do
27
+ subject.rev.must_equal 'HEAD'
28
+ end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: egads
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Suggs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-03 00:00:00.000000000 Z
11
+ date: 2013-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
@@ -92,6 +92,7 @@ files:
92
92
  - lib/egads/capistrano.rb
93
93
  - lib/egads/command.rb
94
94
  - lib/egads/command/build.rb
95
+ - lib/egads/command/check.rb
95
96
  - lib/egads/command/extract.rb
96
97
  - lib/egads/command/release.rb
97
98
  - lib/egads/command/stage.rb
@@ -99,9 +100,11 @@ files:
99
100
  - lib/egads/command/upload.rb
100
101
  - lib/egads/config.rb
101
102
  - lib/egads/group.rb
103
+ - lib/egads/local_helpers.rb
102
104
  - lib/egads/s3_tarball.rb
103
105
  - lib/egads/version.rb
104
106
  - spec/egads_build_spec.rb
107
+ - spec/egads_check_spec.rb
105
108
  - spec/egads_config_spec.rb
106
109
  - spec/egads_extract_spec.rb
107
110
  - spec/egads_release_spec.rb
@@ -136,6 +139,7 @@ specification_version: 4
136
139
  summary: Extensible Git Archive Deploy Strategy
137
140
  test_files:
138
141
  - spec/egads_build_spec.rb
142
+ - spec/egads_check_spec.rb
139
143
  - spec/egads_config_spec.rb
140
144
  - spec/egads_extract_spec.rb
141
145
  - spec/egads_release_spec.rb