Switch from travis to github actions for unit tests (#1206)

Migrate to github actions as travis has switched to a process that will
require requesting minutes regularly for open source projects, and
current development is slow enough that this additional overhead is too
much.

Correct the generation of the line coverage following the example at
coverallsapp/github-action#29. Remove dependency on coveralls
gem as no longer needed if using the action.

Patch older versions of simplecov to contain a branch_coverage?
method to ensure working with simplecov-lcov.
This commit is contained in:
Darragh Bailey 2021-02-20 15:23:16 +00:00 committed by GitHub
parent 978e92eac5
commit 66d394d42e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 115 additions and 40 deletions

View File

@ -1 +1 @@
service_name: travis-ci
service_name: github-actions

90
.github/workflows/unit-tests.yml vendored Normal file
View File

@ -0,0 +1,90 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
name: CI
on:
push:
branches: [ $default-branch ]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allow_fail }}
strategy:
fail-fast: false
matrix:
# need to define one entry with a single entry for each of the options
# to allow include to expand the matrix correctly.
ruby: [2.6.6]
vagrant: [main]
allow_fail: [true]
include:
- ruby: 2.2.10
vagrant: v2.0.4
allow_fail: false
- ruby: 2.3.5
vagrant: v2.1.5
allow_fail: false
- ruby: 2.4.10
vagrant: v2.2.4
allow_fail: false
- ruby: 2.6.6
vagrant: v2.2.14
allow_fail: false
steps:
- uses: actions/checkout@v2
- name: Set up libvirt
run: |
sudo apt-get update
sudo apt-get install libvirt-dev
- uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Set up rubygems
run: |
gem update --system --conservative || (gem i "rubygems-update:~>2.7" --no-document && update_rubygems)
gem update bundler --conservative
- name: Run bundler using cached path
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
env:
VAGRANT_VERSION: ${{ matrix.vagrant }}
- name: Run tests
run: |
bundle exec rspec --color --format documentation
cat ./coverage/lcov.info
env:
VAGRANT_VERSION: ${{ matrix.vagrant }}
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
flag-name: run-${{ matrix.vagrant }}
parallel: true
finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true

View File

@ -1,34 +0,0 @@
---
language: ruby
dist: xenial
before_install:
- gem update --system --conservative || (gem i "rubygems-update:~>2.7" --no-document && update_rubygems)
- gem update bundler --conservative
addons:
apt:
packages: libvirt-dev
update: true
language: ruby
cache: bundler
install: bundle install
script: bundle exec rspec --color --format documentation
notifications:
email: false
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
jobs:
include:
- rvm: 2.2.10
env: VAGRANT_VERSION=v2.0.4
- rvm: 2.3.5
env: VAGRANT_VERSION=v2.1.5
- rvm: 2.4.10
env: VAGRANT_VERSION=v2.2.4
- rvm: 2.6.6
env: VAGRANT_VERSION=v2.2.14
- rvm: 2.6.6
env: VAGRANT_VERSION=master
allow_failures:
- env: VAGRANT_VERSION=master

View File

@ -36,5 +36,3 @@ end
group :plugins do
gemspec
end
gem 'coveralls', require: false

View File

@ -1,9 +1,29 @@
require 'simplecov'
require 'coveralls'
require 'simplecov-lcov'
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
# patch simplecov configuration
if ! SimpleCov::Configuration.method_defined? :branch_coverage?
module SimpleCov
module Configuration
def branch_coverage?
return false
end
end
end
end
SimpleCov::Formatter::LcovFormatter.config do |config|
config.report_with_single_file = true
config.single_report_path = 'coverage/lcov.info'
end
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::LcovFormatter,
]
)
SimpleCov.start do
enable_coverage :branch if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5')
add_filter 'spec/'
end

View File

@ -20,6 +20,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "rspec-expectations", "~> 3.5.0"
s.add_development_dependency "rspec-mocks", "~> 3.5.0"
s.add_development_dependency "simplecov"
s.add_development_dependency "simplecov-lcov"
s.add_runtime_dependency 'fog-libvirt', '>= 0.6.0'
s.add_runtime_dependency 'fog-core', '~> 2.1'