diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..ed62e9001 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,28 @@ +*~ +1.sh +.bundle +.rvmrc +.DS_Store +db/*.sqlite3 +log/*.log +tmp/ +config/database.yml +.idea +config/application.yml +public/assets/* +config/initializers/local.rb +public/system/* +public/downloads/* +*.swp +*.tmproj +.sass-cache/ +dump.rdb +crash.log +config/newrelic.yml +config/deploy/*.rb +config/deploy.rb +.swo +.swn +.ruby-gemset +.ruby-version +.localeapp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..c9a4fd057 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM ruby:2.6.6-alpine3.13 as rosa-build-gems + +WORKDIR /rosa-build +RUN apk add --no-cache libpq tzdata ca-certificates git icu rpm nodejs python2 redis && \ + apk add --virtual .ruby-builddeps --no-cache postgresql-dev build-base cmake icu-dev +RUN gem install bundler:1.17.3 +COPY vendor ./vendor +COPY Gemfile Gemfile.lock ./ +RUN bundle install --without development test --jobs 16 --clean --deployment --no-cache --verbose && \ + apk add --no-cache file imagemagick curl gnupg openssh-keygen findutils && \ + apk del .ruby-builddeps && rm -rf /root/.bundle && rm -rf /proxy/vendor/bundle/ruby/2.6.0/cache && \ + git clone -b 2.2.0 https://github.com/pygments/pygments.git && cd pygments && python setup.py install && cd .. && rm -rf pygments && \ + cd /rosa-build/vendor/bundle/ruby && find -name *.o -exec rm {} \; + +FROM scratch +COPY --from=rosa-build-gems / / + +RUN touch /MIGRATE +ENV RAILS_ENV production + +ENV GEM_HOME /usr/local/bundle +ENV BUNDLE_APP_CONFIG /usr/local/bundle +ENV DATABASE_URL postgresql://postgres@postgres/rosa-build?pool=100&prepared_statements=false + +WORKDIR /rosa-build +COPY bin ./bin +COPY lib ./lib +COPY config ./config +COPY db ./db +COPY app/ ./app +COPY script ./script +COPY vendor ./vendor +COPY Rakefile config.ru entrypoint.sh entrypoint_resque.sh entrypoint_resque_scheduler.sh ./ +RUN git config --global user.email "abf@openmandriva.org" +RUN git config --global user.name "ABF" +ENTRYPOINT ["/rosa-build/entrypoint.sh"] diff --git a/Gemfile b/Gemfile index 7f64beaf0..c0cba793c 100644 --- a/Gemfile +++ b/Gemfile @@ -22,8 +22,6 @@ gem 'russian' gem 'state_machines-activerecord' gem 'redis-rails' -#gem 'newrelic_rpm' - gem 'jbuilder' gem 'sprockets' gem 'will_paginate' diff --git a/app/models/concerns/abf_worker_methods.rb b/app/models/concerns/abf_worker_methods.rb index d3b4b9891..aa784b796 100644 --- a/app/models/concerns/abf_worker_methods.rb +++ b/app/models/concerns/abf_worker_methods.rb @@ -6,10 +6,7 @@ module AbfWorkerMethods module ClassMethods def log_server - @log_server ||= Redis.new( - host: APP_CONFIG['abf_worker']['log_server']['host'], - port: APP_CONFIG['abf_worker']['log_server']['port'] - ) + @log_server ||= Redis.new(url: ENV['REDIS_URL']) end def next_build diff --git a/config/application.yml.sample b/config/application.yml.sample deleted file mode 100644 index 02e8cfa56..000000000 --- a/config/application.yml.sample +++ /dev/null @@ -1,80 +0,0 @@ -common: &common - project_name: ABF - repo_project_name: ABF - anonymous_access: true - preregistration: false - file_store_url: <%= ENV["FILE_STORE_URL"] %> - distr_types: ['mdv', 'rhel', 'nau5'] - github_organization: 'OpenMandrivaAssociation' - allowed_addresses: - - 127.0.0.1 - abf_worker: - publish_workers_count: <%= ENV["ABF_WORKER_PUBLISH_WORKERS_COUNT"] %> - log_server: - host: <%= ENV["ABF_WORKER_LOG_SERVER_HOST"] %> - port: <%= ENV["ABF_WORKER_LOG_SERVER_PORT"] %> - airbrake: - api_key: <%= ENV["AIRBRAKE_API_KEY"] %> - host: <%= ENV["AIRBRAKE_HOST"] %> - keys: - key_pair_secret_key: <%= ENV["KEY_PAIR_SECRET_KEY"] %> - node_instruction_secret_key: <%= ENV["NODE_INSTRUCTION_SECRET_KEY"] %> - secret_token: <%= ENV["SECRET_TOKEN"] %> - secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> - devise: - pepper: <%= ENV["DEVISE_PEPPER"] %> - secret: <%= ENV["DEVISE_SECRET"] %> - github: - id: <%= ENV["GITHUB_APP_ID"] %> - secret: <%= ENV["GITHUB_APP_SECRET"] %> - google: - id: <%= ENV["GOOGLE_APP_ID"] %> - secret: <%= ENV["GOOGLE_APP_SECRET"] %> - facebook: - id: <%= ENV["FACEBOOK_APP_ID"] %> - secret: <%= ENV["FACEBOOK_APP_SECRET"] %> - downloads_url: <%= ENV["DOWNLOADS_URL"] %> - wiki_formats: - markdown: "Markdown" - textile: "Textile" - # rdoc: "RDoc" - org: "Org-mode" - # creole: "Creole" - # mediawiki: "MediaWiki" - feedback: - email: - - <%= ENV["FEEDBACK_EMAIL"] %> - cc: - - <%= ENV["FEEDBACK_CC"] %> - subject_prefixes: - - 'abf-users' - - 'feeback_form' - shell_user: 'git' - -development: - <<: *common - root_path: /share - git_path: /share - tmpfs_path: /dev/shm - do-not-reply-email: do-not-reply@localhost - github_services: - ip: 127.0.0.1 - port: 1234 - -production: - <<: *common - root_path: <%= ENV["ROOT_PATH"] %> - git_path: <%= ENV["GIT_PATH"] %> - tmpfs_path: <%= ENV["TMPFS_PATH"] %> - do-not-reply-email: <%= ENV["DO_NOT_REPLY_EMAIL"] %> - mailer_https_url: <%= ENV["MAILER_HTTPS_URL"] %> - github_services: - ip: <%= ENV["GITHUB_SERVICES_ID"] %> - port: <%= ENV["GITHUB_SERVICES_PORT"] %> - -test: - <<: *common - tmpfs_path: "use Rails.root/tmp/test_root in spec" - root_path: "use Rails.root/tmp/test_root in spec" - git_path: "use Rails.root/tmp/test_root in spec" - do-not-reply-email: do-not-reply@localhost diff --git a/config/application.yml.travis b/config/application.yml.travis deleted file mode 100644 index 73af51757..000000000 --- a/config/application.yml.travis +++ /dev/null @@ -1,65 +0,0 @@ -common: &common - project_name: ABF - repo_project_name: ABF - anonymous_access: true - preregistration: false - file_store_url: 'https://file-store.openmandriva.org' - distr_types: ['mdv', 'rhel', 'nau5'] - allowed_addresses: - - 127.0.0.100 - abf_worker: - publish_workers_count: 2 - log_server: - host: 127.0.0.1 - port: 6379 - airbrake: - api_key: 'airbrake_api_key' - host: 'errbit.example.com' - keys: - key_pair_secret_key: 'key_pair_secret_key' - node_instruction_secret_key: 'node_instruction_secret_key' - devise_pepper: 'e295a79fb7966e94a6e8b184ba65791a' - secret_token: 'e295a79fb7966e94a6e8b184ba65791a' - devise: - pepper: 'e295a79fb7966e94a6e8b184ba65791a' - secret: '82e10b58b3f4a764f551fb104aa76808f539380f82da75d3f29edfc09ed9c3a153c22ceacc87890a9b19d0ad89bb6484481f4e021e0ecf942d80c34d930829e9' - github: - id: 'APP_ID' - secret: 'APP_SECRET' - google: - id: 'APP_ID' - secret: 'APP_SECRET' - facebook: - id: 'APP_ID' - secret: 'APP_SECRET' - downloads_url: 'http://abf-downloads.openmandriva.org' - wiki_formats: - markdown: "Markdown" - textile: "Textile" - # rdoc: "RDoc" - org: "Org-mode" - # creole: "Creole" - # mediawiki: "MediaWiki" - feedback: - email: - - 'test@example.com' - - 'test1@example.com' - # or - # email: 'test@example.com' - - # optional parameters - cc: - - 'test2@example.com' # or like email - bcc: - - 'test3@example.com' # or like email - subject_prefixes: # or one line - - 'from_feedback' - subject_postfixes: # or one line - - 'sample_postfix' - shell_user: 'git' - -test: - <<: *common - root_path: /home/travis/build/rosa-abf/rosa-build/tmp/test_root - git_path: /home/travis/build/rosa-abf/rosa-build/tmp/test_root - do-not-reply-email: do-not-reply@localhost diff --git a/config/database.yml.sample b/config/database.yml.sample deleted file mode 100644 index 41bb8e6d3..000000000 --- a/config/database.yml.sample +++ /dev/null @@ -1,18 +0,0 @@ -production: - adapter: postgresql - encoding: unicode - database: <%= ENV["DATABASE_NAME"] %> - template: template0 - host: <%= ENV["DATABASE_HOST"] %> - username: <%= ENV["DATABASE_USERNAME"] %> - password: <%= ENV["DATABASE_PASSWORD"] %> - pool: <%= ENV["DATABASE_POOL"] %> - timeout: <%= ENV["DATABASE_TIMEOUT"] %> - prepared_statements: false - -test: - adapter: postgresql - encoding: unicode - template: template0 - database: rosa_build_test - username: postgres diff --git a/config/environments/production.rb b/config/environments/production.rb index aaced6521..64ada3a1e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -52,7 +52,7 @@ Rails.application.configure do # Use a different cache store in production. # config.cache_store = :mem_cache_store - config.cache_store = :redis_store, (ENV["REDIS_URL"].to_s), { expires_in: 10.minutes } + config.cache_store = :redis_store, (ENV["REDIS_CACHE_URL"].to_s), { expires_in: 10.minutes } # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = "http://assets.example.com" diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 484a78f75..298936f44 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -66,7 +66,7 @@ Devise.setup do |config| config.stretches = Rails.env.test? ? 1 : 10 # Setup a pepper to generate the encrypted password. - config.pepper = APP_CONFIG['keys']['devise']['pepper'] + config.pepper = ENV["DEVISE_PEPPER"] # ==> Configuration for :confirmable # A period that the user is allowed to access the website even without @@ -184,7 +184,6 @@ Devise.setup do |config| # Add a new OmniAuth provider. Check the wiki for more information on setting # up on your models and hooks. # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' - config.omniauth :github, APP_CONFIG['keys']['github']['id'], APP_CONFIG['keys']['github']['secret'], scope: 'user:email' # require 'openid/store/filesystem' # config.omniauth :openid, :name => 'open_id' #, :store => OpenID::Store::Filesystem.new('./tmp') @@ -199,7 +198,7 @@ Devise.setup do |config| # manager.default_strategies(:scope => :user).unshift :some_external_strategy # end - config.secret_key = APP_CONFIG['keys']['devise']['secret'] + config.secret_key = ENV["DEVISE_SECRET"] config.reconfirmable = false end diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb deleted file mode 100644 index d3a15f803..000000000 --- a/config/initializers/secret_token.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -Rosa::Application.config.secret_token = APP_CONFIG['keys']['secret_token'] -Rosa::Application.config.secret_key_base = APP_CONFIG['keys']['secret_key_base'] diff --git a/config/newrelic.yml.sample b/config/newrelic.yml.sample deleted file mode 100644 index 15ad09c1d..000000000 --- a/config/newrelic.yml.sample +++ /dev/null @@ -1,229 +0,0 @@ -# -# This file configures the New Relic Agent. New Relic monitors -# Ruby, Java, .NET, PHP, and Python applications with deep visibility and low overhead. -# For more information, visit www.newrelic.com. -# -# Generated January 26, 2012 -# -# This configuration file is custom generated for Rosalab - -# Here are the settings that are common to all environments: -common: &default_settings - # ============================== LICENSE KEY =============================== - - # You must specify the license key associated with your New Relic - # account. This key binds your Agent's data to your account in the - # New Relic service. - license_key: 'license_key' - - # Agent Enabled (Ruby/Rails Only) - # Use this setting to force the agent to run or not run. - # Default is 'auto' which means the agent will install and run only - # if a valid dispatcher such as Mongrel is running. This prevents - # it from running with Rake or the console. Set to false to - # completely turn the agent off regardless of the other settings. - # Valid values are true, false and auto. - # agent_enabled: auto - - # Application Name - # Set this to be the name of your application as you'd like it show - # up in New Relic. New Relic will then auto-map instances of your application - # into a New Relic "application" on your home dashboard page. If you want - # to map this instance into multiple apps, like "AJAX Requests" and - # "All UI" then specify a semicolon-separated list of up to three - # distinct names. If you comment this out, it defaults to the - # capitalized RAILS_ENV (i.e., Production, Staging, etc) - app_name: ABF - - # When "true", the agent collects performance data about your - # application and reports this data to the New Relic service at - # newrelic.com. This global switch is normally overridden for each - # environment below. (formerly called 'enabled') - monitor_mode: true - - # Developer mode should be off in every environment but - # development as it has very high overhead in memory. - developer_mode: false - - # The newrelic agent generates its own log file to keep its logging - # information separate from that of your application. Specify its - # log level here. - log_level: info - - # The newrelic agent communicates with the New Relic service via http by - # default. If you want to communicate via https to increase - # security, then turn on SSL by setting this value to true. Note, - # this will result in increased CPU overhead to perform the - # encryption involved in SSL communication, but this work is done - # asynchronously to the threads that process your application code, - # so it should not impact response times. - ssl: false - - # EXPERIMENTAL: enable verification of the SSL certificate sent by - # the server. This setting has no effect unless SSL is enabled - # above. This may block your application. Only enable it if the data - # you send us needs end-to-end verified certificates. - # - # This means we cannot cache the DNS lookup, so each request to the - # New Relic service will perform a lookup. It also means that we cannot - # use a non-blocking lookup, so in a worst case, if you have DNS - # problems, your app may block indefinitely. - # verify_certificate: true - - # Set your application's Apdex threshold value with the 'apdex_t' - # setting, in seconds. The apdex_t value determines the buckets used - # to compute your overall Apdex score. - # Requests that take less than apdex_t seconds to process will be - # classified as Satisfying transactions; more than apdex_t seconds - # as Tolerating transactions; and more than four times the apdex_t - # value as Frustrating transactions. - # For more about the Apdex standard, see - # http://newrelic.com/docs/general/apdex - apdex_t: 0.5 - - # Proxy settings for connecting to the New Relic server. - # - # If a proxy is used, the host setting is required. Other settings - # are optional. Default port is 8080. - # - # proxy_host: hostname - # proxy_port: 8080 - # proxy_user: - # proxy_pass: - - # Tells transaction tracer and error collector (when enabled) - # whether or not to capture HTTP params. When true, frameworks can - # exclude HTTP parameters from being captured. - # Rails: the RoR filter_parameter_logging excludes parameters - # Java: create a config setting called "ignored_params" and set it to - # a comma separated list of HTTP parameter names. - # ex: ignored_params: credit_card, ssn, password - capture_params: false - - # Transaction tracer captures deep information about slow - # transactions and sends this to the New Relic service once a - # minute. Included in the transaction is the exact call sequence of - # the transactions including any SQL statements issued. - transaction_tracer: - - # Transaction tracer is enabled by default. Set this to false to - # turn it off. This feature is only available at the Professional - # product level. - enabled: true - - # Threshold in seconds for when to collect a transaction - # trace. When the response time of a controller action exceeds - # this threshold, a transaction trace will be recorded and sent to - # New Relic. Valid values are any float value, or (default) "apdex_f", - # which will use the threshold for an dissatisfying Apdex - # controller action - four times the Apdex T value. - transaction_threshold: apdex_f - - # When transaction tracer is on, SQL statements can optionally be - # recorded. The recorder has three modes, "off" which sends no - # SQL, "raw" which sends the SQL statement in its original form, - # and "obfuscated", which strips out numeric and string literals. - record_sql: obfuscated - - # Threshold in seconds for when to collect stack trace for a SQL - # call. In other words, when SQL statements exceed this threshold, - # then capture and send to New Relic the current stack trace. This is - # helpful for pinpointing where long SQL calls originate from. - stack_trace_threshold: 0.500 - - # Determines whether the agent will capture query plans for slow - # SQL queries. Only supported in mysql and postgres. Should be - # set to false when using other adapters. - # explain_enabled: true - - # Threshold for query execution time below which query plans will not - # not be captured. Relevant only when `explain_enabled` is true. - # explain_threshold: 0.5 - - # Error collector captures information about uncaught exceptions and - # sends them to New Relic for viewing - error_collector: - - # Error collector is enabled by default. Set this to false to turn - # it off. This feature is only available at the Professional - # product level. - enabled: true - - # Rails Only - tells error collector whether or not to capture a - # source snippet around the place of the error when errors are View - # related. - capture_source: true - - # To stop specific errors from reporting to New Relic, set this property - # to comma-separated values. Default is to ignore routing errors, - # which are how 404's get triggered. - ignore_errors: ActionController::RoutingError - - # (Advanced) Uncomment this to ensure the CPU and memory samplers - # won't run. Useful when you are using the agent to monitor an - # external resource - # disable_samplers: true - - # If you aren't interested in visibility in these areas, you can - # disable the instrumentation to reduce overhead. - # - # disable_view_instrumentation: true - # disable_activerecord_instrumentation: true - # disable_memcache_instrumentation: true - # disable_dj: true - - # Certain types of instrumentation such as GC stats will not work if - # you are running multi-threaded. Please let us know. - # multi_threaded = false - -# Application Environments -# ------------------------------------------ -# Environment-specific settings are in this section. -# For Rails applications, RAILS_ENV is used to determine the environment. -# For Java applications, pass -Dnewrelic.environment to set -# the environment. - -# NOTE if your application has other named environments, you should -# provide newrelic configuration settings for these environments here. - -development: - <<: *default_settings - # Turn off communication to New Relic service in development mode (also - # 'enabled'). - # NOTE: for initial evaluation purposes, you may want to temporarily - # turn agent communication on in development mode. - monitor_mode: false - - # Rails Only - when running in Developer Mode, the New Relic Agent will - # present performance information on the last 100 transactions you have - # executed since starting the app server. - # NOTE: There is substantial overhead when running in developer mode. - # Do not use for production or load testing. - developer_mode: true - - # Enable textmate links - # textmate: true - -test: - <<: *default_settings - # It almost never makes sense to turn on the agent when running - # unit, functional or integration tests or the like. - monitor_mode: false - -# Turn on the agent in production for 24x7 monitoring. New Relic -# testing shows an average performance impact of < 5 ms per -# transaction, so you can leave this on all the time without -# incurring any user-visible performance degradation. -production: - <<: *default_settings - monitor_mode: true - dispatcher: 'puma' - -# Many applications have a staging environment which behaves -# identically to production. Support for that environment is provided -# here. By default, the staging environment has the agent turned on. -staging: - <<: *default_settings - monitor_mode: true - app_name: ABF (Staging) - dispatcher: 'puma' diff --git a/doc/state_machines/BuildList_container_status.png b/doc/state_machines/BuildList_container_status.png deleted file mode 100644 index 2d6d72a05..000000000 Binary files a/doc/state_machines/BuildList_container_status.png and /dev/null differ diff --git a/doc/state_machines/BuildList_status.png b/doc/state_machines/BuildList_status.png deleted file mode 100644 index 33dc2160d..000000000 Binary files a/doc/state_machines/BuildList_status.png and /dev/null differ diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 000000000..b820601d5 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -ex + +if [ -f /MIGRATE ] +then + bundle exec rake db:migrate + rm /MIGRATE +fi + +rm -rf public/assets/* +bundle exec rake assets:precompile +cd public/assets +rm -f new_application.css new_application.js +ln -sv new_application*.css new_application.css +ln -sv new_application*.js new_application.js +cd ../.. +RUBYOPT="-W0" bundle exec puma -C /rosa-build/config/puma/production.rb diff --git a/entrypoint_sidekiq.sh b/entrypoint_sidekiq.sh new file mode 100755 index 000000000..28f4f6fbd --- /dev/null +++ b/entrypoint_sidekiq.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -ex + +cd /rosa-build + +bundle exec sidekiq -q iso_worker_observer -q low -q middle -q notification -q publish_observer -q rpm_worker_observer -c 5 -e production diff --git a/jobs/clean_api_defender_statistics_job_spec.rb b/jobs/clean_api_defender_statistics_job_spec.rb deleted file mode 100644 index 228c232f9..000000000 --- a/jobs/clean_api_defender_statistics_job_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper' - -describe CleanApiDefenderStatisticsJob do - - it 'ensures that not raises error' do - lambda do - CleanApiDefenderStatisticsJob.perform - end.should_not raise_exception - end - - it 'ensures that cleans only old statistics' do - today = Date.today - Timecop.freeze(today) do - key1 = "throttle:key1:#{today.strftime('%Y-%m-%d')}" - key2 = "throttle:key2:#{today.strftime('%Y-%m-%d')}T01" - key3 = "throttle:key1:#{(today - 32.days).strftime('%Y-%m-%d')}" - key4 = "throttle:key2:#{(today - 32.days).strftime('%Y-%m-%d')}T01" - key5 = "other:throttle:key:#{(today - 32.days).strftime('%Y-%m-%d')}" - @redis_instance.set key1, 1 - @redis_instance.set key2, 1 - @redis_instance.set key3, 1 - @redis_instance.set key4, 1 - @redis_instance.set key5, 1 - - CleanApiDefenderStatisticsJob.perform - @redis_instance.keys.should include(key1, key2, key5) - @redis_instance.keys.should_not include(key3, key4) - end - end - -end diff --git a/jobs/clean_buildroot_job_spec.rb b/jobs/clean_buildroot_job_spec.rb deleted file mode 100644 index a1be850a3..000000000 --- a/jobs/clean_buildroot_job_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe BuildLists::CleanBuildrootJob do - - before { stub_symlink_methods } - subject { BuildLists::CleanBuildrootJob } - - it 'ensures that not raises error' do - FactoryGirl.create(:build_list, status: BuildList::BUILD_ERROR) - expect(FileStoreService::File).to_not receive(:new) - expect do - subject.perform - end.to_not raise_exception - end - - it 'cleans RPM buildroot' do - results = [ - { 'sha1' => 'sha1-1', 'file_name' => BuildLists::CleanBuildrootJob::FILENAME }, - { 'sha1' => 'sha1-2', 'file_name' => 'test.log' } - ] - FactoryGirl.create(:build_list, - results: results, - save_buildroot: true, - status: BuildList::BUILD_ERROR - ) - bl = FactoryGirl.create(:build_list, - results: results, - save_buildroot: true, - status: BuildList::BUILD_ERROR, - updated_at: Time.now - 2.hours - ) - file_store_service = double(:file_store_service, destroy: true) - - expect(FileStoreService::File).to receive(:new).with(sha1: 'sha1-1').and_return(file_store_service) - - subject.perform - expect(bl.reload.results).to eq [{ 'sha1' => 'sha1-2', 'file_name' => 'test.log' }] - end - -end diff --git a/jobs/create_empty_metadata_job_spec.rb b/jobs/create_empty_metadata_job_spec.rb deleted file mode 100644 index 8c63e45c1..000000000 --- a/jobs/create_empty_metadata_job_spec.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'spec_helper' - -describe CreateEmptyMetadataJob do - - before { stub_symlink_methods } - subject { BuildLists::CleanBuildrootJob } - - context 'create_empty_metadata' do - let(:job) { CreateEmptyMetadataJob.new } - let(:platform) { FactoryGirl.build(:platform) } - let(:path) { platform.path } - - it 'creates metadata for rhel platform' do - platform.distrib_type = 'rhel' - job.send :create_empty_metadata, platform, path.dup - - expect(Dir["#{ path }/repodata/*"]).to be_present - expect(Dir["#{ path }/media_info/*"]).to be_empty - end - - it 'creates metadata for mdv platform' do - platform.distrib_type = 'mdv' - job.send :create_empty_metadata, platform, path.dup - - expect(Dir["#{ path }/media_info/*"]).to be_present - expect(Dir["#{ path }/repodata/*"]).to be_empty - end - - it 'does nothing for other platforms' do - platform.distrib_type = 'test' - job.send :create_empty_metadata, platform, path.dup - - expect(Dir["#{ path }/media_info/*"]).to be_empty - expect(Dir["#{ path }/repodata/*"]).to be_empty - end - end - - context 'create_empty_metadata_for_repository' do - let(:job) { CreateEmptyMetadataJob.new } - let(:repository) { FactoryGirl.build(:repository) } - let(:platform) { repository.platform } - - before do - allow(job).to receive(:arch_names).and_return(%w(i586 x86_64)) - end - - it 'repository of main platform' do - paths = <<-STR - #{ platform.path }/repository/i586/#{ repository.name }/release - #{ platform.path }/repository/i586/#{ repository.name }/updates - #{ platform.path }/repository/x86_64/#{ repository.name }/release - #{ platform.path }/repository/x86_64/#{ repository.name }/updates - STR - paths.split("\n").each do |path| - expect(job).to receive(:create_empty_metadata).with(platform, path.strip) - end - - job.send :create_empty_metadata_for_repository, repository - end - - it 'repository of personal platform' do - platform.platform_type = Platform::TYPE_PERSONAL - Platform.stub_chain(:main, :opened).and_return([platform]) - paths = <<-STR - #{ platform.path }/repository/#{ platform.name }/i586/#{ repository.name }/release - #{ platform.path }/repository/#{ platform.name }/i586/#{ repository.name }/updates - #{ platform.path }/repository/#{ platform.name }/x86_64/#{ repository.name }/release - #{ platform.path }/repository/#{ platform.name }/x86_64/#{ repository.name }/updates - STR - paths.split("\n").each do |path| - expect(job).to receive(:create_empty_metadata).with(platform, path.strip) - end - - job.send :create_empty_metadata_for_repository, repository - end - end - - context 'create_empty_metadata_for_platform' do - let(:platform) { FactoryGirl.build(:platform, id: 123) } - let(:repository1) { FactoryGirl.build(:personal_repository) } - let(:repository2) { FactoryGirl.build(:personal_repository) } - let(:job) { CreateEmptyMetadataJob.new('Platform', 123) } - - before do - Platform.stub_chain(:main, :opened, :find).and_return(platform) - Repository.stub_chain(:joins, :where, :find_each).and_yield(repository1).and_yield(repository2) - end - - it 'creates metadata for all personal repositories' do - expect(job).to receive(:create_empty_metadata_for_repository).with(repository1) - expect(job).to receive(:create_empty_metadata_for_repository).with(repository2) - - job.send :create_empty_metadata_for_platform - end - end - -end diff --git a/jobs/dependent_packages_job_spec.rb b/jobs/dependent_packages_job_spec.rb deleted file mode 100644 index 4dc07b970..000000000 --- a/jobs/dependent_packages_job_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'spec_helper' - -describe BuildLists::DependentPackagesJob do - let(:build_list) { FactoryGirl.build(:build_list, id: 123) } - let(:user) { build_list.user } - let(:project) { build_list.project } - let(:project_ids) { [build_list.project_id] } - let(:arch_ids) { [build_list.arch_id] } - let(:options) { { - 'auto_publish_status' => 'none', - 'auto_create_container' => '0', - 'include_testing_subrepository' => '0', - 'use_cached_chroot' => '0', - 'use_extra_tests' => '0' - } } - - before do - stub_symlink_methods - allow(BuildList).to receive(:find).with(123).and_return(build_list) - allow(Project).to receive_message_chain(:where, :to_a).and_return([project]) - allow(Arch).to receive_message_chain(:where, :to_a).and_return([build_list.arch]) - - allow_any_instance_of(BuildList).to receive(:update_statistic) - allow_any_instance_of(BuildListPolicy).to receive(:show?).and_return(true) - allow_any_instance_of(ProjectPolicy).to receive(:write?).and_return(true) - allow_any_instance_of(BuildListPolicy).to receive(:create?).and_return(true) - end - - subject { BuildLists::DependentPackagesJob } - - it 'ensures that not raises error' do - expect do - subject.perform build_list.id, user.id, project_ids, arch_ids, options - end.to_not raise_exception - end - - it 'ensures that creates build_list' do - expect do - subject.perform build_list.id, user.id, project_ids, arch_ids, options - end.to change(BuildList, :count).by(1) - end - - it 'ensures that do nothing if user has no access for show of build_list' do - allow_any_instance_of(BuildListPolicy).to receive(:show?).and_return(false) - expect do - subject.perform build_list.id, user.id, project_ids, arch_ids, options - end.to change(BuildList, :count).by(0) - end - - it 'ensures that do nothing if user has no access for write of project' do - allow_any_instance_of(ProjectPolicy).to receive(:write?).and_return(false) - expect do - subject.perform build_list.id, user.id, project_ids, arch_ids, options - end.to change(BuildList, :count).by(0) - end - - it 'ensures that do nothing if user has no access for create of build_list' do - allow_any_instance_of(BuildListPolicy).to receive(:create?).and_return(false) - expect do - subject.perform build_list.id, user.id, project_ids, arch_ids, options - end.to change(BuildList, :count).by(0) - end - -end diff --git a/jobs/destroy_project_from_repository_job_spec.rb b/jobs/destroy_project_from_repository_job_spec.rb deleted file mode 100644 index f6e9e5944..000000000 --- a/jobs/destroy_project_from_repository_job_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe DestroyProjectFromRepositoryJob do - let(:project) { FactoryGirl.build(:project, id: 123) } - let(:repository) { FactoryGirl.build(:repository, id: 234) } - - before do - stub_symlink_methods - end - - subject { DestroyProjectFromRepositoryJob } - - it 'ensures that not raises error' do - expect do - subject.perform project, repository - end.to_not raise_exception - end - -end diff --git a/jobs/publish_task_manager_job_spec.rb b/jobs/publish_task_manager_job_spec.rb deleted file mode 100644 index d46a85f72..000000000 --- a/jobs/publish_task_manager_job_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe PublishTaskManagerJob do - - subject { PublishTaskManagerJob } - - it 'ensures that not raises error' do - expect do - subject.perform - end.to_not raise_exception - end -end diff --git a/jobs/run_extra_mass_builds_job_spec.rb b/jobs/run_extra_mass_builds_job_spec.rb deleted file mode 100644 index 38475f591..000000000 --- a/jobs/run_extra_mass_builds_job_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'spec_helper' - -describe RunExtraMassBuildsJob do - let(:mass_build1) { FactoryGirl.build(:mass_build, id: 123) } - let(:mass_build2) { FactoryGirl.build(:mass_build, id: 234, extra_mass_builds: [mass_build1.id]) } - let(:build_list) { FactoryGirl.build(:build_list, id: 345, mass_build: mass_build) } - - let(:job) { RunExtraMassBuildsJob.new } - - before do - stub_symlink_methods - MassBuild.stub_chain(:where, :find_each).and_yield(mass_build2) - MassBuild.stub_chain(:where, :to_a).and_return([mass_build1]) - allow(job).to receive(:not_ready?).with(mass_build1).and_return(false) - allow(mass_build2).to receive(:build_all) - end - - it 'ensures that not raises error' do - expect do - job.perform - end.to_not raise_exception - end - - it 'ensures that calls #build_all' do - expect(mass_build2).to receive(:build_all) - job.perform - end - - it 'ensures that do nothing when no extra_mass_builds' do - mass_build2.extra_mass_builds = [] - expect(mass_build2).to_not receive(:build_all) - job.perform - end - - it 'ensures that do nothing when extra mass build not ready' do - allow(job).to receive(:not_ready?).with(mass_build1).and_return(true) - expect(mass_build2).to_not receive(:build_all) - job.perform - end - - it 'ensures that do nothing when some extra mass builds have no status SUCCESS' do - mass_build0 = FactoryGirl.build(:mass_build, id: 1) - mass_build2.extra_mass_builds = [mass_build0, mass_build1] - MassBuild.stub_chain(:where, :to_a).and_return([mass_build1]) - expect(mass_build2).to_not receive(:build_all) - job.perform - end - -end