aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorPeter Wilmott <p@p8952.info>2015-01-10 15:32:57 +0000
committerPeter Wilmott <p@p8952.info>2015-01-10 16:21:05 +0000
commit69af0e6866bc8f4a6236201038a22c1138252b5b (patch)
treeeeed9668e813ae0dfe92c2283647bee2665cefb6 /web
parentDon't use slots in any identifiers (diff)
downloadruby-tinderbox-69af0e6866bc8f4a6236201038a22c1138252b5b.tar.gz
ruby-tinderbox-69af0e6866bc8f4a6236201038a22c1138252b5b.tar.bz2
ruby-tinderbox-69af0e6866bc8f4a6236201038a22c1138252b5b.zip
Wrap calls to AWS in vagrant_rbapi to allow running on other platforms
Diffstat (limited to 'web')
-rw-r--r--web/Gemfile2
-rw-r--r--web/Gemfile.lock15
-rw-r--r--web/Rakefile11
-rw-r--r--web/app.rb3
-rw-r--r--web/lib/ci.rb30
5 files changed, 20 insertions, 41 deletions
diff --git a/web/Gemfile b/web/Gemfile
index 58262d6..d7c7051 100644
--- a/web/Gemfile
+++ b/web/Gemfile
@@ -1,6 +1,5 @@
source 'https://rubygems.org'
-gem 'aws-sdk'
gem 'gems'
gem 'net-scp'
gem 'net-ssh'
@@ -9,6 +8,7 @@ gem 'pmap'
gem 'puma'
gem 'sequel'
gem 'sinatra'
+gem 'vagrant_rbapi'
group :development do
gem 'minitest'
diff --git a/web/Gemfile.lock b/web/Gemfile.lock
index 103e9d2..33c2b7f 100644
--- a/web/Gemfile.lock
+++ b/web/Gemfile.lock
@@ -4,28 +4,19 @@ GEM
ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
- aws-sdk (1.58.0)
- aws-sdk-v1 (= 1.58.0)
- aws-sdk-v1 (1.58.0)
- json (~> 1.4)
- nokogiri (>= 1.4.4)
celluloid (0.16.0)
timers (~> 4.0.0)
ffi (1.9.6)
gems (0.8.3)
hitimes (1.2.2)
- json (1.8.0)
listen (2.8.0)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
- mini_portile (0.6.0)
minitest (2.5.1)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
- nokogiri (1.6.3.1)
- mini_portile (= 0.6.0)
parser (2.2.0.pre.8)
ast (>= 1.1, < 3.0)
slop (~> 3.4, >= 3.4.5)
@@ -40,6 +31,7 @@ GEM
rack-test (0.6.2)
rack (>= 1.0)
rainbow (2.0.0)
+ rake (10.4.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
@@ -62,12 +54,14 @@ GEM
tilt (1.4.1)
timers (4.0.1)
hitimes
+ vagrant_rbapi (0.0.1)
+ net-ssh
+ rake
PLATFORMS
ruby
DEPENDENCIES
- aws-sdk
gems
minitest
net-scp
@@ -81,3 +75,4 @@ DEPENDENCIES
sequel
sinatra
sqlite3
+ vagrant_rbapi
diff --git a/web/Rakefile b/web/Rakefile
index ba68c7f..3956dc2 100644
--- a/web/Rakefile
+++ b/web/Rakefile
@@ -1,11 +1,8 @@
require_relative 'app'
-task default: 'unit:test'
-
-namespace :unit do
- task :test do
- Dir.glob('./test/test_*.rb') { |f| require f }
- end
+task default: 'test'
+task :test do
+ Dir.glob('./test/test_*.rb') { |f| require f }
end
namespace :db do
@@ -29,7 +26,7 @@ namespace :db do
end
end
-namespace :aws do
+namespace :vm do
task :run_ci_all do
run_ci(:all)
end
diff --git a/web/app.rb b/web/app.rb
index e1c0bd3..9008fa6 100644
--- a/web/app.rb
+++ b/web/app.rb
@@ -1,4 +1,3 @@
-require 'aws-sdk'
require 'gems'
require 'logger'
require 'net/scp'
@@ -6,8 +5,8 @@ require 'net/ssh'
require 'pmap'
require 'sequel'
require 'sinatra/base'
+require 'vagrant_rbapi'
-require_relative 'lib/aws'
require_relative 'lib/ci'
require_relative 'lib/helpers'
require_relative 'lib/models'
diff --git a/web/lib/ci.rb b/web/lib/ci.rb
index 7514a14..98a1ec2 100644
--- a/web/lib/ci.rb
+++ b/web/lib/ci.rb
@@ -21,30 +21,18 @@ def run_ci(num_of_packages)
end
begin
- instance, key_pair = start_instance
- file_path = File.dirname(File.dirname(File.expand_path(File.dirname(__FILE__))))
+ vagrant_path = File.dirname(File.dirname(File.expand_path(File.dirname(__FILE__))))
+ vagrant = Vagrant_Rbapi.new(vagrant_path)
+ vagrant.up
+ sleep 5 while vagrant.status != 'running'
+ config = vagrant.ssh_config
+ vagrant.ssh('sudo /vagrant/tinder.sh ' + packages.join(' '))
- Net::SCP.start(instance.ip_address, 'ec2-user', key_data: [key_pair.private_key]) do |scp|
- scp.upload!(file_path + '/conf', '/home/ec2-user', recursive: true)
- scp.upload!(file_path + '/tinder.sh', '/home/ec2-user/tinder.sh')
+ Net::SCP.start(config[0], config[1], port: config[2], key_data: [File.read(config[3])]) do |scp|
+ scp.download!('/home/ec2-user/ci-logs', vagrant_path + '/web', recursive: true)
end
-
- Net::SSH.start(instance.ip_address, 'ec2-user', key_data: [key_pair.private_key]) do |ssh|
- ssh.exec!('sudo /home/ec2-user/conf/provision.sh') do |_ch, _stream, data|
- puts data
- end
- ssh.exec!('sudo /home/ec2-user/tinder.sh ' + packages.join(' ')) do |_ch, _stream, data|
- puts data
- end
- end
-
- Net::SCP.start(instance.ip_address, 'ec2-user', key_data: [key_pair.private_key]) do |scp|
- scp.download!('/home/ec2-user/ci-logs', file_path + '/web', recursive: true)
- end
- rescue => e
- puts e
ensure
- delete_instance(instance)
+ vagrant.destroy
end
end