diff --git a/.travis.yml b/.travis.yml index 966101451..6df40becc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,15 +24,13 @@ 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" +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/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 diff --git a/config/defaults.yml b/config/defaults.yml index 48525f7bb..dd5abbfcc 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -4,7 +4,7 @@ defaults: version: - number: "0.7.1.0" # Do not touch unless doing a release, do not backport the version number that's in master + number: "0.7.1.1" # Do not touch unless doing a release, do not backport the version number that's in master heroku: false environment: url: "http://localhost:3000/" diff --git a/script/ci/build.sh b/script/ci/build.sh deleted file mode 100755 index 7a129f211..000000000 --- a/script/ci/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/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 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."