diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000000..97bf4e1dce8 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,47 @@ +name: CI + +on: [push, pull_request] + +jobs: + ci: + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: + - '2.6' + - '2.7' + test-suite: + - vmdb + - security + services: + postgres: + image: manageiq/postgresql:10 + env: + POSTGRESQL_USER: root + POSTGRESQL_PASSWORD: smartvm + POSTGRESQL_DATABASE: vmdb_test + options: --health-cmd pg_isready --health-interval 2s --health-timeout 5s --health-retries 5 + ports: + - 5432:5432 + env: + TEST_SUITE: ${{ matrix.test-suite }} + PGHOST: localhost + PGPASSWORD: smartvm + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + steps: + - uses: actions/checkout@v2 + - name: Set up system + run: bin/before_install + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - name: Prepare tests + run: bin/setup + - name: Run tests + run: bundle exec rake + - name: Report code coverage + if: ${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '2.7' && matrix.test-suite == 'vmdb' }} + continue-on-error: true + uses: paambaati/codeclimate-action@v3.0.0 diff --git a/.gitignore b/.gitignore index 0e6e1288b63..9157f0f6492 100644 --- a/.gitignore +++ b/.gitignore @@ -38,9 +38,6 @@ xfer_*.xml Thumbs.db Procfile -# bin/ -bin/* - # config/ config/apache config/cable.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a2b89c0fc6a..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- -language: ruby -dist: bionic -rvm: -- 2.6.6 -cache: bundler -env: - global: - - RUBY_GC_HEAP_GROWTH_MAX_SLOTS=300000 - - RUBY_GC_HEAP_INIT_SLOTS=600000 - - RUBY_GC_HEAP_GROWTH_FACTOR=1.25 - - PARALLEL_TEST_PROCESSORS=2 - matrix: - - TEST_SUITE=vmdb PARALLEL=true - - TEST_SUITE=brakeman -matrix: - fast_finish: true - jobs: - - group: edge - virt: lxd - arch: arm64-graviton2 - rvm: 2.6.6 - env: - - RUBY_GC_HEAP_GROWTH_MAX_SLOTS=300000 - - RUBY_GC_HEAP_INIT_SLOTS=600000 - - RUBY_GC_HEAP_GROWTH_FACTOR=1.25 - - PARALLEL_TEST_PROCESSORS=2 - - TEST_SUITE=vmdb PARALLEL=true -addons: - postgresql: '10' -before_install: source ${TRAVIS_BUILD_DIR}/bin/ci/before_install.sh -before_script: source ${TRAVIS_BUILD_DIR}/bin/ci/before_script.sh -after_failure: source ${TRAVIS_BUILD_DIR}/bin/ci/after_failure.sh -notifications: - webhooks: - urls: - - https://webhooks.gitter.im/e/7af45001fe6b7a4039f2 - on_success: change - on_failure: always - on_start: never diff --git a/README.md b/README.md index 4ff62a08926..22157f6f429 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ManageIQ -[![Build Status](https://travis-ci.com/ManageIQ/manageiq.svg?branch=morphy)](https://travis-ci.com/ManageIQ/manageiq) +[![CI](https://github.com/ManageIQ/manageiq/actions/workflows/ci.yaml/badge.svg?branch=morphy)](https://github.com/ManageIQ/manageiq/actions/workflows/ci.yaml) [![Code Climate](https://codeclimate.com/github/ManageIQ/manageiq/badges/gpa.svg)](https://codeclimate.com/github/ManageIQ/manageiq) [![Codacy](https://api.codacy.com/project/badge/grade/9ffce48ccb924020ae8f9e698048e9a4)](https://www.codacy.com/app/ManageIQ/manageiq) [![Coverage Status](https://coveralls.io/repos/ManageIQ/manageiq/badge.svg?branch=morphy&service=github)](https://coveralls.io/github/ManageIQ/manageiq?branch=morphy) @@ -11,8 +11,7 @@ [![Translate](https://img.shields.io/badge/translate-transifex-blue.svg)](https://www.transifex.com/manageiq/manageiq/dashboard/) [![License](http://img.shields.io/badge/license-APACHE2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) - -[![Build history for master branch](https://buildstats.info/travisci/chart/ManageIQ/manageiq?branch=morphy&includeBuildsFromPullRequest=false&buildCount=50)](https://travis-ci.org/ManageIQ/manageiq/branches) +[![Build history for morphy branch](https://buildstats.info/github/chart/ManageIQ/manageiq?branch=morphy&buildCount=50&includeBuildsFromPullRequest=false&showstats=false)](https://github.com/ManageIQ/manageiq/actions?query=branch%3Amorphy) ## Discover, Optimize, and Control your Hybrid IT diff --git a/app/models/openscap_result.rb b/app/models/openscap_result.rb index 48e76cece68..720ba9f800b 100644 --- a/app/models/openscap_result.rb +++ b/app/models/openscap_result.rb @@ -7,7 +7,7 @@ class OpenscapResult < ApplicationRecord before_save :create_rule_results def self.openscap_available? - # needed only for travis + # needed only for CI require 'openscap' require 'openscap/ds/arf' require 'openscap/xccdf/benchmark' diff --git a/bin/before_install b/bin/before_install new file mode 100755 index 00000000000..449efe14518 --- /dev/null +++ b/bin/before_install @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +APP_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." &>/dev/null && pwd) + +if [ -n "$CI" ]; then + echo "== Installing system packages ==" + sudo apt-get install libcurl4-openssl-dev + echo +fi + +if [ -n "$CI" ]; then + echo "== Setup git config ==" + git config --global user.name "ManageIQ" + git config --global user.email "contact@manageiq.org" + echo + + # Gemfile.lock.release only applies to non-master branches and PRs to non-master branches + if [ "$GITHUB_REPOSITORY_OWNER" = "ManageIQ" -a "$GITHUB_BASE_REF" != "master" -a "$GITHUB_REF_NAME" != "master" ]; then + echo "== Setup Gemfile.lock.release ==" + cp -f "$APP_ROOT/Gemfile.lock.release" "$APP_ROOT/Gemfile.lock" + echo + fi +fi diff --git a/bin/ci/after_failure.sh b/bin/ci/after_failure.sh deleted file mode 100755 index 927ecdb7eb3..00000000000 --- a/bin/ci/after_failure.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -v - -echo "Errors and warnings in log files" -echo log/* -egrep -i "warn|error" log/*.log - -set +v diff --git a/bin/ci/before_install.rb b/bin/ci/before_install.rb deleted file mode 100755 index 3b1e51ed4f4..00000000000 --- a/bin/ci/before_install.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -require_relative '../../lib/manageiq/environment' -ManageIQ::Environment.setup_gemfile_lock -ManageIQ::Environment.ensure_config_files -ManageIQ::Environment.create_database_user -ManageIQ::Environment.install_bundler diff --git a/bin/ci/before_install.sh b/bin/ci/before_install.sh deleted file mode 100755 index b9c243e283c..00000000000 --- a/bin/ci/before_install.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -ev - -if [ -n "$CI" ]; then - git config --global user.name "ManageIQ" - git config --global user.email "contact@manageiq.org" -fi - -./bin/ci/before_install.rb - -export BUNDLE_WITHOUT=development -export BUNDLE_GEMFILE=${PWD}/Gemfile - -set +ev diff --git a/bin/ci/before_script.sh b/bin/ci/before_script.sh deleted file mode 100755 index 979f8c09a5d..00000000000 --- a/bin/ci/before_script.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -bundle exec rake test:setup diff --git a/bin/setup b/bin/setup index 3a66b2fe337..56f38ee0bca 100755 --- a/bin/setup +++ b/bin/setup @@ -21,9 +21,11 @@ ENV["SKIP_TEST_RESET"] = "true" if ENV['RAILS_ENV'] == 'production' Dir.chdir(ManageIQ::Environment::APP_ROOT) do ManageIQ::Environment.ensure_config_files - puts '== Installing dependencies ==' - ManageIQ::Environment.install_bundler - ManageIQ::Environment.bundle_update + unless ENV["CI"] + puts '== Installing dependencies ==' + ManageIQ::Environment.install_bundler + ManageIQ::Environment.bundle_update + end ui_thread = ManageIQ::Environment.update_ui_thread unless ENV["SKIP_UI_UPDATE"] diff --git a/lib/manageiq/environment.rb b/lib/manageiq/environment.rb index 1aaa7e44413..826b231e9c0 100644 --- a/lib/manageiq/environment.rb +++ b/lib/manageiq/environment.rb @@ -22,8 +22,6 @@ def self.manageiq_plugin_update(plugin_root = nil) ensure_config_files setup_test_environment(:task_prefix => 'app:', :root => plugin_root) unless ENV["SKIP_TEST_RESET"] - - prepare_codeclimate_test_reporter(plugin_root) if ENV["CI"] end def self.ensure_config_files @@ -55,20 +53,14 @@ 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"] - - # 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. - # On travis, or other CI's, we may not be able to easily install the various dev dependencies it expects. We'll force - # travis to compile these extensions from source until we can use these native gems. - # See https://nokogiri.org/CHANGELOG.html#1130-2022-01-06 - system!("bundle config set force_ruby_platform true") if ENV["TRAVIS"] + system!("gem install bundler -v '#{bundler_version}' --conservative") unless ENV["GITHUB_ACTIONS"] end def self.setup_gemfile_lock - return if ENV["TRAVIS_BRANCH"] == "master" + # Gemfile.lock.release only applies to non-master branches and PRs to non-master branches + return unless ENV["GITHUB_REPOSITORY_OWNER"] == "ManageIQ" && + ENV["GITHUB_BASE_REF"] != "master" && # PR to non-master branch + ENV["GITHUB_REF_NAME"] != "master" # A non-master branch raise "Missing Gemfile.lock.release" unless APP_ROOT.join("Gemfile.lock.release").file? end @@ -115,12 +107,6 @@ def self.clear_logs_and_temp run_rake_task("log:clear tmp:clear") end - def self.prepare_codeclimate_test_reporter(root = APP_ROOT) - 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) - end - def self.update_ui system!("bundle exec rake update:ui") end diff --git a/spec/models/miq_database_spec.rb b/spec/models/miq_database_spec.rb index faae6481005..42d4d9b68e0 100644 --- a/spec/models/miq_database_spec.rb +++ b/spec/models/miq_database_spec.rb @@ -134,8 +134,8 @@ end end - if ENV.key?("CI") - it "uses a random, non-zero, region number on Travis" do + if ENV["CI"] + it "uses a random, non-zero, region number on CI" do db = MiqDatabase.seed expect(db.region_number).to be > 0 expect(db.region_number).to eq(MiqRegion.my_region_number) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b8c24028c41..6aac07d0bb7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' -if ENV["TRAVIS"] || ENV['CI'] +if ENV['CI'] require 'coveralls' require 'simplecov' SimpleCov.start @@ -65,7 +65,7 @@ EvmSpecHelper.clear_caches { example.run } end - if ENV["TRAVIS"] && ENV["TEST_SUITE"] == "vmdb" + if ENV["CI"] && ENV["TEST_SUITE"] == "vmdb" config.before(:suite) do require Rails.root.join("spec/coverage_helper.rb") end