bait 0.3.0 → 0.3.1

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: 538ab60ada5752213726f9810c21f4b9a628925d
4
- data.tar.gz: 27fa1ecb9bc9e38a8db35a698b6e5c75fd534faf
3
+ metadata.gz: 79b2349cec35ff210520cda8f7a1e42a8cf337bd
4
+ data.tar.gz: d94204410a8ddc0d5a808e018ac416d74c162783
5
5
  SHA512:
6
- metadata.gz: 35c7dbf5f18c4779305b512d913b0cd74a1d2bfa6fe318a7b8603c366873b172c62ba398af03f104fd172981bf700ab2762d8fdc75b1e2f49b196e343eabdc33
7
- data.tar.gz: fa325bd7030acac83f71aa121efcfdbc24231b7f4dc3dffcab8bed7c270d759c6dcf62b07411c127e87071bc493bee518e3aa18dcfce19fbef4b31c33966fbba
6
+ metadata.gz: 826bd09db46bfd8df6df60210954f18ff602189f4a5730513255a978a47eaf86785260ec0a2f0a80a8e0ef481e621f7ad2a5fd3e42d4f3870848fd0bb02e1346
7
+ data.tar.gz: 4d132ee6b67f6af921ed23e6d9a5c462cdf19a81dd9811dc1737abfb48be5b39e7718ef8c275fa0d6dbcfaf01befc7c438bbc53bdcb9e03b930f54481e56722d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bait (0.2.1)
4
+ bait (0.3.1)
5
5
  git
6
6
  haml
7
7
  moneta
data/README.md CHANGED
@@ -9,19 +9,13 @@ Install the gem and then just run `bait`
9
9
 
10
10
  A sinatra server will start up. YAML files will be stored in ~/.bait
11
11
 
12
- Hit up 0.0.0.0:8417 to see what's up. You can set your Github to notify it and it will run your tests per the bait spec.
12
+ Go to 0.0.0.0:8417
13
13
 
14
- # Backstory
14
+ You can set your Github to notify the server on that port.
15
15
 
16
- https://github.com/DFTi/Scribbeo-motion already is designed in such a way that it vendors our existing iOS (completely written in Objective-C) application https://github.com/DFTi/Critique
16
+ When github notifies bait, bait will clone the project and execute ~/.bait/test.sh and record exit value and output
17
17
 
18
- This gave us a Ruby(Motion) environment where UIAutomator is available using MacBacon (like rspec)
19
-
20
- As a Ruby on Rails developer, this was invaluable... But the iOS developers we hired disliked it and did not maintain the RubyMotion stuff.
21
-
22
- Fast forward a year or so later and the app is complex, has no test suite, and our QA testers can barely keep up.
23
-
24
- Scribbeo-motion proved that this works, and so bait is a service I'm envisioning for as the first stop between Github and the rest of my continuous integration pipeline.
18
+ You may also test manually by inputting a clone URL within the UI
25
19
 
26
20
  # Architectural Overview
27
21
 
@@ -42,20 +36,26 @@ ______________________ \./
42
36
  | \|/ /|\ |
43
37
  | \[build]\ |
44
38
  | \|/ /|\ |
45
- | \|/ /|\ |
46
- | +------------+ |
39
+ | _____________ \|/ /|\ |
40
+ | [ your project] +------------+ |
47
41
  | [.bait/test.sh]------|Bait::Tester| |
48
- | +------------+ |
42
+ | [status/output] +------------+ |
49
43
  | |
50
44
  +-----------------------------------------------+
51
45
 
52
46
  Bait::Build -- Persistent ToyStore
53
47
 
54
- Bait::Tester -- Runs your tests and updates build accordingly
48
+ Bait::Tester -- Runs your tests and persists results in Bait::Build
55
49
  ```
56
50
 
57
51
  *Created with [JavE](http://www.jave.de/)*
58
52
 
53
+ # Datastore
54
+
55
+ You can use any datastore you want that is supported in [Moneta](https://github.com/minad/moneta)
56
+
57
+ By default, bait will store the data as YAML files in `~/bait`
58
+
59
59
  # Functional Overview
60
60
 
61
61
  ## Github Webhook Support
@@ -70,12 +70,12 @@ project. This file must exist in order to use bait: `.bait/test.sh`
70
70
  In this file you will run your test suite. **Be sure to make it
71
71
  executable `chmod a+x .bait/test.sh`**
72
72
 
73
- This file should output whatever you want to STDOUT/STDERR and return
74
- the correct exit value.
73
+ This file should output whatever you want to STDOUT and/or STDERR and
74
+ return 0 for passing and non-zero for failure.
75
75
 
76
76
  ### Examples
77
77
 
78
- #### Ruby / Rails Example (RSpec)
78
+ #### Ruby Projects
79
79
 
80
80
  ##### [project root]/.bait/test.sh
81
81
  ```bash
@@ -89,7 +89,7 @@ bundle install > /dev/null 2>&1
89
89
  bundle exec rspec spec
90
90
  ```
91
91
 
92
- #### RubyMotion Example
92
+ #### RubyMotion Projects
93
93
 
94
94
  ##### [project root]/.bait/test.sh
95
95
  ```bash
@@ -113,34 +113,33 @@ properly, that's why we are using
113
113
  [motion-specwrap](https://github.com/mdks/motion-specwrap) to run the
114
114
  tests and report the correct exit value
115
115
 
116
- ## Objective-C ?
117
-
118
- So you can see how bait will run any test suite via arbitrary bash
119
- scripts upon a Github hook.
116
+ #### Objective-C Projects
120
117
 
121
- But how exactly will it help add a ruby test suite to an Obj-C app?
118
+ Objective-C projects are supported if you're using [Calabash](http://calaba.sh)
122
119
 
123
- Watch this spot for some examples soon
124
-
125
- The basic idea however is to bootstrap a rubymotion project in your
126
- `test.sh` file, throw your Obj-C files into vendor/ and then setup your
127
- Rakefile like so:
120
+ ##### [project root]/.bait/test.sh
121
+ ```bash
122
+ #!/bin/bash
123
+ bait_dir=$(dirname $0)
124
+ project_dir="$bait_dir/.."
125
+ cd $project_dir
128
126
 
129
- ```ruby
130
- Motion::Project::App.setup do |app|
131
- app.name = 'My Wrapped Project'
127
+ export BUNDLE_GEMFILE=$project_dir/Gemfile
132
128
 
133
- %w[Tools Models Controllers Views].map{|i| app.vendor_project "vendor/SB/#{i}", :static }
134
- end
129
+ echo "bundling"
130
+ bundle install > /dev/null 2>&1
131
+ bundle exec cucumber
135
132
  ```
136
133
 
137
- Now that's just a preliminary example; I will try to make this very easy
138
- and conventional and then report my findings here.
134
+ #### Other Projects
139
135
 
140
- # Future
136
+ Create a file `.bait/test.sh` and `exit 0` if it passes or non-zero if
137
+ it does not pass. Output whatever you want to STDOUT or STDERR.
141
138
 
142
- ## Static Code Analysis
139
+ Feel free to send pull requests with examples if you end up using bait.
143
140
 
144
- Integrate [metric-fu](http://metric-fu.rubyforge.org/) for ruby apps and [OCLint](http://oclint.org/) for objective-c apps. Report these in Redis.
141
+ # Future Goals
145
142
 
143
+ ## Static Code Analysis
146
144
 
145
+ Integrate [metric-fu](http://metric-fu.rubyforge.org/) for ruby apps and [OCLint](http://oclint.org/) for objective-c apps, JSLint and JSure for javascript.
data/VERSION ADDED
@@ -0,0 +1,2 @@
1
+ 0.3.1
2
+
data/lib/bait/api.rb CHANGED
@@ -39,5 +39,13 @@ module Bait
39
39
  Build.destroy params["id"]
40
40
  redirect '/build'
41
41
  end
42
+
43
+ get '/build/retest/:id' do
44
+ build = Build.find params['id']
45
+ build.tested = false
46
+ build.test_later
47
+ build.save
48
+ redirect '/build'
49
+ end
42
50
  end
43
51
  end
data/lib/bait/build.rb CHANGED
@@ -40,11 +40,11 @@ module Bait
40
40
  self
41
41
  end
42
42
 
43
- after_destroy :remove_sandbox
44
-
45
- def remove_sandbox
46
- tester.cleanup!
43
+ def queued?
44
+ !self.reload.tested?
47
45
  end
48
46
 
47
+ after_destroy { tester.cleanup! }
48
+
49
49
  end
50
50
  end
data/lib/bait/project.rb CHANGED
@@ -8,7 +8,12 @@ module Bait
8
8
  end
9
9
 
10
10
  def glob pattern
11
- Dir.glob @path.join("**/#{pattern}")
11
+ cache ||= {}
12
+ if value = cache[pattern]
13
+ value
14
+ else
15
+ cache[pattern] = Dir.glob @path.join("**/#{pattern}")
16
+ end
12
17
  end
13
18
 
14
19
  def ordered_dependencies file_pattern, klass
data/lib/bait/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bait
2
- VERSION = "0.3.0"
2
+ VERSION = File.open(File.join(File.dirname(__FILE__), "..", "..", "VERSION")){|f| f.read.strip}
3
3
  end
@@ -17,6 +17,7 @@ Listing Builds
17
17
  %pre= build.output
18
18
  .actions
19
19
  %a{href:"/build/remove/#{build.id}"} Remove
20
+ %a{href:"/build/retest/#{build.id}"} Retest
20
21
 
21
22
  %hr
22
23
 
@@ -61,9 +61,7 @@ describe "Sinatra App" do
61
61
  build.ref.should eq "refs/heads/master"
62
62
  end
63
63
 
64
- it "will be tested later based on a flag" do
65
- build.should_not be_tested
66
- end
64
+ it { build.should be_queued }
67
65
  end
68
66
 
69
67
  describe "GET /" do
@@ -88,24 +86,40 @@ describe "Sinatra App" do
88
86
 
89
87
  describe "POST /build/create" do
90
88
  let(:test_url){ "http://github.com/defunkt/github" }
91
- it "can create a build manually" do
89
+ before do
92
90
  post '/build/create', {clone_url:test_url}
91
+ end
92
+ it "can create a build manually" do
93
93
  build.clone_url.should eq test_url
94
94
  end
95
+ specify { build.should be_queued }
95
96
  end
96
97
 
97
98
  describe "GET /build/remove/#" do
98
99
  before do
99
100
  @build = Bait::Build.create(name: "quickfox", clone_url:'...')
100
101
  @sandbox = @build.tester.sandbox_directory
102
+ get "/build/remove/#{@build.id}"
101
103
  end
102
104
  it "removes the build from store and its files from the filesystem" do
103
- Bait::Build.ids.should have(1).item
104
- get "/build/remove/#{@build.id}"
105
105
  expect{@build.reload}.to raise_error Toy::NotFound
106
106
  Bait::Build.ids.should be_empty
107
107
  Pathname.new(@sandbox).should_not exist
108
108
  end
109
+ it { should be_redirect }
110
+ end
111
+
112
+ describe "GET /build/retest/#" do
113
+ before do
114
+ @build = Bait::Build.create(name: "quickfox", clone_url:'...')
115
+ @build.tested = true
116
+ @build.save
117
+ get "/build/retest/#{@build.id}"
118
+ end
119
+ it "queues the build for retesting" do
120
+ build.should be_queued
121
+ end
122
+ it { should be_redirect }
109
123
  end
110
124
  end
111
125
  end
@@ -62,4 +62,17 @@ describe Bait::Build do
62
62
  Bait::Build.ids.should be_empty
63
63
  end
64
64
  end
65
+
66
+ describe "#queued" do
67
+ subject { build }
68
+ context "already tested" do
69
+ before { build.tested = true ; build.save }
70
+ it { should_not be_queued }
71
+ end
72
+
73
+ context "not tested" do
74
+ before { build.tested = false ; build.save }
75
+ it { should be_queued }
76
+ end
77
+ end
65
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bait
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keyvan Fatehi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-31 00:00:00.000000000 Z
11
+ date: 2013-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -209,6 +209,7 @@ files:
209
209
  - LICENSE
210
210
  - README.md
211
211
  - Rakefile
212
+ - VERSION
212
213
  - bait.gemspec
213
214
  - bin/bait
214
215
  - lib/bait.rb
@@ -252,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
253
  version: '0'
253
254
  requirements: []
254
255
  rubyforge_project:
255
- rubygems_version: 2.0.3
256
+ rubygems_version: 2.0.5
256
257
  signing_key:
257
258
  specification_version: 4
258
259
  summary: build and integration test service