Skip to content

Commit

Permalink
Merge pull request #4464 from ChrisBr/2.9-ruby25
Browse files Browse the repository at this point in the history
Ruby 2.5 for 2.9 branch
  • Loading branch information
hennevogel committed Feb 13, 2018
2 parents d3fbcaa + caac1fa commit 4ebc613
Show file tree
Hide file tree
Showing 35 changed files with 74 additions and 67 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
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ RUN chown -R frontend /obs/src/api
USER frontend
WORKDIR /obs/src/api

# foreman, which we only run in docker, needs a different thor version than OBS.
# Installing the gem directly spares us from having to rpm package two different thor versions.
RUN sudo gem.ruby2.5 install thor:0.19 foreman
# Ensure there is a foreman command without ruby suffix
RUN sudo ln -s /usr/bin/foreman.ruby2.5 /usr/bin/foreman

# FIXME: Retrying bundler if it fails is a workaround for https://github.com/moby/moby/issues/783
# which seems to happen on openSUSE (< Tumbleweed 20171001)...
RUN export NOKOGIRI_USE_SYSTEM_LIBRARIES=1; bundle install --jobs=3 --retry=3 || bundle install --jobs=3 --retry=3

# Run our command
CMD ["foreman", "start", "-f", "Procfile"]
CMD ["foreman", "start", "-f", "Procfile"]
4 changes: 2 additions & 2 deletions Dockerfile.frontend-base
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ RUN chown -R frontend /obs/src/api
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
# Ensure there are ruby, gem and irb commands without ruby suffix
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
2 changes: 1 addition & 1 deletion dist/ci/travis_before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ rm -rf log/* tmp/cache tmp/sessions tmp/sockets
popd

# travis rvm can not deal with our extended executable names
sed -i 1,1s,\.ruby2\.4,, src/api/{script,bin}/* docs/api/restility/bin/*
sed -i 1,1s,\.ruby2\.5,, src/api/{script,bin}/* docs/api/restility/bin/*
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
8 changes: 4 additions & 4 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 All @@ -39,7 +39,7 @@ This package serves one purpose only: to list the dependencies in Gemfile.lock
Summary: The Open Build Service -- The Testsuite dependencies
Group: Productivity/Networking/Web/Utilities
# dependencies not needed in production
Requires: %(echo `bash %{S:1} %{S:0} "ruby:2.4.0"`)
Requires: %(echo `bash %{S:1} %{S:0} "ruby:2.5.0"`)

Requires: perl-BSSolv >= 0.18.0
# Required by source server
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
6 changes: 3 additions & 3 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 All @@ -230,7 +230,7 @@ BuildRequires: xorg-x11-server
BuildRequires: xorg-x11-server-extra
# write down dependencies for production
BuildRequires: rubygem(bundler)
Requires: %(echo `bash %{S:1} %{S:0} "ruby:2.4.0" "production"`)
Requires: %(echo `bash %{S:1} %{S:0} "ruby:2.5.0" "production"`)
# for rebuild_time
Requires: perl(GD)

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
8 changes: 4 additions & 4 deletions src/api/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ GEM
rake (>= 10.4, < 13.0)
ansi (1.5.0)
arel (8.0.0)
ast (2.3.0)
ast (2.4.0)
bcrypt (3.1.11)
builder (3.2.3)
bullet (5.7.0)
Expand Down Expand Up @@ -108,7 +108,7 @@ GEM
data_migrate (3.2.2)
rails (>= 4.0)
database_cleaner (1.6.2)
delayed_job (4.1.3)
delayed_job (4.1.4)
activesupport (>= 3.0, < 5.2)
delayed_job_active_record (4.1.2)
activerecord (>= 3.0, < 5.2)
Expand Down Expand Up @@ -219,8 +219,8 @@ GEM
nyan-cat-formatter (0.12.0)
rspec (>= 2.99, >= 2.14.2, < 4)
parallel (1.12.0)
parser (2.4.0.0)
ast (~> 2.2)
parser (2.4.0.2)
ast (~> 2.3)
pastel (0.7.2)
equatable (~> 0.5.0)
tty-color (~> 0.4.0)
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
Loading

0 comments on commit 4ebc613

Please sign in to comment.