codeclimate_circle_ci_coverage 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/report_coverage +5 -0
- data/lib/codeclimate_circle_ci_coverage/circle.rb +73 -0
- data/lib/codeclimate_circle_ci_coverage.rb +1 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 736e755062235de6ea205fb870ada692f4d522ba
|
4
|
+
data.tar.gz: b5c0f4623c999bb307ae0dd9f9f43259d33bba3c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 73ef5d25b4a56ed4d505bb5c56e276c1e9464bf70647d2dc993311fbf29c4f478489a6ffc4c83c9103108bb4b3fc5c6d5a00072ffb6366f9ecd15b0096ede8b7
|
7
|
+
data.tar.gz: 208ead58f46e78abb2104c0674357544cfb515d3f297a2f0becbe1eee49e83a551ac965084c591f8f59010bf3a033cc4915bd86d4b8b9c8a6ab852de5f126cb4
|
data/bin/report_coverage
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# This packages up the code coverage metrics and
|
2
|
+
# sends them to CodeClimate via the CodeClimate Test Reporter Gem
|
3
|
+
|
4
|
+
# from https://github.com/codeclimate/ruby-test-reporter/issues/10
|
5
|
+
# https://gist.github.com/evanwhalen/f74879e0549b67eb17bb
|
6
|
+
|
7
|
+
# Possibly look at:
|
8
|
+
# http://technology.indiegogo.com/2015/08/how-we-get-coverage-on-parallelized-test-builds/
|
9
|
+
#
|
10
|
+
# Questions:
|
11
|
+
# - Why aren't artifacts stored in the $CIRCLE_ARTIFACTS directory when doing SSH login?
|
12
|
+
require "codeclimate-test-reporter"
|
13
|
+
require "simplecov"
|
14
|
+
require 'fileutils'
|
15
|
+
|
16
|
+
class CoverageReporter
|
17
|
+
def self.run
|
18
|
+
branch = ENV['CIRCLE_BRANCH']
|
19
|
+
node_index = ENV['CIRCLE_NODE_INDEX'].to_i
|
20
|
+
node_total = ENV['CIRCLE_NODE_TOTAL'].to_i
|
21
|
+
coverage_dir = File.join("coverage")
|
22
|
+
|
23
|
+
# Create directory if it doesn't exist
|
24
|
+
FileUtils.mkdir_p coverage_dir
|
25
|
+
|
26
|
+
filename = '.resultset.json'
|
27
|
+
|
28
|
+
SimpleCov.coverage_dir(coverage_dir)
|
29
|
+
|
30
|
+
# Only run on node0
|
31
|
+
exit unless node_index.zero?
|
32
|
+
|
33
|
+
if node_total > 0
|
34
|
+
# Copy coverage results from all nodes to circle artifacts directory
|
35
|
+
1.upto(node_total - 1) do |i|
|
36
|
+
node = "node#{i}"
|
37
|
+
# Modified because circleCI doesn't appear to deal with artifacts in the expected manner
|
38
|
+
node_project_dir = `ssh #{node} 'printf $CIRCLE_PROJECT_REPONAME'`
|
39
|
+
from = File.join("~/", node_project_dir, 'coverage', filename)
|
40
|
+
to = File.join(coverage_dir, "#{i}#{filename}")
|
41
|
+
command = "scp #{node}:#{from} #{to}"
|
42
|
+
|
43
|
+
puts "running command: #{command}"
|
44
|
+
`#{command}`
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Merge coverage results from other nodes
|
49
|
+
# .resultset.json is a hidden file and thus ignored by the glob
|
50
|
+
files = Dir.glob(File.join(coverage_dir, "*#{filename}"))
|
51
|
+
files.each_with_index do |file, i|
|
52
|
+
resultset = JSON.load(File.read(file))
|
53
|
+
resultset.each do |_command_name, data|
|
54
|
+
result = SimpleCov::Result.from_hash(['command', i].join => data)
|
55
|
+
SimpleCov::ResultMerger.store_result(result)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
merged_result = SimpleCov::ResultMerger.merged_result
|
60
|
+
merged_result.command_name = 'RSpec'
|
61
|
+
|
62
|
+
# Format merged result with html
|
63
|
+
html_formatter = SimpleCov::Formatter::HTMLFormatter.new
|
64
|
+
html_formatter.format(merged_result)
|
65
|
+
|
66
|
+
# Only submit coverage to codeclimate on master branch
|
67
|
+
exit if branch != 'master'
|
68
|
+
|
69
|
+
# Post merged coverage result to codeclimate
|
70
|
+
codeclimate_formatter = CodeClimate::TestReporter::Formatter.new
|
71
|
+
codeclimate_formatter.format(merged_result)
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "codeclimate_coverage_parallel_circle_ci/circle"
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: codeclimate_circle_ci_coverage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robin Dunlop
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: codeclimate-test-reporter
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: simplecov
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A set of tools to support reporting SimpleCov Coverage to CodeClimate
|
56
|
+
with Parallel tests on CircleCI
|
57
|
+
email: robin@dunlopweb.com
|
58
|
+
executables:
|
59
|
+
- report_coverage
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- bin/report_coverage
|
64
|
+
- lib/codeclimate_circle_ci_coverage.rb
|
65
|
+
- lib/codeclimate_circle_ci_coverage/circle.rb
|
66
|
+
homepage: http://rubygems.org/gems/codeclimate_circle_ci_coverage
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.4.8
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: CodeClimate Code Coverage reporting script for CircleCI
|
90
|
+
test_files: []
|