Skip to content

Commit

Permalink
[dist][frontend] Update Ruby to version 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBr committed Feb 8, 2018
1 parent d3fbcaa commit df75070
Show file tree
Hide file tree
Showing 32 changed files with 59 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
language: ruby
cache: bundler
gemfile: src/api/Gemfile
rvm: 2.4.1
rvm: 2.5.0

# Github config
branches:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.frontend-base
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ USER frontend
WORKDIR /obs/src/api

# Set up some convenience ruby binaries...
RUN for i in ruby gem irb; do ln -s /usr/bin/$i.ruby2.4 ~/bin/$i; done
RUN for i in ruby gem irb; do ln -s /usr/bin/$i.ruby2.5 ~/bin/$i; done

# Install our bundle
# FIXME: Retrying bundler if it fails is a workaround for https://github.com/moby/moby/issues/783
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.old-test-suite
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ USER frontend
WORKDIR /obs/src/api

# Set up some convenience ruby binaries...
RUN for i in ruby gem irb; do ln -s /usr/bin/$i.ruby2.4 ~/bin/$i; done
RUN for i in ruby gem irb; do ln -s /usr/bin/$i.ruby2.5 ~/bin/$i; done

# Install our bundle
# FIXME: Retrying bundler if it fails is a workaround for https://github.com/moby/moby/issues/783
Expand Down
6 changes: 3 additions & 3 deletions contrib/docker-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ do
nodejs6 npm6 \
mariadb-client \
git-core \
ruby2.4-devel cyrus-sasl-devel openldap2-devel libxml2-devel zlib-devel libxslt-devel \
ruby2.5-devel cyrus-sasl-devel openldap2-devel libxml2-devel zlib-devel libxslt-devel \
perl-XML-Parser \
ruby2.4-rubygem-mysql2 \
ruby2.4-rubygem-bundler ruby2.4-rubygem-thor-0_19 ruby2.4-rubygem-foreman
ruby2.5-rubygem-mysql2 \
ruby2.5-rubygem-bundler ruby2.5-rubygem-thor-0_19 ruby2.5-rubygem-foreman
;;

backend)
Expand Down
4 changes: 2 additions & 2 deletions dist/find-requires.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ tdir=`mktemp -d`
tar xJf $sourcearchive -C $tdir >&/dev/null

pushd $tdir/open-build-service*/src/api >& /dev/null
ruby.ruby2.4 -rbundler -e 'exit' || echo "___ERROR_BUNDLER_NOT_INSTALLED___"
ruby.ruby2.5 -rbundler -e 'exit' || echo "___ERROR_BUNDLER_NOT_INSTALLED___"

mode="resolve"
if [ "$limit" == "production" ]; then
mode="specs_for([:default, :production, :assets])"
fi

ruby.ruby2.4 -rbundler -e 'Bundler.definition.'"$mode"'.any? { |s| puts "rubygem('$prefix':#{s.name}) = #{s.version}" }' | while read i; do echo -n $i", "; done
ruby.ruby2.5 -rbundler -e 'Bundler.definition.'"$mode"'.any? { |s| puts "rubygem('$prefix':#{s.name}) = #{s.version}" }' | while read i; do echo -n $i", "; done
popd >& /dev/null

#cleanup
Expand Down
6 changes: 3 additions & 3 deletions dist/obs-api-deps.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Url: http://en.opensuse.org/Build_Service
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: open-build-service-%version.tar.xz
Source1: find-requires.sh
BuildRequires: ruby2.4
BuildRequires: ruby2.4-rubygem-bundler
BuildRequires: ruby2.5
BuildRequires: ruby2.5-rubygem-bundler
%if 0%{?suse_version} < 1210
BuildRequires: xz
%endif
Expand Down Expand Up @@ -72,7 +72,7 @@ Requires: perl(GD)
Requires: sphinx >= 2.1.8

%description -n obs-api-testsuite-deps
This is the API server instance, and the web client for the
This is the API server instance, and the web client for the
OBS.

%prep
Expand Down
4 changes: 2 additions & 2 deletions dist/obs-server.spec
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Requires(pre): group(www)
%endif

#For apache
Requires: apache2 apache2-mod_xforward rubygem-passenger-apache2 ruby2.4-rubygem-passenger
Requires: apache2 apache2-mod_xforward rubygem-passenger-apache2 ruby2.5-rubygem-passenger

# memcache is required for session data
Requires: memcached
Expand Down Expand Up @@ -466,7 +466,7 @@ done
if [ ! -e %{secret_key_file} ]; then
pushd .
cd /srv/www/obs/api/config
( umask 0077; RAILS_ENV=production bundle.ruby2.4 exec rails.ruby2.4 secret > %{secret_key_file} ) || exit 1
( umask 0077; RAILS_ENV=production bundle.ruby2.5 exec rails.ruby2.5 secret > %{secret_key_file} ) || exit 1
popd
fi
chmod 0640 %{secret_key_file}
Expand Down
2 changes: 1 addition & 1 deletion dist/obs_api_delayed_jobs_monitor.cron
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*/10 * * * * /usr/bin/bundle.ruby2.4 exec /srv/www/obs/api/script/delayed_job_monitor.rb > /dev/null
*/10 * * * * /usr/bin/bundle.ruby2.5 exec /srv/www/obs/api/script/delayed_job_monitor.rb > /dev/null
12 changes: 6 additions & 6 deletions dist/obsapidelayed
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
. /etc/rc.status

API_ROOT=/srv/www/obs/api
CLOCKWORKD=/usr/bin/clockworkd.ruby2.4
CLOCKWORKD=/usr/bin/clockworkd.ruby2.5

# If you are using newrelic_rpm you need this
# to fix detection of our delay_job.api daemons
Expand All @@ -48,7 +48,7 @@ function run_in_api
{
export RAILS_ENV="production"
# startproc only works for classical daemons
chroot --userspec=wwwrun:www / /bin/bash -c "cd $API_ROOT && /usr/bin/bundle.ruby2.4 exec $*"
chroot --userspec=wwwrun:www / /bin/bash -c "cd $API_ROOT && /usr/bin/bundle.ruby2.5 exec $*"
}

# number of parallel delayed jobs
Expand All @@ -72,9 +72,9 @@ case "$1" in
echo -n "Starting OBS searchd daemon "
FILE_SIZE=`stat -c '%s' /srv/www/obs/api/config/production.sphinx.conf`
if [ $FILE_SIZE -eq 0 ];then
run_in_api rails.ruby2.4 ts:rebuild
run_in_api rails.ruby2.5 ts:rebuild
else
run_in_api rails.ruby2.4 ts:start
run_in_api rails.ruby2.5 ts:start
fi
rc_status -v
echo -n "Starting OBS api clock daemon "
Expand All @@ -95,7 +95,7 @@ case "$1" in
run_in_api $CLOCKWORKD -l -c config/clock.rb stop
rc_status -v
echo -n "Shutting down OBS searchd daemon "
run_in_api rails.ruby2.4 ts:stop
run_in_api rails.ruby2.5 ts:stop
rc_status -v
;;
try-restart|condrestart)
Expand All @@ -114,7 +114,7 @@ case "$1" in
$0 stop
rm -f $API_ROOT/db/sphinx/production/*
$0 start
run_in_api rails.ruby2.4 ts:index
run_in_api rails.ruby2.5 ts:index

rc_status
;;
Expand Down
20 changes: 10 additions & 10 deletions dist/setup-appliance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function check_service {
echo "$srv daemon not started. Trying to start"
execute_silently systemctl start $srv\.service
if [[ $? -gt 0 ]];then
echo -n "Starting $srv daemon failed."
echo -n "Starting $srv daemon failed."
if [[ $service_critical == 1 ]];then
echo " Exiting ..."
exit 1
Expand All @@ -55,15 +55,15 @@ function check_server_cert {
DETECTED_CERT_CHANGE=1
# hostname specific certs - survive intermediate hostname changes
if [ ! -e $backenddir/certs/server.${FQHOSTNAME}.crt ] ; then
# This is just a dummy SSL certificate, but it has a valid hostname.
# This is just a dummy SSL certificate, but it has a valid hostname.
# Admin can replace it with his version.
create_selfsigned_certificate
echo "$OPENSSL_CONFIG" | openssl req -new -nodes -config /dev/stdin \
-x509 -days 365 -batch \
-key $backenddir/certs/server.key \
-out $backenddir/certs/server.${FQHOSTNAME}.crt
if [[ $? == 0 ]];then

if [[ $? == 0 ]];then
echo "Do not remove this file or new SSL CAs will get created." > $backenddir/certs/server.${FQHOSTNAME}.created
fi
else
Expand Down Expand Up @@ -227,9 +227,9 @@ function adapt_worker_jobs {
}
###############################################################################
function prepare_database_setup {
cd /srv/www/obs/api
RAILS_ENV=production rails.ruby2.4 db:migrate:status > /dev/null

cd /srv/www/obs/api
RAILS_ENV=production rails.ruby2.5 db:migrate:status > /dev/null

if [[ $? > 0 ]];then
echo "Initialize MySQL databases (first time only)"
Expand Down Expand Up @@ -270,8 +270,8 @@ function prepare_database_setup {
logline "Setting up rails environment"
for cmd in $RAKE_COMMANDS
do
logline " - Doing 'rails.ruby2.4 $cmd'"
RAILS_ENV=production bundle exec rails.ruby2.4 $cmd >> $apidir/log/db_migrate.log
logline " - Doing 'rails.ruby2.5 $cmd'"
RAILS_ENV=production bundle exec rails.ruby2.5 $cmd >> $apidir/log/db_migrate.log
if [[ $? > 0 ]];then
(>&2 echo "Command $cmd FAILED")
exit 1
Expand Down Expand Up @@ -509,7 +509,7 @@ function prepare_apache2 {
function prepare_passenger {

perl -p -i -e \
's#^(\s*)PassengerRuby "/usr/bin/ruby"#$1\PassengerRuby "/usr/bin/ruby.ruby2.4"#' \
's#^(\s*)PassengerRuby "/usr/bin/ruby"#$1\PassengerRuby "/usr/bin/ruby.ruby2.5"#' \
/etc/apache2/conf.d/mod_passenger.conf


Expand Down
2 changes: 1 addition & 1 deletion docs/api/restility/bin/rest_doc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby.ruby2.4
#!/usr/bin/env ruby.ruby2.5

require 'optparse'
require 'rubygems'
Expand Down
2 changes: 1 addition & 1 deletion docs/api/restility/bin/rest_test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/ruby.ruby2.4
#!/usr/bin/ruby.ruby2.5

require 'optparse'
require 'rubygems'
Expand Down
6 changes: 3 additions & 3 deletions src/api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ build: config
# we need to have *something* as secret key
echo "" | sha256sum| cut -d\ -f 1 > $(DESTDIR)/srv/www/obs/api/config/secret.key
cd $(DESTDIR)/srv/www/obs/api ;\
bundle.ruby2.4 exec rake.ruby2.4 assets:precompile RAILS_ENV=production RAILS_GROUPS=assets || exit 1 ;\
bundle.ruby2.5 exec rake.ruby2.5 assets:precompile RAILS_ENV=production RAILS_GROUPS=assets || exit 1 ;\
rm -rf tmp/cache/sass tmp/cache/assets config/secret.key ;\
bundle.ruby2.4 config --local frozen 1 || exit 1 ;\
bundle.ruby2.4 config --local without development:test:assets || exit 1 ;\
bundle.ruby2.5 config --local frozen 1 || exit 1 ;\
bundle.ruby2.5 config --local without development:test:assets || exit 1 ;\
# reinstall
$(INSTALL) config/database.yml.example $(DESTDIR)$(OBS_API_PREFIX)/config/database.yml
# patch our version inside
Expand Down
2 changes: 1 addition & 1 deletion src/api/Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env rake.ruby2.4
#!/usr/bin/env rake.ruby2.5
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
2 changes: 1 addition & 1 deletion src/api/bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby.ruby2.4
#!/usr/bin/env ruby.ruby2.5
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
2 changes: 1 addition & 1 deletion src/api/bin/pry
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/ruby.ruby2.4
#!/usr/bin/ruby.ruby2.5
# frozen_string_literal: true

#
Expand Down
2 changes: 1 addition & 1 deletion src/api/bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby.ruby2.4
#!/usr/bin/env ruby.ruby2.5
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
2 changes: 1 addition & 1 deletion src/api/bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby.ruby2.4
#!/usr/bin/env ruby.ruby2.5
require_relative '../config/boot'
require 'rake'
Rake.application.run
2 changes: 1 addition & 1 deletion src/api/bin/rdoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/ruby.ruby2.4
#!/usr/bin/ruby.ruby2.5
# frozen_string_literal: true

#
Expand Down
2 changes: 1 addition & 1 deletion src/api/bin/ri
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/ruby.ruby2.4
#!/usr/bin/ruby.ruby2.5
# frozen_string_literal: true

#
Expand Down
2 changes: 1 addition & 1 deletion src/api/bin/rspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/ruby.ruby2.4
#!/usr/bin/ruby.ruby2.5
# frozen_string_literal: true

#
Expand Down
2 changes: 1 addition & 1 deletion src/api/bin/rubocop
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/ruby.ruby2.4
#!/usr/bin/ruby.ruby2.5
# frozen_string_literal: true

#
Expand Down
1 change: 1 addition & 0 deletions src/api/db/migrate/20150623063641_reindex_sphinx_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class ReindexSphinxDb < ActiveRecord::Migration[4.2]
def self.up
rake = 'rake'
rake = 'rake.ruby2.4' if File.exist?('/usr/bin/rake.ruby2.4')
rake = 'rake.ruby2.5' if File.exist?('/usr/bin/rake.ruby2.5')
# we do not use ThinkingSphinx class, since searchd might not be able to startup
system("cd #{Rails.root}; rm -rf tmp/binlog; exec #{rake} ts:index")
end
Expand Down
12 changes: 6 additions & 6 deletions src/api/script/api_test_in_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ EOF

# migration test
export RAILS_ENV=development
bundle.ruby2.4 exec rake.ruby2.4 db:create || exit 1
bundle.ruby2.5 exec rake.ruby2.5 db:create || exit 1
mv db/structure.sql db/structure.sql.git
xzcat test/dump_2.5.sql.xz | mysql -u root --socket=$MYSQL_SOCKET
bundle.ruby2.4 exec rake.ruby2.4 db:migrate:with_data db:structure:dump db:drop || exit 1
bundle.ruby2.5 exec rake.ruby2.5 db:migrate:with_data db:structure:dump db:drop || exit 1
./script/compare_structure_sql.sh db/structure.sql.git db/structure.sql || exit 1

# entire test suite
export RAILS_ENV=test
bundle.ruby2.4 exec rake.ruby2.4 db:create db:setup || exit 1
bundle.ruby2.5 exec rake.ruby2.5 db:create db:setup || exit 1

for suite in "rake.ruby2.4 test:api" "rake.ruby2.4 test:spider" "rspec"; do
for suite in "rake.ruby2.5 test:api" "rake.ruby2.5 test:spider" "rspec"; do
rm -f log/test.log
bundle.ruby2.4 exec rails assets:precompile
bundle.ruby2.5 exec rails assets:precompile

# Configure the frontend<->backend connection settings
if [ "$suite" = "rspec" ]; then
Expand All @@ -86,7 +86,7 @@ for suite in "rake.ruby2.4 test:api" "rake.ruby2.4 test:spider" "rspec"; do
perl -pi -e 's/source_host: backend/source_host: localhost/' config/options.yml
perl -pi -e 's/source_port: 5352/source_port: 3200/' config/options.yml
fi
if ! (set -x; bundle.ruby2.4 exec $suite); then
if ! (set -x; bundle.ruby2.5 exec $suite); then
# dump log only in package builds
[[ -n "$RPM_BUILD_ROOT" ]] && cat log/test.log
kill_memcached
Expand Down
2 changes: 1 addition & 1 deletion src/api/script/check_database
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby.ruby2.4
#!/usr/bin/env ruby.ruby2.5
require File.dirname(__FILE__) + '/../config/boot'
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require File.expand_path(File.join(Rails.root, 'db', 'checker'))
Expand Down
2 changes: 1 addition & 1 deletion src/api/script/delayed_job.api.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby.ruby2.4
#!/usr/bin/env ruby.ruby2.5

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Expand Down
2 changes: 1 addition & 1 deletion src/api/script/delayed_job_monitor.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby.ruby2.4
#!/usr/bin/env ruby.ruby2.5
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))

output = %x(service obsapidelayed status | grep "active")
Expand Down
2 changes: 1 addition & 1 deletion src/api/script/import
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby.ruby2.4
#!/usr/bin/env ruby.ruby2.5
require File.dirname(__FILE__) + '/../config/boot'

# set this to true if you want to create users that appear in metafiles
Expand Down
2 changes: 1 addition & 1 deletion src/api/script/plugin
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby.ruby2.4
#!/usr/bin/env ruby.ruby2.5
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
2 changes: 1 addition & 1 deletion src/api/script/reformat_memprof
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/ruby.ruby2.4
#! /usr/bin/ruby.ruby2.5

require 'rubygems'
require 'json'
Expand Down
2 changes: 1 addition & 1 deletion src/api/script/rubygem_package_names.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby.ruby2.4
#!/usr/bin/env ruby.ruby2.5

require 'bundler'

Expand Down
2 changes: 1 addition & 1 deletion src/api/script/start_test_backend
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby.ruby2.4
#!/usr/bin/env ruby.ruby2.5
ENV['RAILS_ENV'] ||= 'test'
ENV['origin_RAILS_ENV'] ||= ENV['RAILS_ENV']
ENV['LC_ALL'] = 'C'
Expand Down

0 comments on commit df75070

Please sign in to comment.