Skip to content

Commit

Permalink
T-79: Set up Coveralls using GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Feb 11, 2022
1 parent ed62679 commit afbcdbb
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 11 deletions.
1 change: 0 additions & 1 deletion .coveralls.yml

This file was deleted.

27 changes: 25 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
# NOTE: Virtual Environments.
# - https://github.com/actions/virtual-environments
#
# NOTE: How to collect and upload coverage reports for Coveralls?
# - https://github.com/marketplace/actions/coveralls-github-action#complete-parallel-job-example
# - https://github.com/coverallsapp/github-action/issues/29
# - https://github.com/coverallsapp/github-action/issues/29#issuecomment-704366557
#
# IMPORTANT: This workflow is heavily based on Shopify/packwerk workflow.
# - https://github.com/Shopify/packwerk/blob/main/.github/workflows/ci.yml
# - https://github.com/Shopify/packwerk/actions/runs/331834549/workflow
Expand All @@ -32,10 +37,10 @@ name: CI
on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

jobs:
lint:
Expand Down Expand Up @@ -94,3 +99,21 @@ jobs:
bundler-cache: true
- name: Run RSpec
run: bundle exec rspec
- name: Collect coverage reports for Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
flag-name: run-${{ matrix.ruby }}-${{ matrix.gemfile }}
parallel: true
path-to-lcov: "./coverage/lcov.info"

coverage:
needs:
- test
runs-on: ubuntu-20.04
steps:
- name: Upload coverage reports to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
2 changes: 1 addition & 1 deletion basic_temperature.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ Gem::Specification.new do |spec|

spec.add_development_dependency 'bundler-audit'
spec.add_development_dependency 'byebug', '~> 10.0'
spec.add_development_dependency 'coveralls', '~> 0.8'
spec.add_development_dependency 'rake', '~> 12.0'
spec.add_development_dependency 'rerun'
spec.add_development_dependency 'reverse_coverage'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rubocop', '~> 0.80.0'
spec.add_development_dependency 'sdoc'
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'simplecov-lcov'
end
51 changes: 44 additions & 7 deletions spec/coverage_helper.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,53 @@
# DOCS: https://github.com/colszowka/simplecov
# DOCS: https://docs.coveralls.io/ruby-on-rails
##
# Coverage using SimpleCov.
#
# NOTE: What is SimpleCov?
# https://github.com/simplecov-ruby/simplecov
#
# NOTE: What is lcov and how to set up it?
# - https://github.com/fortissimo1997/simplecov-lcov
# - https://github.com/tagliala/coveralls-ruby-reborn#github-actions
#
# NOTE: How to deploy coverage data to Coveralls using GitHub Actions?
# - https://github.com/marketplace/actions/coveralls-github-action
# - https://github.com/coverallsapp/github-action/issues/29
#
# IMPORTANT: Why `basic_temperature/version.rb` is ignored? See:
# https://github.com/simplecov-ruby/simplecov/issues/557
#

##
# Fixes the following error for older Ruby versions.
#
# Formatter SimpleCov::Formatter::LcovFormatter failed with NoMethodError: undefined method `branch_coverage?' for SimpleCov:Module
#
# https://github.com/fortissimo1997/simplecov-lcov/pull/25/files
#
# TODO: Remove when support for Rubies lower than 2.5 will be dropped.
#
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.5')
module SimpleCov
class << self
def branch_coverage?
false
end
end
end
end

require 'simplecov'
require 'coveralls'
require 'simplecov-lcov'

SimpleCov::Formatter::LcovFormatter.config do |config|
config.report_with_single_file = true
config.single_report_path = 'coverage/lcov.info'
end

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
SimpleCov::Formatter::LcovFormatter
])

SimpleCov.start do
add_filter '/spec/'
end

# NOTE: `basic_temperature/version.rb` is ignored intentionally.
# See https://github.com/colszowka/simplecov/issues/557

0 comments on commit afbcdbb

Please sign in to comment.