Skip to content

Commit

Permalink
Switch from travis to github actions for unit tests (vagrant-libvirt#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
electrofelix authored Feb 20, 2021
1 parent 978e92e commit 66d394d
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
service_name: travis-ci
service_name: github-actions
90 changes: 90 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ end
group :plugins do
gemspec
end

gem 'coveralls', require: false
26 changes: 23 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions vagrant-libvirt.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 66d394d

Please sign in to comment.