aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Vagrantfile6
-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
6 files changed, 23 insertions, 44 deletions
diff --git a/Vagrantfile b/Vagrantfile
index 4d53c60..da92aae 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -1,13 +1,13 @@
Vagrant.configure(2) do |config|
config.vm.box = 'gentoo-amd64'
- config.vm.box_url = 'http://vagrant.p8952.info/gentoo-amd64-aws-1418910301.box'
- config.vm.synced_folder '.', '/vagrant', type: 'rsync', rsync__exclude: ['gentoo-x86/', 'web/'], :rsync_excludes => ['gentoo-x86/', 'web/']
+ config.vm.provision "shell", path: "conf/provision.sh"
config.vm.provider :aws do |aws, override|
+ config.vm.box_url = 'http://vagrant.p8952.info/gentoo-amd64-aws-1418910301.box'
+ config.vm.synced_folder '.', '/vagrant', type: 'rsync', rsync__exclude: ['gentoo-x86/', 'web/'], :rsync_excludes => ['gentoo-x86/', 'web/']
aws.instance_type = 't2.micro'
aws.region = 'eu-west-1'
aws.keypair_name = 'AWS-Key'
override.ssh.username = 'ec2-user'
override.ssh.private_key_path = '~/.ssh/AWS-Key.pem'
end
- config.vm.provision "shell", path: "conf/provision.sh"
end
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