From 63fcc9c1bcfe5a5033344358fff13ab803f724a7 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 28 Oct 2017 19:14:35 +0200 Subject: [PATCH 1/4] Fix compatibility with Bundler 1.6 Stop using `Bundler.settings.with`, because it will be removed from Bundler 1.6. Also, as described in #7653, we could use `Bundler.settings[:with]`, but that would be internal API again, so it probably breaks again in the future. That's why I added a `BundlerHelper` module to parse the required optional group from our config files, without the use of any internal Bundler API. Fixes #7653 --- config/application.rb | 4 +++- config/bundler_helper.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 config/bundler_helper.rb diff --git a/config/application.rb b/config/application.rb index f40f6b369..50524a735 100644 --- a/config/application.rb +++ b/config/application.rb @@ -4,9 +4,11 @@ require_relative 'boot' require 'rails/all' +require_relative "bundler_helper" + # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. -Bundler.require(*Rails.groups(*Bundler.settings.with)) +Bundler.require(*Rails.groups(BundlerHelper.database)) # Do not dump the limit of boolean fields on MySQL, # since that generates a db/schema.rb that's incompatible diff --git a/config/bundler_helper.rb b/config/bundler_helper.rb new file mode 100644 index 000000000..6ca9d6ba1 --- /dev/null +++ b/config/bundler_helper.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require "yaml" + +module BundlerHelper + def self.rails_env + @rails_env ||= ENV["RAILS_ENV"] || + parse_value_from_file("diaspora.yml", "configuration", "server", "rails_environment") || + parse_value_from_file("defaults.yml", "defaults", "server", "rails_environment") + end + + def self.database + @adapter ||= parse_value_from_file("database.yml", rails_env, "adapter") + + raise "No database adapter found, please fix your config/database.yml!" unless @adapter + + @adapter.sub("mysql2", "mysql") + end + + private_class_method def self.parse_value_from_file(file, *keys) + path = File.join(__dir__, file) + return YAML.load_file(path).dig(*keys) if File.file?(path) + + puts "Configuration file #{path} not found, ensure it's present" # rubocop:disable Rails/Output + end +end From a14115119c643c00f19366be94251ded1be6ec32 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 29 Oct 2017 17:23:57 +0100 Subject: [PATCH 2/4] Add script/configure_bundler to set correct bundler options --- script/configure_bundler | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 script/configure_bundler diff --git a/script/configure_bundler b/script/configure_bundler new file mode 100755 index 000000000..6c28ae7a0 --- /dev/null +++ b/script/configure_bundler @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require_relative "../config/bundler_helper" + +rails_env = BundlerHelper.rails_env +database = BundlerHelper.database + +puts "Configuring Bundler for #{rails_env} environment and #{database} database." + +def config(option) + puts "$ bin/bundle config --local #{option}" + system("#{File.join(__dir__, '../bin/bundle')} config --local #{option}") +end + +config("jobs #{`nproc`}") +config("with #{database}") + +if rails_env == "production" + config("without test:development") +elsif rails_env == "test" + config("without development") +end + +if rails_env != "development" + config("path vendor/bundle") + config("frozen 1") + config("disable_shared_gems true") +end + +if `gcc -dumpversion`.split(".").first.to_i >= 5 + config("build.sigar \"--with-cppflags='-fgnu89-inline'\"") +end + +puts "Bundler configured! Please run 'bin/bundle install' now." From 4e267bb1efdd0a295c3b6909f74cf9c60b6856a4 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 29 Oct 2017 17:33:26 +0100 Subject: [PATCH 3/4] Use configure_bundler script on travis --- .travis.yml | 4 +--- script/ci/build.sh | 8 -------- script/ci/prepare.sh | 11 +++++++++++ 3 files changed, 12 insertions(+), 11 deletions(-) create mode 100755 script/ci/prepare.sh diff --git a/.travis.yml b/.travis.yml index 966101451..7fc3b0aeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,14 +24,12 @@ branches: - 'develop' before_install: - - gem install bundler + - script/ci/prepare.sh - mkdir travis-phantomjs - wget http://cifiles.diasporafoundation.org/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 - tar -xvf $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis-phantomjs - export PATH=$PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH -bundler_args: "--deployment --without development --with mysql postgresql --jobs 3 --retry 3" - script: "./script/ci/build.sh" notifications: diff --git a/script/ci/build.sh b/script/ci/build.sh index 7a129f211..376917c83 100755 --- a/script/ci/build.sh +++ b/script/ci/build.sh @@ -1,13 +1,5 @@ #!/bin/sh - -# Create a database.yml for the right database -echo "Setting up database.yml for $DB" -cp config/database.yml.example config/database.yml -if [ "$DB" = "mysql" ]; then - sed -i 's/*common/*mysql/' config/database.yml -fi - command="bundle exec rake --trace ci:travis:${BUILD_TYPE}" exec xvfb-run --auto-servernum --server-num=1 --server-args="-screen 0 1280x1024x8" $command diff --git a/script/ci/prepare.sh b/script/ci/prepare.sh new file mode 100755 index 000000000..6bd574ba4 --- /dev/null +++ b/script/ci/prepare.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# Create a database.yml for the right database +echo "Setting up database.yml for ${DB}" +cp config/database.yml.example config/database.yml +if [ "${DB}" = "mysql" ]; then + sed -i 's/*common/*mysql/' config/database.yml +fi + +gem install bundler +script/configure_bundler From 7c4648030f4256c8e405db470c0f3d77cd225add Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 29 Oct 2017 17:38:58 +0100 Subject: [PATCH 4/4] Run rake directly without xvfb on travis closes #7654 --- .travis.yml | 2 +- Changelog.md | 4 ++++ script/ci/build.sh | 5 ----- 3 files changed, 5 insertions(+), 6 deletions(-) delete mode 100755 script/ci/build.sh diff --git a/.travis.yml b/.travis.yml index 7fc3b0aeb..6df40becc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ before_install: - tar -xvf $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis-phantomjs - export PATH=$PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH -script: "./script/ci/build.sh" +script: "bin/rake --trace ci:travis:${BUILD_TYPE}" notifications: irc: diff --git a/Changelog.md b/Changelog.md index 9ebd9e557..02de9c2c4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +# 0.7.1.1 + +Fixes an issue with installing and running diaspora\* with today released bundler v1.16.0. + # 0.7.1.0 ## Ensure account deletions are run diff --git a/script/ci/build.sh b/script/ci/build.sh deleted file mode 100755 index 376917c83..000000000 --- a/script/ci/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -command="bundle exec rake --trace ci:travis:${BUILD_TYPE}" - -exec xvfb-run --auto-servernum --server-num=1 --server-args="-screen 0 1280x1024x8" $command