Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Only sync master branches when necessary
Browse files Browse the repository at this point in the history
The server keeps track of library revisions now.
This means that we can check wether our local
clone is synced to the desired revision, and do so
if it isn't.

WARNING: dm:ci:client now syncs the master branches
of all datamapper gems. This means that you should
*never* do any work in master yourself (why would
you anyway?)
  • Loading branch information
snusnu committed Dec 5, 2010
1 parent 47c34f7 commit 454cb77
Showing 1 changed file with 42 additions and 13 deletions.
55 changes: 42 additions & 13 deletions tasks.rb
Expand Up @@ -465,7 +465,7 @@ def after
def execute
if executable?
before
unless suppress_log?
unless suppress_log? || skip?
log(command)
end
unless pretend?
Expand Down Expand Up @@ -625,6 +625,18 @@ def action
'Pulling'
end

def target_revision
env.options[:revision]
end

def revision
%x[git rev-parse head].chomp!
end

def skip?
target_revision == revision
end

end
end

Expand Down Expand Up @@ -826,6 +838,18 @@ def suppress_log?
!executable? || print_matrix?
end

def skip?
target_revision && !clean?
end

def target_revision
env.options[:revision]
end

def clean?
%x[git status] =~ /working directory clean/
end

end

class Gem < Rvm
Expand Down Expand Up @@ -956,15 +980,19 @@ class Job
attr_reader :platform
attr_reader :adapter
attr_reader :library
attr_reader :revision
attr_reader :previous_status

attr_reader :data

def initialize(data, requested_status)
@requested_status = requested_status
@id = data['id']
@platform = data['platform']['name']
@adapter = data['adapter' ]['name']
@library = data['library' ]['name']
@platform = data['platform_name']
@adapter = data['adapter_name' ]
@library = data['library_name' ]
@revision = data['revision' ]
@previous_status = data['previous_status' ]
@data = data
@results = {}
end
Expand Down Expand Up @@ -996,28 +1024,29 @@ def accept
end

def execute
DataMapper::Project.sync(:include => [library], :rubies => [platform], :adapters => [adapter]) if upstream_modified?
DataMapper::Project.spec(:include => [library], :rubies => [platform], :adapters => [adapter])
permutation = { :include => [library], :rubies => [platform], :adapters => [adapter], :revision => revision }
DataMapper::Project.sync(permutation)
DataMapper::Project.spec(permutation)
end

def report
RestClient.post("#{CI::SERVICE_URL}/jobs/report", :report => { :job_id => self.id, :status => result })
RestClient.post("#{CI::SERVICE_URL}/jobs/report",
:report => {
:job_id => self.id,
:status => result,
:revision => revision
})
end

def running?
@running
end

def upstream_modified?
# TODO make this more solid with respect to 'skipped' (use SHA1s)
@requested_status.empty? || @requested_status.include?('modified')
end

def result
if @results[library]
@results[library].first.to_s # we know that we only get one result back
else
:skipped # HACK
'skipped' # HACK
end
end

Expand Down

0 comments on commit 454cb77

Please sign in to comment.