From 9922a701c3bede0aafdf5e8d3e262af3d3129e40 Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Fri, 4 Feb 2022 15:44:17 -0500 Subject: [PATCH] Support GitHub Actions --- Gemfile | 2 +- lib/manageiq/environment.rb | 16 ++++++++++++---- spec/spec_helper.rb | 4 +--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 00cb36f750a..e670100d942 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/lib/manageiq/environment.rb b/lib/manageiq/environment.rb index 8286b784030..37013848e6d 100644 --- a/lib/manageiq/environment.rb +++ b/lib/manageiq/environment.rb @@ -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. @@ -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")) @@ -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 @@ -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) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b8c24028c41..81562dd364a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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'