Permalink
Browse files

add a build_script service so we can serve the script from the api

  • Loading branch information...
1 parent 7805b0d commit 1f84a2ebe4989f5cdd883f2c3283e084db51fcf4 @svenfuchs svenfuchs committed Dec 29, 2012
View
@@ -1,6 +1,8 @@
source :rubygems
-gem 'travis-support', :git => 'git://github.com/travis-ci/travis-support.git'
+gem 'travis-core', github: 'travis-ci/travis-core'
+gem 'travis-support', github: 'travis-ci/travis-support'
+gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs' # siggggghhhhh ......
group :test do
gem 'mocha', '~> 0.10.0'
View
@@ -4,6 +4,7 @@ module Travis
module Build
autoload :Data, 'travis/build/data'
autoload :Script, 'travis/build/script'
+ autoload :Services, 'travis/build/services'
autoload :Shell, 'travis/build/shell'
HOME_DIR = '~'
@@ -15,6 +16,10 @@ module Build
}
class << self
+ def self.register(key)
+ Travis.services.add(key, self)
+ end
+
def script(data)
data = data.deep_symbolize_keys
lang = (Array(data[:language]).first || 'ruby').downcase.strip
@@ -0,0 +1,13 @@
+module Travis
+ module Build
+ module Services
+ autoload :BuildScript, 'travis/build/services/build_script'
+
+ class << self
+ def register
+ constants(false).each { |name| const_get(name) }
+ end
+ end
+ end
+ end
+end
@@ -0,0 +1,25 @@
+require 'travis'
+
+module Travis
+ module Build
+ module Services
+ class BuildScript < Travis::Services::Base
+ register :build_script
+
+ def run
+ Travis::Build.script(data).compile
+ end
+
+ private
+
+ def data
+ Travis::Api.data(job, for: 'worker', type: 'Job::Test', version: 'v0')
+ end
+
+ def job
+ run_service(:find_job, id: params[:id])
+ end
+ end
+ end
+ end
+end
View
@@ -3,7 +3,7 @@
$: << 'lib'
require 'travis/build'
-config = {
+data = {
urls: {
logs: 'http://localhost:3000/jobs/1/logs',
# state: 'http://localhost:3000/jobs/1/state', # not sure about this ...
@@ -35,7 +35,7 @@
}
}
-script = Travis::Build.script(config)
+script = Travis::Build.script(data)
script = script.compile
puts script
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe Travis::Build::Services::BuildScript do
+ include Travis::Testing::Stubs
+
+ let(:service) { Travis.service(:build_script, id: test.id) }
+
+ before :each do
+ service.stubs(:run_service).with(:find_job, id: test.id).returns(test)
+ end
+
+ it 'generates the build script for the given job' do
+ service.run.should include('travis_start')
+ end
+end
View
@@ -1,5 +1,6 @@
require 'fileutils'
require 'travis/build'
+
require 'support/matchers'
require 'support/payloads'
require 'shared/jdk'
@@ -46,9 +47,9 @@ def gemfile(name)
FileUtils.mkdir 'tmp'
end
- c.after :each do
- puts subject if example.failed?
- end
+ # c.after :each do
+ # puts subject if example.failed?
+ # end
end
class RSpec::Core::Example

0 comments on commit 1f84a2e

Please sign in to comment.