Increase release tag implementation
This commit is contained in:
parent
0dae93bbe5
commit
d34308d749
1
Gemfile
1
Gemfile
|
@ -100,6 +100,7 @@ source 'http://rails-assets.org' do
|
|||
end
|
||||
|
||||
gem 'rack-utf8_sanitizer'
|
||||
gem 'redis-semaphore'
|
||||
|
||||
#github api
|
||||
gem 'github_api'
|
||||
|
|
|
@ -452,6 +452,8 @@ GEM
|
|||
redis-actionpack (~> 4)
|
||||
redis-activesupport (~> 4)
|
||||
redis-store (~> 1.1.0)
|
||||
redis-semaphore (0.3.0)
|
||||
redis
|
||||
redis-store (1.1.4)
|
||||
redis (>= 2.2)
|
||||
ref (1.0.5)
|
||||
|
@ -741,6 +743,7 @@ DEPENDENCIES
|
|||
rdiscount
|
||||
redcarpet (~> 3.3)
|
||||
redis-rails
|
||||
redis-semaphore
|
||||
resque
|
||||
resque-scheduler (~> 2.5.4)
|
||||
resque-status
|
||||
|
@ -777,4 +780,4 @@ DEPENDENCIES
|
|||
zeroclipboard-rails
|
||||
|
||||
BUNDLED WITH
|
||||
1.10.6
|
||||
1.11.2
|
||||
|
|
|
@ -62,7 +62,7 @@ class Api::V1::JobsController < Api::V1::BaseController
|
|||
name = params[:name]
|
||||
if name =~ /abfworker::rpm-worker/
|
||||
if current_user.system? || current_user.id == BuildList.where(id: name.gsub(/[^\d]/, '')).first.try(:builder_id)
|
||||
res = BuildList.log_server.setex name, 15, params[:logs]
|
||||
BuildList.log_server.setex name, 15, params[:logs]
|
||||
end
|
||||
end
|
||||
render nothing: true
|
||||
|
|
|
@ -57,7 +57,6 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
|
|||
flash[:notice] = t('flash.product.build_started')
|
||||
redirect_to [@platform, @product]
|
||||
else
|
||||
puts pbl.errors.messages
|
||||
flash[:error] = t('flash.product.build_error')
|
||||
@product_build_list = pbl
|
||||
render action: :new
|
||||
|
|
|
@ -86,6 +86,19 @@ class MassBuild < ActiveRecord::Base
|
|||
return unless start
|
||||
# later with resque
|
||||
arches_list = arch_names ? Arch.where(name: arch_names.split(', ')) : Arch.all
|
||||
project_version =
|
||||
if save_to_platform.name != build_for_platform.name
|
||||
save_to_platform.default_branch
|
||||
else
|
||||
build_for_platform.default_branch
|
||||
end
|
||||
|
||||
increase_rt = increase_release_tag?
|
||||
if increase_rt
|
||||
inc_rt_sem = Redis::Semaphore.new(:increase_release_tag_lock)
|
||||
inc_rt_sem.lock
|
||||
ratelimit_remaining = Github_blobs_api.ratelimit_remaining
|
||||
end
|
||||
|
||||
projects_list.lines.each do |name|
|
||||
next if name.blank?
|
||||
|
@ -96,13 +109,25 @@ class MassBuild < ActiveRecord::Base
|
|||
return if self.reload.stop_build
|
||||
# Ensures that user has rights to create a build_list
|
||||
next unless ProjectPolicy.new(user, project).write?
|
||||
increase_rt = increase_release_tag?
|
||||
arches_list.each do |arch|
|
||||
rep_id = (project.repository_ids & save_to_platform.repository_ids).first
|
||||
project.build_for(self, rep_id, arch, 0, increase_rt)
|
||||
increase_rt = false
|
||||
if increase_rt
|
||||
if ratelimit_remaining <= 1
|
||||
ratelimit_remaining = Github_blobs_api.ratelimit_remaining
|
||||
#if that's still less that or equal 1
|
||||
if ratelimit_remaining <= 1
|
||||
#just to make sure it really resets wait additional 5 seconds
|
||||
ratelimit_reset_wait = Github_blobs_api.ratelimit_reset - Time.now.to_i + 5
|
||||
sleep ratelimit_reset_wait
|
||||
ratelimit_remaining = Github_blobs_api.ratelimit_remaining
|
||||
end
|
||||
rescue RuntimeError, Exception
|
||||
end
|
||||
count = project.increase_release_tag(project_version, "MassBuild##{id}: Increase release tag")
|
||||
ratelimit_remaining -= count
|
||||
end
|
||||
project.build_for(self, rep_id, project_version, arch, 0)
|
||||
end
|
||||
rescue RuntimeError, Exception => e
|
||||
end
|
||||
else
|
||||
MassBuild.increment_counter :missed_projects_count, id
|
||||
|
@ -111,6 +136,9 @@ class MassBuild < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
done
|
||||
if increase_rt
|
||||
inc_rt_sem.unlock
|
||||
end
|
||||
end
|
||||
later :build_all, queue: :low
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'base64'
|
||||
|
||||
class Project < ActiveRecord::Base
|
||||
has_ancestry orphan_strategy: :adopt # we replace a 'path' method in the Git module
|
||||
|
||||
|
@ -122,7 +124,7 @@ class Project < ActiveRecord::Base
|
|||
"git://github.com/" + github_get_organization + "/" + name + ".git"
|
||||
end
|
||||
|
||||
def build_for(mass_build, repository_id, arch = Arch.find_by(name: 'i586'), priority = 0, increase_rt = false)
|
||||
def build_for(mass_build, repository_id, project_version, arch = Arch.find_by(name: 'i586'), priority = 0)
|
||||
build_for_platform = mass_build.build_for_platform
|
||||
save_to_platform = mass_build.save_to_platform
|
||||
user = mass_build.user
|
||||
|
@ -132,10 +134,6 @@ class Project < ActiveRecord::Base
|
|||
main_rep_id = build_for_platform.repositories.main.first.try(:id)
|
||||
include_repos = ([main_rep_id] << (save_to_platform.main? ? repository_id : nil)).compact.uniq
|
||||
|
||||
project_version = project_version_for save_to_platform, build_for_platform
|
||||
|
||||
increase_release_tag(project_version, user, "MassBuild##{mass_build.id}: Increase release tag") if increase_rt
|
||||
|
||||
build_list = build_lists.build do |bl|
|
||||
bl.save_to_platform = save_to_platform
|
||||
bl.build_for_platform = build_for_platform
|
||||
|
@ -233,18 +231,14 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def increase_release_tag(project_version, user, message)
|
||||
blob, raw = find_blob_and_raw_of_spec_file(project_version)
|
||||
return unless blob
|
||||
|
||||
content = self.class.replace_release_tag raw.content
|
||||
return if content == raw.content
|
||||
|
||||
update_file(blob.name, content.gsub("\r", ''),
|
||||
message: message,
|
||||
actor: user,
|
||||
head: project_version
|
||||
)
|
||||
def increase_release_tag(project_version, message)
|
||||
file = Github_blobs_api.get github_get_organization, name, '/' + name + '.spec', ref: project_version rescue return 1
|
||||
decoded_content = Base64.decode64(file.content)
|
||||
new_content = Project.replace_release_tag decoded_content
|
||||
return 1 if new_content == decoded_content
|
||||
Github_blobs_api.update github_get_organization, name, '/' + name + '.spec', path: '/' + name + '.spec',\
|
||||
message: message, content: new_content, sha: file.sha rescue return 2
|
||||
return 2
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -7,3 +7,6 @@ Github.configure do |c|
|
|||
builder.use Faraday::HttpCache, store: Rails.cache
|
||||
end
|
||||
end
|
||||
|
||||
#for updating repo contents
|
||||
Github_blobs_api = Github::Client::Repos::Contents.new basic_auth: ENV['GITHUB_REPO_BOT_LOGIN'] + ":" + ENV['GITHUB_REPO_BOT_PASSWORD']
|
Loading…
Reference in New Issue