Removed http basic auth in abf, added native build, changed github api gem
This commit is contained in:
parent
b9326ab444
commit
1338cbcb4c
2
Gemfile
2
Gemfile
|
@ -82,7 +82,7 @@ gem 'rack-utf8_sanitizer'
|
||||||
gem 'redis-semaphore'
|
gem 'redis-semaphore'
|
||||||
|
|
||||||
#github api
|
#github api
|
||||||
gem 'github_api'
|
gem "octokit", "~> 4.0"
|
||||||
gem 'faraday-http-cache'
|
gem 'faraday-http-cache'
|
||||||
|
|
||||||
group :production do
|
group :production do
|
||||||
|
|
26
Gemfile.lock
26
Gemfile.lock
|
@ -143,8 +143,6 @@ GEM
|
||||||
safe_yaml (~> 1.0.0)
|
safe_yaml (~> 1.0.0)
|
||||||
daemons (1.2.2)
|
daemons (1.2.2)
|
||||||
debug_inspector (0.0.2)
|
debug_inspector (0.0.2)
|
||||||
descendants_tracker (0.0.4)
|
|
||||||
thread_safe (~> 0.3, >= 0.3.1)
|
|
||||||
devise (3.5.1)
|
devise (3.5.1)
|
||||||
bcrypt (~> 3.0)
|
bcrypt (~> 3.0)
|
||||||
orm_adapter (~> 0.1)
|
orm_adapter (~> 0.1)
|
||||||
|
@ -176,14 +174,6 @@ GEM
|
||||||
formtastic_i18n (0.4.1)
|
formtastic_i18n (0.4.1)
|
||||||
friendly_id (5.1.0)
|
friendly_id (5.1.0)
|
||||||
activerecord (>= 4.0.0)
|
activerecord (>= 4.0.0)
|
||||||
github_api (0.13.0)
|
|
||||||
addressable (~> 2.3)
|
|
||||||
descendants_tracker (~> 0.0.4)
|
|
||||||
faraday (~> 0.8, < 0.10)
|
|
||||||
hashie (>= 3.4)
|
|
||||||
multi_json (>= 1.7.5, < 2.0)
|
|
||||||
nokogiri (~> 1.6.6)
|
|
||||||
oauth2
|
|
||||||
gli (2.13.1)
|
gli (2.13.1)
|
||||||
globalid (0.3.5)
|
globalid (0.3.5)
|
||||||
activesupport (>= 4.1.0)
|
activesupport (>= 4.1.0)
|
||||||
|
@ -198,7 +188,6 @@ GEM
|
||||||
has_scope (0.6.0)
|
has_scope (0.6.0)
|
||||||
actionpack (>= 3.2, < 5)
|
actionpack (>= 3.2, < 5)
|
||||||
activesupport (>= 3.2, < 5)
|
activesupport (>= 3.2, < 5)
|
||||||
hashie (3.4.2)
|
|
||||||
highline (1.6.21)
|
highline (1.6.21)
|
||||||
hike (1.2.3)
|
hike (1.2.3)
|
||||||
hirb (0.7.3)
|
hirb (0.7.3)
|
||||||
|
@ -230,7 +219,6 @@ GEM
|
||||||
railties (>= 3.2)
|
railties (>= 3.2)
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
json (1.8.3)
|
json (1.8.3)
|
||||||
jwt (1.5.0)
|
|
||||||
kaminari (0.16.3)
|
kaminari (0.16.3)
|
||||||
actionpack (>= 3.0.0)
|
actionpack (>= 3.0.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
|
@ -273,7 +261,6 @@ GEM
|
||||||
railties (>= 3.1)
|
railties (>= 3.1)
|
||||||
mono_logger (1.1.0)
|
mono_logger (1.1.0)
|
||||||
multi_json (1.11.1)
|
multi_json (1.11.1)
|
||||||
multi_xml (0.5.5)
|
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
nest (1.1.2)
|
nest (1.1.2)
|
||||||
redis
|
redis
|
||||||
|
@ -291,12 +278,8 @@ GEM
|
||||||
rails (>= 3.1)
|
rails (>= 3.1)
|
||||||
nokogiri (1.6.6.2)
|
nokogiri (1.6.6.2)
|
||||||
mini_portile (~> 0.6.0)
|
mini_portile (~> 0.6.0)
|
||||||
oauth2 (1.0.0)
|
octokit (4.3.0)
|
||||||
faraday (>= 0.8, < 0.10)
|
sawyer (~> 0.7.0, >= 0.5.3)
|
||||||
jwt (~> 1.0)
|
|
||||||
multi_json (~> 1.3)
|
|
||||||
multi_xml (~> 0.5)
|
|
||||||
rack (~> 1.2)
|
|
||||||
ohm (1.3.2)
|
ohm (1.3.2)
|
||||||
nest (~> 1.0)
|
nest (~> 1.0)
|
||||||
redis
|
redis
|
||||||
|
@ -453,6 +436,9 @@ GEM
|
||||||
sprockets (>= 2.8, < 4.0)
|
sprockets (>= 2.8, < 4.0)
|
||||||
sprockets-rails (>= 2.0, < 4.0)
|
sprockets-rails (>= 2.0, < 4.0)
|
||||||
tilt (~> 1.1)
|
tilt (~> 1.1)
|
||||||
|
sawyer (0.7.0)
|
||||||
|
addressable (>= 2.3.5, < 2.5)
|
||||||
|
faraday (~> 0.8, < 0.10)
|
||||||
schema_auto_foreign_keys (0.1.0)
|
schema_auto_foreign_keys (0.1.0)
|
||||||
schema_plus_foreign_keys (~> 0.1)
|
schema_plus_foreign_keys (~> 0.1)
|
||||||
schema_plus_indexes (~> 0.2)
|
schema_plus_indexes (~> 0.2)
|
||||||
|
@ -613,7 +599,6 @@ DEPENDENCIES
|
||||||
ffi
|
ffi
|
||||||
font-awesome-rails
|
font-awesome-rails
|
||||||
friendly_id
|
friendly_id
|
||||||
github_api
|
|
||||||
haml-rails
|
haml-rails
|
||||||
highline (~> 1.6.20)
|
highline (~> 1.6.20)
|
||||||
hirb
|
hirb
|
||||||
|
@ -630,6 +615,7 @@ DEPENDENCIES
|
||||||
newrelic_rpm
|
newrelic_rpm
|
||||||
ng-rails-csrf
|
ng-rails-csrf
|
||||||
ngmin-rails
|
ngmin-rails
|
||||||
|
octokit (~> 4.0)
|
||||||
ohm (~> 1.3.2)
|
ohm (~> 1.3.2)
|
||||||
ohm-expire (~> 0.1.3)
|
ohm-expire (~> 0.1.3)
|
||||||
paperclip
|
paperclip
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Api::V1::BaseController < ApplicationController
|
||||||
def check_auth
|
def check_auth
|
||||||
authenticate_or_request_with_http_basic do |username,pw|
|
authenticate_or_request_with_http_basic do |username,pw|
|
||||||
if user = User.auth_by_token_or_login_pass(username, pw)
|
if user = User.auth_by_token_or_login_pass(username, pw)
|
||||||
sign_in user, false
|
sign_in user, store: false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,10 +15,27 @@ class Api::V1::JobsController < Api::V1::BaseController
|
||||||
for_platform(platform_ids).where(builder: nil).pluck('DISTINCT user_id').sample
|
for_platform(platform_ids).where(builder: nil).pluck('DISTINCT user_id').sample
|
||||||
|
|
||||||
if uid
|
if uid
|
||||||
build_lists = BuildList.scoped_to_arch(arch_ids).
|
if native_arch_ids.empty?
|
||||||
for_status([BuildList::BUILD_PENDING, BuildList::RERUN_TESTS]).
|
build_lists = BuildList.scoped_to_arch(arch_ids).for_platform(platform_ids).
|
||||||
for_platform(platform_ids).where(user_id: uid).where(builder: nil).oldest.order(:created_at)
|
where(native_build: false)
|
||||||
|
else
|
||||||
|
sql_normal = []
|
||||||
|
params = []
|
||||||
|
sql_normal << 'arch_id IN (?)' if !arch_ids.empty?
|
||||||
|
params << arch_ids if !arch_ids.empty?
|
||||||
|
sql_normal << 'platform_id IN (?)' if !platform_ids.empty?
|
||||||
|
params << platform_ids if !platform_ids.empty?
|
||||||
|
sql_normal << 'native_build=false'
|
||||||
|
sql_normal *= ' AND '
|
||||||
|
sql_native_arch = 'arch_id IN (?)'
|
||||||
|
params << native_arch_ids
|
||||||
|
sql_native_arch << ' AND platform_id IN (?)' if !platform_ids.empty?
|
||||||
|
params << platform_ids if !platform_ids.empty?
|
||||||
|
sql_native_arch << ' AND native_build=true'
|
||||||
|
build_lists = BuildList.where(sql_normal + ' OR ' + sql_native_arch, *params)
|
||||||
|
end
|
||||||
|
build_lists = build_lists.for_status([BuildList::BUILD_PENDING, BuildList::RERUN_TESTS]).
|
||||||
|
where(user_id: uid).where(builder: nil).oldest.order(:created_at)
|
||||||
if current_user.system?
|
if current_user.system?
|
||||||
@build_list = build_lists.where(external_nodes: ["", nil]).first
|
@build_list = build_lists.where(external_nodes: ["", nil]).first
|
||||||
@build_list ||= build_lists.external_nodes(:everything).first
|
@build_list ||= build_lists.external_nodes(:everything).first
|
||||||
|
@ -101,6 +118,16 @@ class Api::V1::JobsController < Api::V1::BaseController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def native_arch_ids
|
||||||
|
@native_arch_ids ||= begin
|
||||||
|
arches = params[:arches].to_s.split(',')
|
||||||
|
native_arches = params[:native_arches].to_s.split(',')
|
||||||
|
native_arches &= arches if !arches.empty?
|
||||||
|
puts native_arches
|
||||||
|
native_arches.present? ? Arch.where(name: native_arches).pluck(:id) : []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def set_builder
|
def set_builder
|
||||||
return unless @build_list
|
return unless @build_list
|
||||||
@build_list.builder = current_user
|
@build_list.builder = current_user
|
||||||
|
|
|
@ -3,6 +3,7 @@ class Projects::ProjectsController < Projects::BaseController
|
||||||
include ProjectsHelper
|
include ProjectsHelper
|
||||||
|
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
skip_before_action :authenticate_user!, only: [:commit, :diff]
|
||||||
before_action :who_owns, only: [:new, :create, :mass_import, :run_mass_import]
|
before_action :who_owns, only: [:new, :create, :mass_import, :run_mass_import]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -4,25 +4,17 @@ module Project::GithubApi
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
def github_data
|
def github_data
|
||||||
Github.repos.get user: github_get_organization, repo: name rescue nil
|
Octokit.repo github_get_organization + '/' + name rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def github_branches
|
def github_branches
|
||||||
Github.repos.branches user: github_get_organization, repo: name rescue nil
|
Octokit.branches github_get_organization + '/' + name rescue []
|
||||||
end
|
end
|
||||||
|
|
||||||
def github_tags
|
def github_tags
|
||||||
Github.repos.tags user: github_get_organization, repo: name rescue nil
|
Octokit.tags github_get_organization + '/' + name rescue []
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_blob_and_raw_of_spec_file(project_version)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_file(path, data, options = {})
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def github_get_organization
|
def github_get_organization
|
||||||
return github_organization if github_organization.presence
|
return github_organization if github_organization.presence
|
||||||
APP_CONFIG['github_organization']
|
APP_CONFIG['github_organization']
|
||||||
|
|
|
@ -97,7 +97,6 @@ class MassBuild < ActiveRecord::Base
|
||||||
if increase_rt
|
if increase_rt
|
||||||
inc_rt_sem = Redis::Semaphore.new(:increase_release_tag_lock)
|
inc_rt_sem = Redis::Semaphore.new(:increase_release_tag_lock)
|
||||||
inc_rt_sem.lock
|
inc_rt_sem.lock
|
||||||
ratelimit_remaining = Github_blobs_api.ratelimit_remaining
|
|
||||||
end
|
end
|
||||||
|
|
||||||
projects_list.lines.each do |name|
|
projects_list.lines.each do |name|
|
||||||
|
@ -110,18 +109,11 @@ class MassBuild < ActiveRecord::Base
|
||||||
# Ensures that user has rights to create a build_list
|
# Ensures that user has rights to create a build_list
|
||||||
next unless ProjectPolicy.new(user, project).write?
|
next unless ProjectPolicy.new(user, project).write?
|
||||||
if increase_rt
|
if increase_rt
|
||||||
if ratelimit_remaining <= 1
|
ratelimit = Github_blobs_api.ratelimit
|
||||||
ratelimit_remaining = Github_blobs_api.ratelimit_remaining
|
if ratelimit.remaining <= 1
|
||||||
#if that's still less that or equal 1
|
sleep ratelimit.resets_in
|
||||||
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
|
|
||||||
end
|
end
|
||||||
count = project.increase_release_tag(project_version, "MassBuild##{id}: Increase release tag")
|
project.increase_release_tag(project_version, "MassBuild##{id}: Increase release tag")
|
||||||
ratelimit_remaining -= count
|
|
||||||
end
|
end
|
||||||
arches_list.each do |arch|
|
arches_list.each do |arch|
|
||||||
rep_id = (project.repository_ids & save_to_platform.repository_ids).first
|
rep_id = (project.repository_ids & save_to_platform.repository_ids).first
|
||||||
|
|
|
@ -216,13 +216,14 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def increase_release_tag(project_version, message)
|
def increase_release_tag(project_version, message)
|
||||||
file = Github_blobs_api.get github_get_organization, name, '/' + name + '.spec', ref: project_version rescue return 1
|
file = Github_blobs_api.contents github_get_organization + '/' + name, path: '/' + name + '.spec', ref: project_version rescue nil
|
||||||
decoded_content = Base64.decode64(file.content)
|
if file
|
||||||
new_content = Project.replace_release_tag decoded_content
|
decoded_content = Base64.decode64(file.content)
|
||||||
return 1 if new_content == decoded_content
|
new_content = Project.replace_release_tag decoded_content
|
||||||
Github_blobs_api.update github_get_organization, name, '/' + name + '.spec', path: '/' + name + '.spec',\
|
return if new_content == decoded_content
|
||||||
message: message, content: new_content, sha: file.sha rescue return 2
|
Github_blobs_api.update_contents github_get_organization + '/' + name, '/' + name + '.spec',\
|
||||||
return 2
|
message, file.sha, new_content, branch: project_version rescue nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -68,6 +68,7 @@ class BuildListPolicy < ApplicationPolicy
|
||||||
include_testing_subrepository
|
include_testing_subrepository
|
||||||
project_id
|
project_id
|
||||||
project_version
|
project_version
|
||||||
|
native_build
|
||||||
save_buildroot
|
save_buildroot
|
||||||
save_to_platform_id
|
save_to_platform_id
|
||||||
save_to_repository_id
|
save_to_repository_id
|
||||||
|
|
|
@ -22,7 +22,7 @@ h4.offset10= t("activerecord.attributes.build_list.preferences")
|
||||||
name= 'build_list[auto_create_container]' ]
|
name= 'build_list[auto_create_container]' ]
|
||||||
= BuildList.human_attribute_name :auto_create_container
|
= BuildList.human_attribute_name :auto_create_container
|
||||||
|
|
||||||
- %i(include_testing_subrepository use_cached_chroot use_extra_tests save_buildroot).each do |kind|
|
- %i(include_testing_subrepository use_cached_chroot use_extra_tests save_buildroot native_build).each do |kind|
|
||||||
.checkbox
|
.checkbox
|
||||||
label
|
label
|
||||||
- checked = params[:build_list].try(:[], kind)
|
- checked = params[:build_list].try(:[], kind)
|
||||||
|
|
|
@ -20,7 +20,7 @@ Rails.application.configure do
|
||||||
# since you don't have to restart the web server when you make code changes.
|
# since you don't have to restart the web server when you make code changes.
|
||||||
config.cache_classes = false
|
config.cache_classes = false
|
||||||
|
|
||||||
config.cache_store = :redis_store, 'redis://localhost:6379/0/cache', { expires_in: 10.minutes }
|
config.cache_store = :redis_store, 'redis://localhost:6379/0', { expires_in: 10.minutes }
|
||||||
# Do not eager load code on boot.
|
# Do not eager load code on boot.
|
||||||
config.eager_load = false
|
config.eager_load = false
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ Rails.application.configure do
|
||||||
|
|
||||||
# Use a different cache store in production.
|
# Use a different cache store in production.
|
||||||
# config.cache_store = :mem_cache_store
|
# config.cache_store = :mem_cache_store
|
||||||
config.cache_store = :redis_store, (ENV["REDIS_URL"].to_s + '/cache'), { expires_in: 10.minutes }
|
config.cache_store = :redis_store, (ENV["REDIS_URL"].to_s), { expires_in: 10.minutes }
|
||||||
|
|
||||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
||||||
# config.action_controller.asset_host = "http://assets.example.com"
|
# config.action_controller.asset_host = "http://assets.example.com"
|
||||||
|
|
|
@ -45,9 +45,6 @@ Devise.setup do |config|
|
||||||
# Tell if authentication through request.params is enabled. True by default.
|
# Tell if authentication through request.params is enabled. True by default.
|
||||||
# config.params_authenticatable = true
|
# config.params_authenticatable = true
|
||||||
|
|
||||||
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
|
|
||||||
config.http_authenticatable = true
|
|
||||||
|
|
||||||
# If http headers should be returned for AJAX requests. True by default.
|
# If http headers should be returned for AJAX requests. True by default.
|
||||||
# config.http_authenticatable_on_xhr = true
|
# config.http_authenticatable_on_xhr = true
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
#configuration of Github api gem
|
#configuration of Github api gem
|
||||||
|
|
||||||
Github.configure do |c|
|
Github_blobs_api = Octokit::Client.new(login: ENV['GITHUB_REPO_BOT_LOGIN'], password: ENV['GITHUB_REPO_BOT_PASSWORD'])
|
||||||
c.basic_auth = ENV["GITHUB_LOGIN"] + ":" + ENV["GITHUB_PASSWORD"]
|
|
||||||
c.auto_pagination = true
|
|
||||||
end
|
|
||||||
|
|
||||||
#for updating repo contents
|
Octokit.configure do |c|
|
||||||
Github_blobs_api = Github::Client::Repos::Contents.new(basic_auth: ENV['GITHUB_REPO_BOT_LOGIN'] + ":" + ENV['GITHUB_REPO_BOT_PASSWORD'])
|
c.login = ENV["GITHUB_LOGIN"]
|
||||||
|
c.password = ENV["GITHUB_PASSWORD"]
|
||||||
|
end
|
||||||
|
Octokit.middleware = Faraday::RackBuilder.new do |builder|
|
||||||
|
store = ActiveSupport::Cache.lookup_store(:redis_store, ENV['REDIS_URL'].to_s + '/1')
|
||||||
|
builder.use Faraday::HttpCache, store: store, shared_cache: false
|
||||||
|
builder.use Octokit::Response::RaiseError
|
||||||
|
builder.adapter Faraday.default_adapter
|
||||||
|
end
|
|
@ -1,3 +1,3 @@
|
||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
Rails.application.config.session_store :cookie_store, key: '_rosa_session'
|
Rails.application.config.session_store :cookie_store, key: '_abf_session'
|
||||||
|
|
|
@ -12,6 +12,7 @@ en:
|
||||||
extra_mass_builds: Extra mass builds
|
extra_mass_builds: Extra mass builds
|
||||||
auto_create_container: Create container automatically
|
auto_create_container: Create container automatically
|
||||||
use_cached_chroot: Use cached chroot
|
use_cached_chroot: Use cached chroot
|
||||||
|
native_build: Native build
|
||||||
use_extra_tests: Use extra tests
|
use_extra_tests: Use extra tests
|
||||||
save_buildroot: Save RPM build root
|
save_buildroot: Save RPM build root
|
||||||
container_path: Container path
|
container_path: Container path
|
||||||
|
|
|
@ -15,6 +15,7 @@ ru:
|
||||||
use_extra_tests: Использовать дополнительные тесты
|
use_extra_tests: Использовать дополнительные тесты
|
||||||
save_buildroot: Сохранить RPM build root
|
save_buildroot: Сохранить RPM build root
|
||||||
container_path: Путь до контейнера
|
container_path: Путь до контейнера
|
||||||
|
native_build: Нативная сборка
|
||||||
status: Статус
|
status: Статус
|
||||||
project_id: Проект
|
project_id: Проект
|
||||||
project: Проект
|
project: Проект
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddNativeBuildToBuildLists < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :build_lists, :native_build, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20160323122230) do
|
ActiveRecord::Schema.define(version: 20160326104007) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -112,6 +112,7 @@ ActiveRecord::Schema.define(version: 20160323122230) do
|
||||||
t.boolean "save_buildroot", default: false, null: false
|
t.boolean "save_buildroot", default: false, null: false
|
||||||
t.string "hostname"
|
t.string "hostname"
|
||||||
t.string "fail_reason"
|
t.string "fail_reason"
|
||||||
|
t.boolean "native_build", default: false
|
||||||
end
|
end
|
||||||
add_index "build_lists", ["project_id", "save_to_repository_id", "build_for_platform_id", "arch_id"], name: "maintainer_search_index"
|
add_index "build_lists", ["project_id", "save_to_repository_id", "build_for_platform_id", "arch_id"], name: "maintainer_search_index"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue