Skip to content

Commit

Permalink
Merge pull request ManageIQ#21683 from Fryguy/github_actions
Browse files Browse the repository at this point in the history
Switch to GitHub Actions

(cherry picked from commit 0318b45)
  • Loading branch information
chessbyte authored and Fryguy committed Feb 5, 2025
1 parent 2c9c2f3 commit 4059cd8
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 104 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ xfer_*.xml
Thumbs.db
Procfile

# bin/
bin/*

# config/
config/apache
config/cable.yml
Expand Down
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/openscap_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
25 changes: 25 additions & 0 deletions bin/before_install
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
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
8 changes: 0 additions & 8 deletions bin/ci/after_failure.sh

This file was deleted.

6 changes: 0 additions & 6 deletions bin/ci/before_install.rb

This file was deleted.

14 changes: 0 additions & 14 deletions bin/ci/before_install.sh

This file was deleted.

3 changes: 0 additions & 3 deletions bin/ci/before_script.sh

This file was deleted.

8 changes: 5 additions & 3 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
24 changes: 5 additions & 19 deletions lib/manageiq/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/models/miq_database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4059cd8

Please sign in to comment.