Skip to content

Commit 99cf157

Browse files
authored
Merge pull request #91 from evolve75/coveralls-github-action
Added a Github workflow for coveralls.io integration.
2 parents 9725b47 + aa5c835 commit 99cf157

File tree

8 files changed

+114
-22
lines changed

8 files changed

+114
-22
lines changed

.coveralls.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
service-name: github
2+
repo_token: 5JHbEro1j0uJyxWvQSF67Ds1U6UPHyOmj

.github/workflows/coveralls.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Check the test coverage of the code.
2+
#
3+
# This runs as a Github Action.
4+
#
5+
# See https://github.com/marketplace/actions/coveralls-github-action
6+
7+
name: Test Coveralls
8+
on: ["push", "pull_request"]
9+
10+
env:
11+
COVERAGE: true
12+
13+
jobs:
14+
test:
15+
name: Ruby ${{ matrix.ruby }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
ruby: ["2.6", "2.7", "3.0"]
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Clone Repository
24+
uses: actions/checkout@v2
25+
26+
- name: Setup Ruby and bundler dependencies
27+
uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: ${{ matrix.ruby }}
30+
bundler-cache: true
31+
32+
- name: Run Ruby Tests
33+
run: bundle exec rake clobber test:coverage
34+
35+
- name: Coveralls
36+
uses: coverallsapp/github-action@master
37+
with:
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
flag-name: ruby-${{ matrix.ruby }}
40+
parallel: true
41+
42+
finish:
43+
needs: test
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- name: Coveralls Finished
48+
uses: coverallsapp/github-action@master
49+
with:
50+
github-token: ${{ secrets.GITHUB_TOKEN }}
51+
parallel-finished: true

Gemfile.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ GEM
99
specs:
1010
ast (2.4.2)
1111
diff-lcs (1.5.0)
12+
docile (1.4.0)
1213
json (2.6.2)
1314
parallel (1.22.1)
1415
parser (3.1.2.0)
@@ -54,6 +55,13 @@ GEM
5455
rubocop-rspec (2.11.1)
5556
rubocop (~> 1.19)
5657
ruby-progressbar (1.11.0)
58+
simplecov (0.21.2)
59+
docile (~> 1.1)
60+
simplecov-html (~> 0.11)
61+
simplecov_json_formatter (~> 0.1)
62+
simplecov-html (0.12.3)
63+
simplecov-lcov (0.8.0)
64+
simplecov_json_formatter (0.1.4)
5765
stringio (3.0.2)
5866
test-unit (3.5.3)
5967
power_assert
@@ -75,6 +83,8 @@ DEPENDENCIES
7583
rubocop-rake (~> 0.0)
7684
rubocop-rspec (~> 2.0)
7785
rubytree!
86+
simplecov (~> 0.21)
87+
simplecov-lcov (~> 0.8)
7888
test-unit (~> 3.0)
7989
yard (~> 0.0, >= 0.9.20)
8090

Rakefile

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,6 @@ namespace :test do
139139
task :coverage do
140140
ruby 'test/run_test.rb'
141141
end
142-
143-
begin
144-
require 'rcov/rcovtask'
145-
Rcov::RcovTask.new(:rcov) do |t|
146-
t.libs << 'test'
147-
t.test_files = FileList['test/**/test_*.rb']
148-
t.verbose = true
149-
t.rcov_opts << '--exclude /gems/,/Library/,/usr/,spec,lib/tasks'
150-
end
151-
rescue LoadError
152-
# Oh well. Can't have everything.
153-
end
154142
end
155143

156144
# ................................ Emacs Tags

rubytree.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ Gem::Specification.new do |s|
5858

5959
s.require_paths = ['lib']
6060

61-
s.test_files = Dir.glob('test/**/test_*.rb')
62-
6361
s.extra_rdoc_files = %w[README.md LICENSE.md API-CHANGES.md History.md]
6462
s.rdoc_options = ['--title', "Rubytree Documentation: #{s.name}-#{s.version}",
6563
'--main', 'README.md',
@@ -76,6 +74,8 @@ Gem::Specification.new do |s|
7674
s.add_development_dependency 'rubocop', '~> 1.0'
7775
s.add_development_dependency 'rubocop-rake', '~> 0.0'
7876
s.add_development_dependency 'rubocop-rspec', '~> 2.0'
77+
s.add_development_dependency 'simplecov', '~> 0.21'
78+
s.add_development_dependency 'simplecov-lcov', '~> 0.8'
7979
s.add_development_dependency 'test-unit', '~> 3.0'
8080
s.add_development_dependency 'yard', '~> 0.0', '>= 0.9.20'
8181

spec/spec_helper.rb

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,40 @@
33
# spec_helper.rb
44
#
55
# Author: Anupam Sengupta
6-
# Time-stamp: <2022-06-19 22:38:14 anupam>
6+
# Time-stamp: <2022-06-22 13:54:00 anupam>
77
#
88
# Copyright (C) 2015, 2022 Anupam Sengupta <[email protected]>
99
#
1010
# frozen_string_literal: true
1111

1212
require 'tree'
13+
14+
if ENV['COVERAGE']
15+
begin
16+
require 'simplecov'
17+
require 'simplecov-lcov'
18+
19+
base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
20+
21+
SimpleCov::Formatter::LcovFormatter.config do |cfg|
22+
cfg.report_with_single_file = true
23+
cfg.lcov_file_name = 'lcov.info'
24+
cfg.single_report_path = "#{base_dir}/coverage/lcov.info"
25+
end
26+
27+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
28+
[
29+
SimpleCov::Formatter::HTMLFormatter,
30+
SimpleCov::Formatter::LcovFormatter
31+
]
32+
)
33+
34+
SimpleCov.start do
35+
add_filter '/test'
36+
add_filter '/spec'
37+
enable_coverage :branch
38+
end
39+
rescue LoadError => e
40+
puts "Could not load simplecov; continuing without code coverage #{e.cause}"
41+
end
42+
end

spec/tree_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# tree_spec.rb
44
#
55
# Author: Anupam Sengupta
6-
# Time-stamp: <2022-06-20 22:16:11 anupam>
6+
# Time-stamp: <2022-06-22 13:52:50 anupam>
77
# Copyright (C) 2015-2022 Anupam Sengupta <[email protected]>
88
#
99
# frozen_string_literal: true

test/run_test.rb

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# run_test.rb:: Run all the tests from the Ruby command line.
44
#
55
# Author: Anupam Sengupta
6-
# Time-stamp: <2022-06-19 22:44:56 anupam>
6+
# Time-stamp: <2022-06-22 13:54:25 anupam>
77
# Copyright (C) 2014, 2022 Anupam Sengupta <[email protected]>
88
#
99
# Redistribution and use in source and binary forms, with or without modification,
@@ -42,14 +42,25 @@
4242
if ENV['COVERAGE']
4343
begin
4444
require 'simplecov'
45-
require 'coveralls'
45+
require 'simplecov-lcov'
4646

47-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
47+
SimpleCov::Formatter::LcovFormatter.config do |cfg|
48+
cfg.report_with_single_file = true
49+
cfg.lcov_file_name = 'lcov.info'
50+
cfg.single_report_path = "#{base_dir}/coverage/lcov.info"
51+
end
52+
53+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
54+
[
55+
SimpleCov::Formatter::HTMLFormatter,
56+
SimpleCov::Formatter::LcovFormatter
57+
]
58+
)
4859

4960
SimpleCov.start do
50-
add_filter '/test/'
51-
add_group 'Core Classes', '/lib/.*tree.rb'
52-
add_group 'Internal Utilities', '/lib/tree/utils/.*.rb'
61+
add_filter '/test'
62+
add_filter '/spec'
63+
enable_coverage :branch
5364
end
5465
rescue LoadError => e
5566
puts "Could not load simplecov; continuing without code coverage #{e.cause}"

0 commit comments

Comments
 (0)