Skip to content

Commit

Permalink
Merge pull request ManageIQ#178 from Fryguy/github_actions
Browse files Browse the repository at this point in the history
Switch to GitHub Actions
  • Loading branch information
kbrock committed Mar 21, 2023
2 parents f43972a + 48d0f9f commit df5cffb
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 30 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
push:
pull_request:
schedule:
- cron: '0 0 * * 0'

jobs:
ci:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version:
- '2.6'
- '2.7'
- '3.0'
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:
PGHOST: localhost
PGPASSWORD: smartvm
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Run tests
run: bundle exec rake
- name: Report code coverage
if: ${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.0' }}
continue-on-error: true
uses: paambaati/codeclimate-action@v3.0.0
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
--require spec_helper
--color
--order random
--format documentation
1 change: 0 additions & 1 deletion .rspec_ci
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
--color
--order random
--profile
--format documentation
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ManageIQ::ApplianceConsole

[![Gem Version](https://badge.fury.io/rb/manageiq-appliance_console.svg)](http://badge.fury.io/rb/manageiq-appliance_console)
[![Build Status](https://travis-ci.com/ManageIQ/manageiq-appliance_console.svg?branch=master)](https://travis-ci.com/github/ManageIQ/manageiq-appliance_console)
[![CI](https://github.com/ManageIQ/manageiq-appliance_console/actions/workflows/ci.yaml/badge.svg)](https://github.com/ManageIQ/manageiq-appliance_console/actions/workflows/ci.yaml)
[![Code Climate](https://codeclimate.com/github/ManageIQ/manageiq-appliance_console.svg)](https://codeclimate.com/github/ManageIQ/manageiq-appliance_console)
[![Test Coverage](https://codeclimate.com/github/ManageIQ/manageiq-appliance_console/badges/coverage.svg)](https://codeclimate.com/github/ManageIQ/manageiq-appliance_console/coverage)

Expand Down
5 changes: 4 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ RSpec::Core::RakeTask.new(:spec)
# setting to allow the postgres specs to run.
desc "Run RSpec code examples (assumes ci dependencies)"
RSpec::Core::RakeTask.new("spec:ci") do |t|
t.rspec_opts = "--options #{File.expand_path(".rspec_ci", __dir__)}"
# Temporarily disable the PG runner on CI
# was: t.rspec_opts = "--options #{File.expand_path(".rspec_ci", __dir__)}"
warn "\e[33;1mWARN: PostgresRunner specs are temporarily disabled on CI\e[0m" if ENV["CI"]
t.rspec_opts = "--options #{File.expand_path(".rspec", __dir__)}"
end

desc "Run RSpec code examples (with local postgres dependencies)"
Expand Down
5 changes: 2 additions & 3 deletions manageiq-appliance_console.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "rbnacl", ">= 3.2", "< 5.0"

spec.add_development_dependency "bundler"
spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
spec.add_development_dependency "manageiq-style"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop"
spec.add_development_dependency "simplecov"
spec.add_development_dependency "simplecov", ">= 0.21.2"
end
2 changes: 1 addition & 1 deletion spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@
let(:replication_standby) { ManageIQ::ApplianceConsole::DatabaseReplicationStandby.new }

before do
pending "does not work on macOS because `ip` command is not available" if RUBY_PLATFORM.match?(/darwin/)
pending "does not work because `ip` command is not available" unless LinuxAdmin::Common.cmd?("ip")

allow(ManageIQ::ApplianceConsole::DatabaseReplicationPrimary).to receive(:new).and_return(replication_primary)
allow(ManageIQ::ApplianceConsole::DatabaseReplicationStandby).to receive(:new).and_return(replication_standby)
Expand Down
2 changes: 2 additions & 0 deletions spec/database_admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ def confirm_and_execute

context "when excluding tables" do
it "asks to input tables, providing an example and sensible defaults" do
pending "something is wrong with this test and the readline mocking on CI" if ENV["CI"]

say ["y", "metrics_*"]
expect(subject.ask_for_tables_to_exclude_in_dump).to be_truthy
expect_output <<-EXAMPLE.strip_heredoc
Expand Down
12 changes: 12 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
SimpleCov.start
end

# In GitHub Actions (CI), we do not have a tty, so the various tests that use
# STDIN in order to test interactivity will fail. This code creates a psuedo-tty
# in that environment. If you want to test locally in a "non-tty" way, you can
# run the tests as follows: `true | bundle exec rake 2>&1 | cat`
unless STDIN.tty?
require "pty"
require "io/console"
_master_io, slave_file = PTY.open
slave_file.raw!
STDIN.reopen(slave_file)
end

require "manageiq-appliance_console"
ManageIQ::ApplianceConsole.logger = Logger.new("/dev/null")

Expand Down

0 comments on commit df5cffb

Please sign in to comment.