Skip to content

Commit f06b4fc

Browse files
authored
Code climate (#84)
* Replace coveralls with codeclimate * Update badges
1 parent 1b66607 commit f06b4fc

File tree

10 files changed

+117
-68
lines changed

10 files changed

+117
-68
lines changed

.codeclimate.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
plugins:
2+
bundler-audit:
3+
enabled: true
4+
rubocop:
5+
enabled: true
6+
channel: rubocop-0-80

.github/CONTRIBUTING.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
We love pull requests from everyone.
44

5+
## Setup
6+
57
**Fork, then clone the repo:**
68

79
```bash
@@ -15,12 +17,16 @@ bundle install
1517
bundle exec lefthook install -f
1618
```
1719

18-
**Make your change. Add tests for your change. Make sure all the tests pass:**
20+
## Testing
21+
22+
**Make your change. Add tests for your change. Make sure all the tests pass and coverage is good:**
1923

2024
```bash
21-
bundle exec rake
25+
COV_HTML_REPORT=true bundle exec rake test_with_coverage
2226
```
2327

28+
## Building
29+
2430
**To test changes locally, bump version and build gems**
2531

2632
```bash

.github/workflows/test.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,10 @@ jobs:
4242
env:
4343
BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES: 'true'
4444

45-
- name: Lint
46-
run: bundle exec rake rubocop
47-
4845
- name: Test
4946
run: bundle exec rake test_with_coverage
5047
env:
51-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
5248
CI: "true"
53-
CI_NAME: github-ci
54-
CI_PULL_REQUEST: ${{ github.event.number }}
49+
CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TOKEN }}
5550
CONTEXT: ${{ toJson(github) }}
51+
RUBY_VERSION: ${{ matrix.ruby }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ reports
1616
.allure
1717
doc
1818
coverage
19+
vendor/bundle

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Layout/MultilineHashBraceLayout:
257257

258258
Layout/MultilineMethodCallBraceLayout:
259259
Enabled: true
260-
EnforcedStyle: new_line
260+
EnforcedStyle: symmetrical
261261

262262
Layout/MultilineMethodCallIndentation:
263263
Enabled: true

.simplecov

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ return unless ENV["COVERAGE"] && !ENV["COV_MERGE"]
55
SimpleCov.start do
66
add_filter ["/spec/", "/fixture/", "/features/"]
77
minimum_coverage 95
8+
formatter SimpleCov::Formatter::SimpleFormatter
89
end

Gemfile.lock

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,14 @@ PATH
2121
GEM
2222
remote: https://rubygems.org/
2323
specs:
24+
ansi (1.5.0)
2425
ast (2.4.0)
2526
backport (1.1.2)
2627
backports (3.15.0)
2728
benchmark (0.1.0)
2829
builder (3.2.4)
2930
coderay (1.1.2)
3031
colorize (0.8.1)
31-
coveralls (0.8.23)
32-
json (>= 1.8, < 3)
33-
simplecov (~> 0.16.1)
34-
term-ansicolor (~> 1.3)
35-
thor (>= 0.19.4, < 2.0)
36-
tins (~> 1.6)
3732
cucumber (3.1.2)
3833
builder (>= 2.1.2)
3934
cucumber-core (~> 3.2.0)
@@ -107,10 +102,14 @@ GEM
107102
ruby-progressbar (1.10.1)
108103
ruby2_keywords (0.0.2)
109104
semantic (1.6.1)
110-
simplecov (0.16.1)
105+
simplecov (0.17.1)
111106
docile (~> 1.1)
112107
json (>= 1.8, < 3)
113108
simplecov-html (~> 0.10.0)
109+
simplecov-console (0.6.0)
110+
ansi
111+
simplecov
112+
terminal-table
114113
simplecov-html (0.10.2)
115114
solargraph (0.38.5)
116115
backport (~> 1.1)
@@ -127,11 +126,10 @@ GEM
127126
tilt (~> 2.0)
128127
yard (~> 0.9)
129128
systemu (2.6.5)
130-
term-ansicolor (1.7.1)
131-
tins (~> 1.0)
129+
terminal-table (1.8.0)
130+
unicode-display_width (~> 1.1, >= 1.1.1)
132131
thor (1.0.1)
133132
tilt (2.0.10)
134-
tins (1.22.2)
135133
unicode-display_width (1.6.1)
136134
uuid (2.3.9)
137135
macaddr (~> 1.0)
@@ -142,18 +140,18 @@ PLATFORMS
142140

143141
DEPENDENCIES
144142
allure-ruby!
145-
bundler (~> 2.0)
146-
colorize (~> 0.8)
147-
coveralls (~> 0.8)
143+
bundler (~> 2.1.2)
144+
colorize (~> 0.8.1)
148145
lefthook (~> 0.7.0)
149146
pry (~> 0.12.2)
150-
rake (~> 13.0)
151-
rspec (~> 3.8)
152-
rubocop (~> 0.74)
153-
rubocop-performance (~> 1.4)
154-
semantic (~> 1.6)
155-
simplecov (~> 0.16)
156-
solargraph (~> 0.35)
147+
rake (~> 13.0.1)
148+
rspec (~> 3.9.0)
149+
rubocop (~> 0.80.0)
150+
rubocop-performance (~> 1.5.2)
151+
semantic (~> 1.6.1)
152+
simplecov (~> 0.17.1)
153+
simplecov-console (~> 0.6.0)
154+
solargraph (~> 0.38.5)
157155

158156
BUNDLED WITH
159157
2.1.2

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
[![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/allure-framework/allure-ruby/master)
44
![Workflow status](https://github.com/allure-framework/allure-ruby/workflows/Test/badge.svg)
5-
[![Coverage Status](https://coveralls.io/repos/github/allure-framework/allure-ruby/badge.svg?branch=master)](https://coveralls.io/github/allure-framework/allure-ruby?branch=master)
5+
[![Maintainability](https://api.codeclimate.com/v1/badges/3190a4c9e68f20dd82ec/maintainability)](https://codeclimate.com/github/allure-framework/allure-ruby/maintainability)
6+
[![Test Coverage](https://api.codeclimate.com/v1/badges/3190a4c9e68f20dd82ec/test_coverage)](https://codeclimate.com/github/allure-framework/allure-ruby/test_coverage)
7+
68
Ruby testing framework adaptors for generating allure compatible test reports.
79

810
## allure-ruby-commons

allure.gemspec

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ Gem::Specification.new do |s|
2020
s.add_dependency "allure-cucumber", version
2121
s.add_dependency "allure-rspec", version
2222

23-
s.add_development_dependency "bundler", "~> 2.0"
23+
s.add_development_dependency "bundler", "~> 2.1.2"
2424
s.add_development_dependency "pry", "~> 0.12.2"
25-
s.add_development_dependency "rake", "~> 13.0"
26-
s.add_development_dependency "rspec", "~> 3.8"
27-
s.add_development_dependency "rubocop", "~> 0.74"
28-
s.add_development_dependency "rubocop-performance", "~> 1.4"
29-
s.add_development_dependency "solargraph", "~> 0.35"
30-
s.add_development_dependency "colorize", "~> 0.8"
31-
s.add_development_dependency "simplecov", "~> 0.16"
32-
s.add_development_dependency "coveralls", "~> 0.8"
33-
s.add_development_dependency "semantic", "~> 1.6"
25+
s.add_development_dependency "rake", "~> 13.0.1"
26+
s.add_development_dependency "rspec", "~> 3.9.0"
27+
s.add_development_dependency "rubocop", "~> 0.80.0"
28+
s.add_development_dependency "rubocop-performance", "~> 1.5.2"
29+
s.add_development_dependency "solargraph", "~> 0.38.5"
30+
s.add_development_dependency "colorize", "~> 0.8.1"
31+
s.add_development_dependency "simplecov", "~> 0.17.1"
32+
s.add_development_dependency "simplecov-console", "~> 0.6.0"
33+
s.add_development_dependency "semantic", "~> 1.6.1"
3434
s.add_development_dependency "lefthook", "~> 0.7.0"
3535
end

rake/test.rb

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,57 @@
33
require "rspec/core/rake_task"
44
require "rubocop/rake_task"
55
require "json"
6+
require "fileutils"
67

78
require_relative "util"
89

10+
class CodeClimateUploader
11+
CC_REPORTER_URL = "https://codeclimate.com/downloads/test-reporter/test-reporter-0.6.3-linux-amd64"
12+
CC_REPORTER = "vendor/bundle/cc_reporter_0.6.3"
13+
CC_JSON = "codeclimate.json"
14+
SIMPLECOV_RESULT = "coverage/.resultset.json"
15+
16+
class << self
17+
def upload
18+
download_reporter
19+
format_coverage
20+
upload_coverage
21+
end
22+
23+
private
24+
25+
def format_coverage
26+
system(cc_env, "./#{CC_REPORTER} format-coverage #{SIMPLECOV_RESULT} -t simplecov -o #{CC_JSON}")
27+
end
28+
29+
def upload_coverage
30+
system(cc_env, "./#{CC_REPORTER} upload-coverage -i #{CC_JSON}")
31+
end
32+
33+
def cc_env
34+
@cc_env ||= {
35+
"GIT_COMMIT_SHA" => pull_request? ? context.event.pull_request.head.sha : context.sha,
36+
"GIT_BRANCH" => pull_request? ? ENV["GITHUB_HEAD_REF"] : ENV["GITHUB_REF"].split("/").last,
37+
"CI_NAME" => "github-actions",
38+
}
39+
end
40+
41+
def context
42+
@context ||= JSON.parse(ENV["CONTEXT"], object_class: OpenStruct)
43+
end
44+
45+
def pull_request?
46+
@pull_request ||= ENV["GITHUB_EVENT_NAME"] == "pull_request"
47+
end
48+
49+
def download_reporter
50+
return if File.exist?(CC_REPORTER)
51+
52+
system("curl -s -L #{CC_REPORTER_URL} -o #{CC_REPORTER} && chmod a+x #{CC_REPORTER}")
53+
end
54+
end
55+
end
56+
957
class TestTasks
1058
include Rake::DSL
1159
include TaskUtil
@@ -60,7 +108,7 @@ def add_single_adaptor_tasks
60108

61109
def run_all_adaptors(task_name)
62110
errors = adaptors.each_with_object([]) do |adaptor, a|
63-
puts "\nExecuting #{task_name} for #{adaptor}".yellow
111+
puts "Executing #{task_name} for #{adaptor}".yellow
64112
run_single_adaptor(adaptor, task_name)
65113
rescue
66114
a << adaptor
@@ -75,41 +123,32 @@ def run_single_adaptor(adaptor, task_name)
75123
def merge_coverage
76124
ENV["COV_MERGE"] = "true"
77125
require "simplecov"
78-
require "coveralls"
126+
require "simplecov-console"
79127

80-
results = Dir.glob("#{root}/*/coverage/.resultset.json").each_with_object([]) do |file, res|
81-
res << SimpleCov::Result.from_hash(JSON.parse(File.read(file)))
128+
SimpleCov.configure do
129+
%w[allure-cucumber allure-rspec allure-ruby-commons].each { |g| add_group(g, g) }
130+
formatter(multiformatter)
82131
end
83132

84-
puts "\nGenerating combined coverage report".yellow
85-
SimpleCov::ResultMerger.merge_results(*results).tap do |result|
86-
ENV["CI"] ? publish_coverage(result) : display_coverage(result)
87-
end
133+
merge_results
134+
CodeClimateUploader.upload if ENV["CI"] && ENV["RUBY_VERSION"] == "2.7"
88135
end
89136

90-
def display_coverage(result)
91-
Coveralls::SimpleCov::Formatter.new.display_result(result)
92-
end
93-
94-
def publish_coverage(result)
95-
JSON.parse(ENV["CONTEXT"], object_class: OpenStruct).tap do |context|
96-
coveralls_set_env(pull_request? ? context.event.pull_request.head.sha : context.sha)
137+
def merge_results
138+
puts "Generating combined coverage report".yellow
139+
results = Dir.glob("#{root}/*/coverage/.resultset.json").each_with_object([]) do |file, res|
140+
res << SimpleCov::Result.from_hash(JSON.parse(File.read(file)))
141+
end
142+
SimpleCov::ResultMerger.merge_results(*results).tap do |result|
143+
SimpleCov::ResultMerger.store_result(result)
144+
result.format!
97145
end
98-
Coveralls::SimpleCov::Formatter.new.format(result)
99-
end
100-
101-
def coveralls_set_env(sha)
102-
ENV["GIT_ID"] = sha
103-
ENV["GIT_BRANCH"] = ENV["CI_BRANCH"] = pull_request? ? ENV["GITHUB_HEAD_REF"] : ENV["GITHUB_REF"].split("/").last
104-
ENV["GIT_MESSAGE"] = `git --no-pager show -s --format='%s' #{sha}`
105-
ENV["GIT_COMMITTER_NAME"] = `git --no-pager show -s --format='%cN' #{sha}`
106-
ENV["GIT_COMMITTER_EMAIL"] = `git --no-pager show -s --format='%ce' #{sha}`
107-
ENV["GIT_AUTHOR_NAME"] = `git --no-pager show -s --format='%aN' #{sha}`
108-
ENV["GIT_AUTHOR_EMAIL"] = `git --no-pager show -s --format='%ae' #{sha}`
109146
end
110147

111-
def pull_request?
112-
ENV["GITHUB_EVENT_NAME"] == "pull_request"
148+
def multiformatter
149+
formatters = [SimpleCov::Formatter::Console]
150+
formatters << SimpleCov::Formatter::HTMLFormatter if ENV["COV_HTML_REPORT"]
151+
SimpleCov::Formatter::MultiFormatter.new(formatters)
113152
end
114153
end
115154

0 commit comments

Comments
 (0)