evrone-ci-worker 0.2.0.pre1 → 0.2.0.pre3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +4 -1
- data/bin/evrone-ci-worker +9 -8
- data/docker/Dockerfile +4 -48
- data/docker/bootstrap.sh +66 -0
- data/docker/sv-gen +1 -1
- data/lib/evrone/ci/worker.rb +1 -0
- data/lib/evrone/ci/worker/configuration.rb +1 -0
- data/lib/evrone/ci/worker/docker.rb +1 -0
- data/lib/evrone/ci/worker/job.rb +10 -6
- data/lib/evrone/ci/worker/middlewares/docker_fetch_repo.rb +1 -4
- data/lib/evrone/ci/worker/middlewares/docker_start_container.rb +3 -2
- data/lib/evrone/ci/worker/middlewares/docker_webdav_cache.rb +95 -0
- data/lib/evrone/ci/worker/middlewares/update_job_status.rb +4 -0
- data/lib/evrone/ci/worker/version.rb +1 -1
- data/spec/lib/worker/job_spec.rb +47 -7
- data/spec/lib/worker/middlewares/docker_fetch_repo_spec.rb +1 -1
- data/spec/lib/worker/middlewares/docker_webdav_cache_spec.rb +49 -0
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5891371d77f52eeae58e9692fcd97e024584903
|
4
|
+
data.tar.gz: 45e7c0f16129b0b79df1e076b11e638d7608cc40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3331e43272c6b1bfe6d8d5e778f5c097a168a393cf65959a0610ad04b94550b96bbac8f03a10ce80fc5555870bd52a41fc2a19a3d69a8c59a07ee834434856a
|
7
|
+
data.tar.gz: 248eaaad99449fffe60e1c545ede8383f4d51cc4ebe89eb7b059baa7ad32c965daf6a5354c2a894f66dbd8c07797d2b22589e16713a58dca459b130d5479e435
|
data/Rakefile
CHANGED
@@ -6,9 +6,11 @@ require "bundler/gem_tasks"
|
|
6
6
|
|
7
7
|
RSpec::Core::RakeTask.new(:spec)
|
8
8
|
|
9
|
+
desc "download test repo and run spec"
|
9
10
|
task :default => ["test:create_repo", :spec]
|
10
11
|
|
11
12
|
namespace :test do
|
13
|
+
desc "download test repo"
|
12
14
|
task :create_repo do
|
13
15
|
dir = "fixtures/repo"
|
14
16
|
unless File.directory? dir
|
@@ -19,6 +21,7 @@ namespace :test do
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
24
|
+
desc "run travis build"
|
22
25
|
task :travis do
|
23
|
-
exec "bundle exec rake SPEC_OPTS='--format documentation -t ~run_docker --order=rand'"
|
26
|
+
exec "bundle exec rake SPEC_OPTS='--format documentation -t ~run_docker -t ~webdav --order=rand'"
|
24
27
|
end
|
data/bin/evrone-ci-worker
CHANGED
@@ -4,14 +4,15 @@ require File.expand_path("../../lib/evrone/ci/worker", __FILE__)
|
|
4
4
|
|
5
5
|
cli = Evrone::CI::Worker::CLI.new
|
6
6
|
|
7
|
-
|
8
|
-
Evrone::CI::Worker.configure do |c|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
if RUBY_PLATFORM =~ /darwin/ # developer
|
8
|
+
Evrone::CI::Worker.configure do |c|
|
9
|
+
c.webdav_cache_url = 'http://10.0.2.15:8080'
|
10
|
+
c.docker.ssh.port = 2223
|
11
|
+
c.docker.ssh.host = 'localhost'
|
12
|
+
c.docker.create_options = {
|
13
|
+
'PortSpecs' => ['2022:22']
|
14
|
+
}
|
15
|
+
end
|
14
16
|
end
|
15
|
-
=end
|
16
17
|
|
17
18
|
cli.run
|
data/docker/Dockerfile
CHANGED
@@ -6,56 +6,12 @@ ENV DEBIAN_FRONTEND noninteractive
|
|
6
6
|
# disable service autostarting
|
7
7
|
ENV RUNLEVEL 1
|
8
8
|
|
9
|
-
#
|
10
|
-
RUN dpkg-divert --local --rename --add /sbin/initctl
|
11
|
-
RUN ln -s /bin/true /sbin/initctl
|
12
|
-
|
13
|
-
RUN apt-get -qy update
|
14
|
-
RUN apt-get install -qy curl git-core build-essential
|
15
|
-
|
16
|
-
# add evrone repo
|
17
|
-
RUN mkdir -p /etc/apt/sources.list.d
|
18
|
-
RUN echo "deb http://download.opensuse.org/repositories/home:/dmexe/xUbuntu_12.04/ ./" > /etc/apt/sources.list.d/Evrone.list
|
19
|
-
RUN curl http://download.opensuse.org/repositories/home:/dmexe/xUbuntu_12.04/Release.key | apt-key add -
|
20
|
-
RUN apt-get -qy update
|
21
|
-
|
22
|
-
# install runit
|
23
|
-
RUN chmod 0000 /sbin/start
|
24
|
-
RUN apt-get -qy install runit
|
25
|
-
RUN chmod 0755 /sbin/start
|
9
|
+
# add runit helpers
|
26
10
|
ADD ./sv-gen /usr/local/bin/sv-gen
|
27
11
|
ADD ./sv-enable /usr/local/bin/sv-enable
|
28
12
|
|
29
|
-
#
|
30
|
-
|
31
|
-
RUN
|
32
|
-
RUN apt-get -qy install sudo
|
33
|
-
RUN echo "ci ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
34
|
-
|
35
|
-
# fixes locales
|
36
|
-
RUN locale-gen en_US.UTF-8
|
37
|
-
RUN dpkg-reconfigure -fnoninteractive locales
|
38
|
-
RUN update-locale LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US"
|
39
|
-
|
40
|
-
# install ssh
|
41
|
-
RUN apt-get install -qy openssh-server
|
42
|
-
RUN mkdir -p /var/run/sshd
|
43
|
-
RUN sv-gen ssh "/usr/sbin/sshd -D -e"
|
44
|
-
|
45
|
-
# install postgresql
|
46
|
-
RUN apt-get install -qy postgresql
|
47
|
-
RUN echo "host all all all trust" > /etc/postgresql/9.1/main/pg_hba.conf
|
48
|
-
RUN sv-gen postgresql "/usr/lib/postgresql/9.1/bin/postgres -D /var/lib/postgresql/9.1/main -c config_file=/etc/postgresql/9.1/main/postgresql.conf" postgres
|
49
|
-
|
50
|
-
# add ruby
|
51
|
-
RUN apt-get install -qy rbenv rbenv-2.0.0-p195 rbenv-1.9.3-p448
|
52
|
-
RUN env RBENV_VERSION=2.0.0-p195 rbenv exec gem install bundler --no-ri --no-rdoc
|
53
|
-
RUN env RBENV_VERSION=1.9.3-p448 rbenv exec gem install bundler --no-ri --no-rdoc
|
54
|
-
RUN rbenv rehash
|
55
|
-
|
56
|
-
RUN apt-get -qy clean autoremove
|
57
|
-
|
58
|
-
RUN sv-enable postgresql
|
59
|
-
RUN sv-enable ssh
|
13
|
+
# run bootstrap
|
14
|
+
ADD ./bootstrap.sh /tmp/bootstrap.sh
|
15
|
+
RUN /tmp/bootstrap.sh && rm /tmp/bootstrap.sh
|
60
16
|
|
61
17
|
ENTRYPOINT ["/usr/bin/runsvdir", "-P", "/etc/service"]
|
data/docker/bootstrap.sh
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -x
|
3
|
+
set -e
|
4
|
+
|
5
|
+
# add ubuntu repos
|
6
|
+
echo "deb http://us.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
|
7
|
+
echo "deb http://us.archive.ubuntu.com/ubuntu/ precise multiverse" >> /etc/apt/sources.list
|
8
|
+
|
9
|
+
# replace init
|
10
|
+
dpkg-divert --local --rename --add /sbin/initctl
|
11
|
+
ln -s /bin/true /sbin/initctl
|
12
|
+
|
13
|
+
apt-get -qy update
|
14
|
+
apt-get install -qy curl git-core build-essential
|
15
|
+
|
16
|
+
# add evrone repo
|
17
|
+
mkdir -p /etc/apt/sources.list.d
|
18
|
+
echo "deb http://download.opensuse.org/repositories/home:/dmexe/xUbuntu_12.04/ ./" > /etc/apt/sources.list.d/Evrone.list
|
19
|
+
curl http://download.opensuse.org/repositories/home:/dmexe/xUbuntu_12.04/Release.key | apt-key add -
|
20
|
+
apt-get -qy update
|
21
|
+
|
22
|
+
# add packages
|
23
|
+
apt-get install -qy libmysqlclient-dev libpq-dev imagemagick libmagickwand-dev \
|
24
|
+
libcurl4-openssl-dev nodejs postgresql-contrib-9.1 libxml2-dev libxslt-dev \
|
25
|
+
openjdk-7-jre-headless libsqlite3-dev libgeos-dev ruby
|
26
|
+
|
27
|
+
# install runit
|
28
|
+
chmod 0000 /sbin/start
|
29
|
+
apt-get -qy install runit
|
30
|
+
chmod 0755 /sbin/start
|
31
|
+
|
32
|
+
# set user password
|
33
|
+
useradd -m ci
|
34
|
+
echo "ci:ci" | chpasswd
|
35
|
+
apt-get -qy install sudo
|
36
|
+
echo "ci ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
37
|
+
|
38
|
+
# fixes locales
|
39
|
+
locale-gen en_US.UTF-8
|
40
|
+
dpkg-reconfigure -fnoninteractive locales
|
41
|
+
update-locale LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US"
|
42
|
+
|
43
|
+
# install ssh
|
44
|
+
apt-get install -qy openssh-server
|
45
|
+
mkdir -p /var/run/sshd
|
46
|
+
sv-gen ssh "/usr/sbin/sshd -D -e"
|
47
|
+
|
48
|
+
# install postgresql
|
49
|
+
apt-get install -qy postgresql
|
50
|
+
echo "host all all all trust" > /etc/postgresql/9.1/main/pg_hba.conf
|
51
|
+
sv-gen postgresql "/usr/lib/postgresql/9.1/bin/postgres -D /var/lib/postgresql/9.1/main -c config_file=/etc/postgresql/9.1/main/postgresql.conf" postgres
|
52
|
+
|
53
|
+
# install mysql
|
54
|
+
apt-get install -qy mysql-server
|
55
|
+
sv-gen mysqld "/usr/sbin/mysqld" mysql
|
56
|
+
|
57
|
+
# add ruby
|
58
|
+
apt-get install -qy rbenv rbenv-2.0.0-p195 rbenv-1.9.3-p448
|
59
|
+
env RBENV_VERSION=2.0.0-p195 rbenv exec gem install bundler --no-ri --no-rdoc
|
60
|
+
env RBENV_VERSION=1.9.3-p448 rbenv exec gem install bundler --no-ri --no-rdoc
|
61
|
+
rbenv rehash
|
62
|
+
|
63
|
+
apt-get -qy clean autoremove
|
64
|
+
|
65
|
+
sv-enable postgresql
|
66
|
+
sv-enable ssh
|
data/docker/sv-gen
CHANGED
data/lib/evrone/ci/worker.rb
CHANGED
@@ -31,6 +31,7 @@ module Evrone
|
|
31
31
|
autoload :DockerStartContainer, File.expand_path("../worker/middlewares/docker_start_container", __FILE__)
|
32
32
|
autoload :DockerFetchRepo, File.expand_path("../worker/middlewares/docker_fetch_repo", __FILE__)
|
33
33
|
autoload :DockerScript, File.expand_path("../worker/middlewares/docker_script", __FILE__)
|
34
|
+
autoload :DockerWebdavCache, File.expand_path("../worker/middlewares/docker_webdav_cache", __FILE__)
|
34
35
|
|
35
36
|
module Helper
|
36
37
|
autoload :Logger, File.expand_path("../worker/helper/logger", __FILE__)
|
data/lib/evrone/ci/worker/job.rb
CHANGED
@@ -8,11 +8,12 @@ module Evrone
|
|
8
8
|
|
9
9
|
include Helper::Logger
|
10
10
|
|
11
|
-
attr_reader :output, :message
|
11
|
+
attr_reader :output, :message, :output_counter
|
12
12
|
|
13
13
|
def initialize(perform_job_message)
|
14
|
-
@
|
15
|
-
@
|
14
|
+
@output_counter = 0
|
15
|
+
@output = ""
|
16
|
+
@message = perform_job_message
|
16
17
|
end
|
17
18
|
|
18
19
|
def add_to_output(str)
|
@@ -25,13 +26,16 @@ module Evrone
|
|
25
26
|
add_to_output "$ #{cmd}\n"
|
26
27
|
end
|
27
28
|
|
29
|
+
def add_trace_to_output(log)
|
30
|
+
add_to_output log.split(/\n/).map{|i| " ===> #{i}\n" }.join
|
31
|
+
end
|
32
|
+
|
28
33
|
def create_job_log_message(data)
|
29
|
-
|
34
|
+
@output_counter += 1
|
30
35
|
Message::JobLog.new(
|
31
36
|
build_id: message.id,
|
32
37
|
job_id: message.job_id,
|
33
|
-
tm:
|
34
|
-
tm_usec: tm.usec,
|
38
|
+
tm: @output_counter,
|
35
39
|
log: data
|
36
40
|
)
|
37
41
|
end
|
@@ -21,7 +21,7 @@ module Evrone
|
|
21
21
|
if code == 0
|
22
22
|
app.call env
|
23
23
|
else
|
24
|
-
-1
|
24
|
+
code * -1
|
25
25
|
end
|
26
26
|
else
|
27
27
|
app.call env
|
@@ -52,9 +52,6 @@ module Evrone
|
|
52
52
|
def spawn_script(env)
|
53
53
|
scm = create_scm(env)
|
54
54
|
|
55
|
-
env.job.add_command_to_output("git clone #{scm.src} #{scm.path}")
|
56
|
-
env.job.add_command_to_output("git checkout -q #{scm.sha}")
|
57
|
-
|
58
55
|
script = "sh -c '#{scm.make_fetch_command}'"
|
59
56
|
env.ssh.spawn script, &env.job.method(:add_to_output)
|
60
57
|
end
|
@@ -34,7 +34,8 @@ module Evrone
|
|
34
34
|
paranoid: false,
|
35
35
|
forward_agent: false
|
36
36
|
}
|
37
|
-
|
37
|
+
sleep 2
|
38
|
+
env.job.add_to_output "open ssh session to #{user}@#{host}:#{ssh_options[:port]}\n"
|
38
39
|
open_ssh(host, "ci", ssh_options) do |ssh|
|
39
40
|
begin
|
40
41
|
env.ssh = ssh
|
@@ -49,7 +50,7 @@ module Evrone
|
|
49
50
|
env.container = ::Docker::Container.create create_options
|
50
51
|
env.container.start
|
51
52
|
|
52
|
-
env.job.add_to_output "using #{Socket.gethostname}/#{env.container.id}"
|
53
|
+
env.job.add_to_output "using #{Socket.gethostname}/#{env.container.id}\n"
|
53
54
|
|
54
55
|
env.container_addr = config.docker.ssh.host
|
55
56
|
env.container_addr ||= env.container.json['NetworkSettings']['IPAddress']
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'net/scp'
|
2
|
+
|
3
|
+
module Evrone
|
4
|
+
module CI
|
5
|
+
module Worker
|
6
|
+
|
7
|
+
DockerWebdavCache = Struct.new(:app) do
|
8
|
+
|
9
|
+
include Helper::Config
|
10
|
+
include Helper::Logger
|
11
|
+
|
12
|
+
CASHER_URL = "https://raw.github.com/travis-ci/casher/master/bin/casher"
|
13
|
+
CASHER_BIN = "$HOME/.casher/bin/casher"
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
if env.ssh && config.webdav_cache_url
|
17
|
+
assign_url(env) &&
|
18
|
+
prepare(env) &&
|
19
|
+
fetch(env) &&
|
20
|
+
add(env)
|
21
|
+
end
|
22
|
+
|
23
|
+
rs = app.call env
|
24
|
+
|
25
|
+
if env.ssh && env.webdav_cache_url
|
26
|
+
push(env)
|
27
|
+
end
|
28
|
+
|
29
|
+
rs
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def assign_url(env)
|
35
|
+
release = nil
|
36
|
+
|
37
|
+
env.ssh.spawn "lsb_release -s -c" do |out|
|
38
|
+
release ||= out.gsub(/[^a-z0-9]/, '')
|
39
|
+
end
|
40
|
+
release = 'unknown' unless release
|
41
|
+
|
42
|
+
name = env.job.message.name.dup
|
43
|
+
name << "-#{release}"
|
44
|
+
name << "-#{env.job.message.matrix_keys.join("_")}.tgz"
|
45
|
+
name = name.gsub(/[^a-z0-9_\-.]/, '')
|
46
|
+
|
47
|
+
env.webdav_cache_url = "#{config.webdav_cache_url.dup}/#{name}"
|
48
|
+
true
|
49
|
+
end
|
50
|
+
|
51
|
+
def push(env)
|
52
|
+
cmd = %{
|
53
|
+
#{CASHER_BIN} push #{env.webdav_cache_url}
|
54
|
+
}.compact
|
55
|
+
|
56
|
+
logger.debug "push cache to #{env.webdav_cache_url.inspect}"
|
57
|
+
env.ssh.spawn cmd, &env.job.method(:add_trace_to_output)
|
58
|
+
true
|
59
|
+
end
|
60
|
+
|
61
|
+
def add(env)
|
62
|
+
cmd = %{
|
63
|
+
#{CASHER_BIN} add $HOME/cached
|
64
|
+
}.compact
|
65
|
+
env.ssh.spawn cmd, &env.job.method(:add_trace_to_output)
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
69
|
+
def fetch(env)
|
70
|
+
logger.debug "fetch cache from #{env.webdav_cache_url.inspect}"
|
71
|
+
cmd = %{
|
72
|
+
#{CASHER_BIN} fetch #{env.webdav_cache_url}
|
73
|
+
}.compact
|
74
|
+
env.ssh.spawn cmd, &env.job.method(:add_trace_to_output)
|
75
|
+
true
|
76
|
+
end
|
77
|
+
|
78
|
+
def prepare(env)
|
79
|
+
cmd = %{
|
80
|
+
export CASHER_DIR=$HOME/.casher &&
|
81
|
+
mkdir -p $CASHER_DIR/bin &&
|
82
|
+
curl #{CASHER_URL} -s -o #{CASHER_BIN} &&
|
83
|
+
chmod +x #{CASHER_BIN} &&
|
84
|
+
echo casher successfuly downloaded
|
85
|
+
}.compact
|
86
|
+
code = env.ssh.spawn cmd, &env.job.method(:add_trace_to_output)
|
87
|
+
code == 0
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
@@ -20,9 +20,13 @@ module Evrone
|
|
20
20
|
begin
|
21
21
|
rs = app.call env
|
22
22
|
rescue Exception => e
|
23
|
+
env.job.add_to_output("ERROR: #{e.inspect}\n")
|
23
24
|
logger.error("ERROR: #{e.inspect}\n BACKTRACE:\n#{e.backtrace.map{|i| " #{i}" }.join("\n")}")
|
24
25
|
end
|
25
26
|
|
27
|
+
msg = "\nDone. Your build exited with %s.\n"
|
28
|
+
env.job.add_to_output(msg % rs.abs)
|
29
|
+
|
26
30
|
case
|
27
31
|
when rs == 0
|
28
32
|
update_status env.job, FINISHED
|
data/spec/lib/worker/job_spec.rb
CHANGED
@@ -7,23 +7,26 @@ describe Evrone::CI::Worker::Job do
|
|
7
7
|
subject { job }
|
8
8
|
|
9
9
|
context "just created" do
|
10
|
-
its(:message)
|
10
|
+
its(:message) { should eq message }
|
11
|
+
its(:output) { should eq '' }
|
12
|
+
its(:output_counter) { should eq 0 }
|
11
13
|
end
|
12
14
|
|
13
15
|
context "create_job_log_message" do
|
14
|
-
let(:tm) { Time.new(2012, 12, 10, 15, 45) }
|
15
16
|
let(:data) { 'log' }
|
16
17
|
subject { job.create_job_log_message data }
|
17
18
|
|
18
|
-
before do
|
19
|
-
mock(Time).now { tm }
|
20
|
-
end
|
21
|
-
|
22
19
|
it { should be_an_instance_of(Evrone::CI::Message::JobLog) }
|
23
20
|
its(:job_id) { should eq job.message.job_id }
|
24
21
|
its(:build_id) { should eq job.message.id }
|
25
|
-
its(:tm) { should eq
|
22
|
+
its(:tm) { should eq 1 }
|
26
23
|
its(:log) { should eq data }
|
24
|
+
|
25
|
+
it "should increment counter" do
|
26
|
+
expect {
|
27
|
+
subject
|
28
|
+
}.to change(job, :output_counter).by(1)
|
29
|
+
end
|
27
30
|
end
|
28
31
|
|
29
32
|
context "add_to_output" do
|
@@ -37,6 +40,13 @@ describe Evrone::CI::Worker::Job do
|
|
37
40
|
subject
|
38
41
|
}.to change(messages, :size).by(1)
|
39
42
|
end
|
43
|
+
|
44
|
+
it "should increment output_counter" do
|
45
|
+
expect {
|
46
|
+
subject
|
47
|
+
}.to change(job, :output_counter).by(1)
|
48
|
+
expect(messages.first.tm).to eq 1
|
49
|
+
end
|
40
50
|
end
|
41
51
|
|
42
52
|
context "add_command_to_output" do
|
@@ -45,10 +55,40 @@ describe Evrone::CI::Worker::Job do
|
|
45
55
|
subject { job.add_command_to_output(data) ; job }
|
46
56
|
|
47
57
|
its(:output) { should eq "$ #{data}\n" }
|
58
|
+
|
48
59
|
it "should delivery message" do
|
49
60
|
expect {
|
50
61
|
subject
|
51
62
|
}.to change(messages, :size).by(1)
|
52
63
|
end
|
64
|
+
|
65
|
+
it "should increment output_counter" do
|
66
|
+
expect {
|
67
|
+
subject
|
68
|
+
}.to change(job, :output_counter).by(1)
|
69
|
+
expect(messages.first.tm).to eq 1
|
70
|
+
end
|
53
71
|
end
|
72
|
+
|
73
|
+
context "add_trace_to_output" do
|
74
|
+
let(:data) { 'data' }
|
75
|
+
let(:messages) { Evrone::CI::Worker::JobLogsConsumer.messages }
|
76
|
+
subject { job.add_trace_to_output(data) ; job }
|
77
|
+
|
78
|
+
its(:output) { should eq " ===> #{data}\n" }
|
79
|
+
|
80
|
+
it "should delivery message" do
|
81
|
+
expect {
|
82
|
+
subject
|
83
|
+
}.to change(messages, :size).by(1)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should increment output_counter" do
|
87
|
+
expect {
|
88
|
+
subject
|
89
|
+
}.to change(job, :output_counter).by(1)
|
90
|
+
expect(messages.first.tm).to eq 1
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
54
94
|
end
|
@@ -18,7 +18,7 @@ describe Evrone::CI::Worker::DockerFetchRepo, run_docker: true do
|
|
18
18
|
context "when fail to fetch repo" do
|
19
19
|
let(:options) { { src: "/not-exists-repo.git" } }
|
20
20
|
it "should be" do
|
21
|
-
expect(subject).to eq(-
|
21
|
+
expect(subject).to eq(-128)
|
22
22
|
expect(job.output).to be_include("does not exist")
|
23
23
|
end
|
24
24
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evrone::CI::Worker::DockerWebdavCache, run_docker: true, webdav: true do
|
4
|
+
let(:exit_code) { 0 }
|
5
|
+
let(:app) {
|
6
|
+
->(env) {
|
7
|
+
file = "$HOME/cached/foo.txt"
|
8
|
+
cmd = %{
|
9
|
+
if [ -f #{file} ] ; then
|
10
|
+
echo "!exists" ;
|
11
|
+
cat #{file} ;
|
12
|
+
else
|
13
|
+
echo "!touch" ;
|
14
|
+
echo 1 > #{file} ;
|
15
|
+
fi
|
16
|
+
}.compact
|
17
|
+
env.ssh.spawn cmd, &job.method(:add_to_output)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
let(:job) { create :job }
|
21
|
+
let(:env) { OpenStruct.new job: job }
|
22
|
+
let(:mid) { described_class.new app }
|
23
|
+
let(:docker_mid) { Evrone::CI::Worker::DockerStartContainer.new(mid) }
|
24
|
+
|
25
|
+
subject { docker_mid.call env }
|
26
|
+
|
27
|
+
before do
|
28
|
+
Evrone::CI::Worker.config.webdav_cache_url = 'http://192.168.44.1:8080/'
|
29
|
+
end
|
30
|
+
|
31
|
+
context "first run" do
|
32
|
+
it "should be" do
|
33
|
+
expect(subject).to eq 0
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "next run" do
|
38
|
+
before do
|
39
|
+
expect(docker_mid.call env).to eq 0
|
40
|
+
job.output.clear
|
41
|
+
end
|
42
|
+
it "should be" do
|
43
|
+
expect(subject).to eq 0
|
44
|
+
expect(job.output).to match(/\!exists/)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evrone-ci-worker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.pre3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Galinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evrone-ci-common
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.0.
|
19
|
+
version: 0.2.0.pre3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.0.
|
26
|
+
version: 0.2.0.pre3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: evrone-ci-message
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2.0.
|
33
|
+
version: 0.2.0.pre3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.2.0.
|
40
|
+
version: 0.2.0.pre3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: evrone-common-amqp
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- Rakefile
|
167
167
|
- bin/evrone-ci-worker
|
168
168
|
- docker/Dockerfile
|
169
|
+
- docker/bootstrap.sh
|
169
170
|
- docker/sv-enable
|
170
171
|
- docker/sv-gen
|
171
172
|
- evrone-ci-worker.gemspec
|
@@ -185,6 +186,7 @@ files:
|
|
185
186
|
- lib/evrone/ci/worker/middlewares/docker_fetch_repo.rb
|
186
187
|
- lib/evrone/ci/worker/middlewares/docker_script.rb
|
187
188
|
- lib/evrone/ci/worker/middlewares/docker_start_container.rb
|
189
|
+
- lib/evrone/ci/worker/middlewares/docker_webdav_cache.rb
|
188
190
|
- lib/evrone/ci/worker/middlewares/local_create_dirs.rb
|
189
191
|
- lib/evrone/ci/worker/middlewares/local_fetch_repo.rb
|
190
192
|
- lib/evrone/ci/worker/middlewares/local_script.rb
|
@@ -200,6 +202,7 @@ files:
|
|
200
202
|
- spec/lib/worker/middlewares/docker_fetch_repo_spec.rb
|
201
203
|
- spec/lib/worker/middlewares/docker_script_spec.rb
|
202
204
|
- spec/lib/worker/middlewares/docker_start_container_spec.rb
|
205
|
+
- spec/lib/worker/middlewares/docker_webdav_cache_spec.rb
|
203
206
|
- spec/lib/worker/middlewares/local_create_dirs_spec.rb
|
204
207
|
- spec/lib/worker/middlewares/local_fetch_repo_spec.rb
|
205
208
|
- spec/lib/worker/middlewares/local_script_spec.rb
|
@@ -241,6 +244,7 @@ test_files:
|
|
241
244
|
- spec/lib/worker/middlewares/docker_fetch_repo_spec.rb
|
242
245
|
- spec/lib/worker/middlewares/docker_script_spec.rb
|
243
246
|
- spec/lib/worker/middlewares/docker_start_container_spec.rb
|
247
|
+
- spec/lib/worker/middlewares/docker_webdav_cache_spec.rb
|
244
248
|
- spec/lib/worker/middlewares/local_create_dirs_spec.rb
|
245
249
|
- spec/lib/worker/middlewares/local_fetch_repo_spec.rb
|
246
250
|
- spec/lib/worker/middlewares/local_script_spec.rb
|