Skip to content

Commit

Permalink
Switch to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Fryguy committed Feb 7, 2022
1 parent 03cb63e commit 615d9ff
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 115 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on: [push, pull_request]

jobs:
ci:
runs-on: ubuntu-latest
strategy:
fail-fast: false
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
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
41 changes: 0 additions & 41 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 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=master)](https://travis-ci.com/github/ManageIQ/manageiq)
[![CI](https://github.com/ManageIQ/manageiq/actions/workflows/ci.yaml/badge.svg)](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=master&service=github)](https://coveralls.io/github/ManageIQ/manageiq?branch=master)
Expand All @@ -11,7 +11,7 @@
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4282/badge)](https://bestpractices.coreinfrastructure.org/projects/4282)
[![Open Source Helpers](https://www.codetriage.com/manageiq/manageiq/badges/users.svg)](https://www.codetriage.com/manageiq/manageiq)

[![Build history for master branch](https://buildstats.info/travisci/chart/ManageIQ/manageiq?branch=master&includeBuildsFromPullRequest=false&buildCount=50)](https://travis-ci.com/github/ManageIQ/manageiq/branches)
[![Build history for master branch](https://buildstats.info/github/chart/ManageIQ/manageiq?branch=master&buildCount=50&includeBuildsFromPullRequest=false&showstats=false)](https://github.com/ManageIQ/manageiq/actions?query=branch%3Amaster)

## 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
23 changes: 23 additions & 0 deletions bin/before_install
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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"

# 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" ]
echo "== Setup Gemfile.lock.release =="
cp -f "$APP_ROOT/Gemfile.lock.release" "$APP_ROOT/Gemfile.lock"
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
35 changes: 4 additions & 31 deletions lib/manageiq/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ def self.manageiq_plugin_update(plugin_root = nil)

ensure_config_files

create_database_user if ENV["CI"]

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 @@ -58,23 +54,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['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.
# 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"]
end

def self.setup_gemfile_lock
# 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
# 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?
FileUtils.cp(APP_ROOT.join("Gemfile.lock.release"), APP_ROOT.join("Gemfile.lock"))
Expand Down Expand Up @@ -123,20 +110,6 @@ def self.clear_logs_and_temp
run_rake_task("log:clear tmp:clear")
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)
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 @@ -49,8 +49,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
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,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 615d9ff

Please sign in to comment.