Skip to content

Commit

Permalink
Merge pull request #21682 from Fryguy/support_github_actions
Browse files Browse the repository at this point in the history
Support GitHub Actions
  • Loading branch information
chessbyte authored Feb 5, 2022
2 parents a739a56 + 9922a70 commit 03cb63e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ unless ENV["APPLIANCE"]
gem "brakeman", "~>5.0", :require => false
gem "bundler-audit", :require => false
gem "capybara", "~>2.5.0", :require => false
gem "coveralls", "~>0.8.23", :require => false
gem "db-query-matchers", "~>0.10.0"
gem "factory_bot", "~>5.1", :require => false
gem "simplecov", ">=0.21.2", :require => false
gem "timecop", "~>0.9", :require => false
gem "vcr", "~>5.0", :require => false
gem "webmock", "~>3.7", :require => false
Expand Down
16 changes: 12 additions & 4 deletions lib/manageiq/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def self.update_ui_thread
end

def self.install_bundler(root = APP_ROOT)
system!("echo 'gem: --no-ri --no-rdoc --no-document' > ~/.gemrc") if ENV['CI']
system!("gem install bundler -v '#{bundler_version}' --conservative")
system!("bundle config path #{root.join('vendor/bundle').expand_path}", :chdir => root) if ENV["CI"]
system!("echo 'gem: --no-ri --no-rdoc --no-document' > ~/.gemrc") if ENV['TRAVIS']
system!("gem install bundler -v '#{bundler_version}' --conservative") unless ENV["GITHUB_ACTIONS"]
system!("bundle config path #{root.join('vendor/bundle').expand_path}", :chdir => root) if ENV["TRAVIS"]

# For nokogiri 1.13.0+, native gem support was added, allowing pre-compiled binaries to be used.
# This provides faster and more reliable installation but assumes you have total control of the installation environment.
Expand All @@ -71,7 +71,10 @@ def self.install_bundler(root = APP_ROOT)
end

def self.setup_gemfile_lock
return if ENV["TRAVIS_BRANCH"] == "master"
# Gemfile.lock.release does not apply to the master branch nor to a PR to the master branch
return if ENV["TRAVIS_BRANCH"] == "master" || # Travis master branch OR PR to master branch
ENV["GITHUB_BASE_REF"] == "master" || # GHA PR to master branch
ENV["GITHUB_REF_NAME"] == "master" # GHA master branch

raise "Missing Gemfile.lock.release" unless APP_ROOT.join("Gemfile.lock.release").file?
FileUtils.cp(APP_ROOT.join("Gemfile.lock.release"), APP_ROOT.join("Gemfile.lock"))
Expand All @@ -80,6 +83,7 @@ def self.setup_gemfile_lock
def self.bundle_update(root = APP_ROOT)
system!("bundle update --jobs=3", :chdir => root)
return unless ENV["CI"]

lockfile_contents = File.read(root.join("Gemfile.lock"))
puts "===== Begin Gemfile.lock =====\n\n#{lockfile_contents}\n\n===== End Gemfile.lock ====="
end
Expand Down Expand Up @@ -120,10 +124,14 @@ def self.clear_logs_and_temp
end

def self.create_database_user
return if ENV["GITHUB_ACTIONS"]

system!(%q(psql -c "CREATE USER root SUPERUSER PASSWORD 'smartvm';" -U postgres))
end

def self.prepare_codeclimate_test_reporter(root = APP_ROOT)
return if ENV["GITHUB_ACTIONS"]

system!("curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter", :chdir => root)
system!("chmod +x ./cc-test-reporter", :chdir => root)
system!("./cc-test-reporter before-build", :chdir => root)
Expand Down
4 changes: 1 addition & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
if ENV["TRAVIS"] || ENV['CI']
require 'coveralls'
if ENV['CI']
require 'simplecov'
SimpleCov.start
Coveralls.wear!('rails') { add_filter("/spec/") }
end

ENV["RAILS_ENV"] ||= 'test'
Expand Down

0 comments on commit 03cb63e

Please sign in to comment.