coveralls-multi 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +62 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/coveralls-multi +6 -0
- data/bin/setup +6 -0
- data/bin/test +3 -0
- data/coveralls-multi.gemspec +31 -0
- data/lib/coveralls-multi.rb +9 -0
- data/lib/coveralls-multi/config.rb +34 -0
- data/lib/coveralls-multi/formatter.rb +39 -0
- data/lib/coveralls-multi/formatters/lcov.rb +20 -0
- data/lib/coveralls-multi/formatters/simplecov.rb +37 -0
- data/lib/coveralls-multi/runner.rb +57 -0
- data/lib/coveralls-multi/validator.rb +50 -0
- data/lib/coveralls-multi/version.rb +3 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4fac777408e47be1747fca8273ff16d095861b02ee022fa4b7515dc067701c78
|
4
|
+
data.tar.gz: be2f784f4b014c5cf180081b43b9eaa803e7b80280677bf0843e45bde5ef80d5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7e1079f5b076d6a1628888bf92e487ad3c1e4508d6150541974e1e11f2477c481b2741d5069c342455a2b3d25e3cf242c5b8bb4ba1dce6047c48aaadeff82448
|
7
|
+
data.tar.gz: 2366f207f0a1f1266c68b774e5d00cfde8d0ec894ca71d1420233b56655cc12626ec29b0025c639a3bbc8a240fd048f483c4803179f399efa9871ba1efe85484
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Style/TrailingCommaInArguments:
|
2
|
+
EnforcedStyleForMultiline: comma
|
3
|
+
|
4
|
+
Style/TrailingCommaInArrayLiteral:
|
5
|
+
EnforcedStyleForMultiline: comma
|
6
|
+
|
7
|
+
Style/TrailingCommaInHashLiteral:
|
8
|
+
EnforcedStyleForMultiline: comma
|
9
|
+
|
10
|
+
Metrics/LineLength:
|
11
|
+
Max: 100
|
12
|
+
|
13
|
+
EmptyMethod:
|
14
|
+
EnforcedStyle: expanded
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at thecjhorton@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
coveralls-multi (0.1.0)
|
5
|
+
coveralls (~> 0.8.21)
|
6
|
+
coveralls-lcov (~> 1.5.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
coderay (1.1.2)
|
12
|
+
coveralls (0.8.21)
|
13
|
+
json (>= 1.8, < 3)
|
14
|
+
simplecov (~> 0.14.1)
|
15
|
+
term-ansicolor (~> 1.3)
|
16
|
+
thor (~> 0.19.4)
|
17
|
+
tins (~> 1.6)
|
18
|
+
coveralls-lcov (1.5.1)
|
19
|
+
diff-lcs (1.3)
|
20
|
+
docile (1.1.5)
|
21
|
+
json (2.1.0)
|
22
|
+
method_source (0.9.0)
|
23
|
+
pry (0.11.3)
|
24
|
+
coderay (~> 1.1.0)
|
25
|
+
method_source (~> 0.9.0)
|
26
|
+
rake (10.5.0)
|
27
|
+
rspec (3.7.0)
|
28
|
+
rspec-core (~> 3.7.0)
|
29
|
+
rspec-expectations (~> 3.7.0)
|
30
|
+
rspec-mocks (~> 3.7.0)
|
31
|
+
rspec-core (3.7.1)
|
32
|
+
rspec-support (~> 3.7.0)
|
33
|
+
rspec-expectations (3.7.0)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.7.0)
|
36
|
+
rspec-mocks (3.7.0)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.7.0)
|
39
|
+
rspec-support (3.7.1)
|
40
|
+
simplecov (0.14.1)
|
41
|
+
docile (~> 1.1.0)
|
42
|
+
json (>= 1.8, < 3)
|
43
|
+
simplecov-html (~> 0.10.0)
|
44
|
+
simplecov-html (0.10.2)
|
45
|
+
term-ansicolor (1.6.0)
|
46
|
+
tins (~> 1.0)
|
47
|
+
thor (0.19.4)
|
48
|
+
tins (1.16.3)
|
49
|
+
|
50
|
+
PLATFORMS
|
51
|
+
ruby
|
52
|
+
|
53
|
+
DEPENDENCIES
|
54
|
+
bundler (~> 1.16)
|
55
|
+
coveralls-multi!
|
56
|
+
pry (~> 0.11.3)
|
57
|
+
rake (~> 10.0)
|
58
|
+
rspec (~> 3.0)
|
59
|
+
simplecov (~> 0.14.1)
|
60
|
+
|
61
|
+
BUNDLED WITH
|
62
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 CJ
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# CoverallsMulti
|
2
|
+
|
3
|
+
CoverallsMulti is a Coveralls client with support for multi-language repos. Specify the paths to your coverage output files in `.coveralls.yml`, and CoverallsMulti will handle formatting them, merging them into one big superfile, and posting the result to Coveralls.io.
|
4
|
+
|
5
|
+
### Currently supported:
|
6
|
+
|
7
|
+
#### CI Providers
|
8
|
+
- TravisCI
|
9
|
+
|
10
|
+
#### Languages/Output Formats
|
11
|
+
- Ruby (SimpleCov)
|
12
|
+
- JavaScript (lcov)
|
13
|
+
|
14
|
+
#### Coming Soon
|
15
|
+
- Elixir
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add this line to the test group in your application's Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'coveralls-multi'
|
23
|
+
```
|
24
|
+
|
25
|
+
And then execute:
|
26
|
+
|
27
|
+
$ bundle
|
28
|
+
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
$ gem install coveralls-multi
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
Set up coverage measurement for each of the languages in your repo (TODO: add links to setup instructions for supported languages).
|
36
|
+
|
37
|
+
Once you know where the output files will go, add the output type and path to `.coveralls.yml`. Example:
|
38
|
+
|
39
|
+
```
|
40
|
+
service_name: travis-ci
|
41
|
+
repo_token: [REPO_TOKEN]
|
42
|
+
multi:
|
43
|
+
simplecov: coverage/.resultset.json
|
44
|
+
lcov: coverage/lcov.info
|
45
|
+
```
|
46
|
+
|
47
|
+
Then run `coveralls-multi` to merge the output files and send them to Coveralls. In a CI environment, run `coveralls-multi` after you run your test commands.
|
48
|
+
|
49
|
+
## Development
|
50
|
+
|
51
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
52
|
+
|
53
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
54
|
+
|
55
|
+
TODO: more detailed instructions for adding a new formatter
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/radditude/coveralls-multi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
64
|
+
|
65
|
+
## Code of Conduct
|
66
|
+
|
67
|
+
Everyone interacting in the CoverallsMulti project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/radditude/coveralls-multi/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'coveralls-multi'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/coveralls-multi
ADDED
data/bin/setup
ADDED
data/bin/test
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('lib', __dir__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'coveralls-multi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'coveralls-multi'
|
8
|
+
spec.version = CoverallsMulti::VERSION
|
9
|
+
spec.authors = ['CJ Horton']
|
10
|
+
spec.email = ['thecjhorton@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Coveralls client for multi-language repos.'
|
13
|
+
spec.description = 'A configurable Coveralls client that supports merging coverage from multiple languages & test suites.'
|
14
|
+
# spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.executables = 'coveralls-multi'
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_dependency 'coveralls', '~> 0.8.21'
|
24
|
+
spec.add_dependency 'coveralls-lcov', '~> 1.5.1'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
27
|
+
spec.add_development_dependency 'pry', '~> 0.11.3'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
spec.add_development_dependency 'simplecov', '~> 0.14.1'
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module CoverallsMulti
|
4
|
+
# reads .coveralls.yml and sets module config options
|
5
|
+
class Config
|
6
|
+
class << self
|
7
|
+
def files
|
8
|
+
yml = yaml_config['multi']
|
9
|
+
|
10
|
+
raise "Couldn't find coveralls-multi configuration in .coveralls.yml" unless yml
|
11
|
+
|
12
|
+
yml
|
13
|
+
end
|
14
|
+
|
15
|
+
def debug_mode
|
16
|
+
yaml_config['debug_mode'] && yaml_config['debug_mode'] == 'true'
|
17
|
+
end
|
18
|
+
|
19
|
+
def yaml_config
|
20
|
+
raise "Couldn't find config file" unless configuration_path && File.exist?(configuration_path)
|
21
|
+
|
22
|
+
YAML.load_file(configuration_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def root
|
26
|
+
Dir.pwd
|
27
|
+
end
|
28
|
+
|
29
|
+
def configuration_path
|
30
|
+
File.expand_path(File.join(root, '.coveralls.yml')) if root
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
# require individual formatters here
|
5
|
+
require 'coveralls-multi/formatters/lcov'
|
6
|
+
require 'coveralls-multi/formatters/simplecov'
|
7
|
+
|
8
|
+
module CoverallsMulti
|
9
|
+
# contains formatters for individual language/output types
|
10
|
+
# and common methods
|
11
|
+
class Formatter
|
12
|
+
class << self
|
13
|
+
def add_source_digests(merged_files)
|
14
|
+
merged_files['source_files'].map do |src_file|
|
15
|
+
file_content = src_file['source']
|
16
|
+
src_digest = Digest::MD5.hexdigest(file_content)
|
17
|
+
src_file['source_digest'] = src_digest
|
18
|
+
src_file
|
19
|
+
end
|
20
|
+
puts 'Added source digests'
|
21
|
+
merged_files
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_travis_keys(payload)
|
25
|
+
payload['service_name'] = 'travis-pro'
|
26
|
+
payload['repo_token'] = ENV['COVERALLS_REPO_TOKEN'] || ''
|
27
|
+
payload.delete 'service_job_id'
|
28
|
+
puts 'Added Travis keys'
|
29
|
+
payload
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse_json(path)
|
33
|
+
JSON.parse(IO.read("#{CoverallsMulti::Config.root}/#{path}"))
|
34
|
+
rescue StandardError => e
|
35
|
+
raise e, "Could not parse file at #{path}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'coveralls/lcov/converter'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module CoverallsMulti
|
5
|
+
class Formatter
|
6
|
+
# formats lcov coverage results files
|
7
|
+
# before merge + push to Coveralls
|
8
|
+
class Lcov
|
9
|
+
# convert lcov files using the coveralls-lcov gem
|
10
|
+
def run(file_path)
|
11
|
+
converter = Coveralls::Lcov::Converter.new(file_path)
|
12
|
+
file = converter.convert
|
13
|
+
# HACK: stringify keys without iterating over the whole array of hashes
|
14
|
+
JSON.parse(JSON.dump(file[:source_files]))
|
15
|
+
rescue StandardError, SystemExit => e
|
16
|
+
raise e, "There was a problem converting the lcov file at #{file_path}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module CoverallsMulti
|
2
|
+
class Formatter
|
3
|
+
# formats SimpleCov coverage results files
|
4
|
+
# before merge + push to Coveralls
|
5
|
+
class Simplecov
|
6
|
+
|
7
|
+
# helper to grab the filename relative to the repo root
|
8
|
+
def format_short_filename(filename)
|
9
|
+
filename = filename.gsub(CoverallsMulti::Config.root, '.').gsub(/^\.\//, '') if CoverallsMulti::Config.root
|
10
|
+
filename
|
11
|
+
end
|
12
|
+
|
13
|
+
# get relevant data from the Ruby coverage report & format it
|
14
|
+
def run(file_path)
|
15
|
+
file = CoverallsMulti::Formatter.parse_json(file_path)
|
16
|
+
|
17
|
+
source_files = []
|
18
|
+
begin
|
19
|
+
file['RSpec']['coverage'].each do |filename, coverage|
|
20
|
+
properties = {}
|
21
|
+
|
22
|
+
properties['source'] = File.open(filename, 'rb:utf-8').read
|
23
|
+
properties['name'] = format_short_filename(filename)
|
24
|
+
properties['coverage'] = coverage
|
25
|
+
|
26
|
+
source_files << properties
|
27
|
+
end
|
28
|
+
rescue StandardError => e
|
29
|
+
raise e, "There was a problem formatting the simplecov report at #{file_path}"
|
30
|
+
end
|
31
|
+
|
32
|
+
puts 'SimpleCov report reformatted to prepare for merge'
|
33
|
+
source_files
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'coveralls'
|
3
|
+
|
4
|
+
module CoverallsMulti
|
5
|
+
class Runner
|
6
|
+
attr_accessor :files
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@files = CoverallsMulti::Config.files
|
10
|
+
end
|
11
|
+
|
12
|
+
def start
|
13
|
+
payload = merge
|
14
|
+
write_to_file(payload)
|
15
|
+
puts 'Validating payload and pushing to Coveralls'
|
16
|
+
valid = CoverallsMulti::Validator.new(payload).run
|
17
|
+
Coveralls::API.post_json('jobs', payload) if valid
|
18
|
+
end
|
19
|
+
|
20
|
+
def write_to_file(payload)
|
21
|
+
return unless CoverallsMulti::Config.debug_mode
|
22
|
+
|
23
|
+
output_file_path = "#{CoverallsMulti::Config.root}/coveralls.json"
|
24
|
+
puts "Writing results to #{output_file_path}"
|
25
|
+
File.write(output_file_path, JSON.pretty_generate(payload))
|
26
|
+
end
|
27
|
+
|
28
|
+
def merge
|
29
|
+
source_files = format_all_coverage_files
|
30
|
+
merged = { 'source_files' => source_files }
|
31
|
+
CoverallsMulti::Formatter.add_source_digests(merged)
|
32
|
+
CoverallsMulti::Formatter.add_travis_keys(merged)
|
33
|
+
|
34
|
+
puts 'All files merged and formatted'
|
35
|
+
merged
|
36
|
+
end
|
37
|
+
|
38
|
+
def format_all_coverage_files
|
39
|
+
type_array = @files.keys
|
40
|
+
formatted_array = []
|
41
|
+
|
42
|
+
type_array.each do |type|
|
43
|
+
result = formatter(type).new.run(@files[type])
|
44
|
+
formatted_array.concat result
|
45
|
+
end
|
46
|
+
|
47
|
+
formatted_array
|
48
|
+
end
|
49
|
+
|
50
|
+
def formatter(string)
|
51
|
+
string_klass = "CoverallsMulti::Formatter::#{string.capitalize}"
|
52
|
+
Object.const_get(string_klass)
|
53
|
+
rescue NameError => e
|
54
|
+
raise e, "Could not find formatter #{string_klass}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module CoverallsMulti
|
4
|
+
# checks that a payload is valid before sending to Coveralls
|
5
|
+
class Validator
|
6
|
+
attr_accessor :payload
|
7
|
+
TOP_LEVEL_KEYS = %w[repo_token service_name source_files].freeze
|
8
|
+
SOURCE_FILE_KEYS = %w[name source_digest coverage source].freeze
|
9
|
+
|
10
|
+
def initialize(payload)
|
11
|
+
@payload = payload
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
return true if json? && valid_coveralls_payload?
|
16
|
+
end
|
17
|
+
|
18
|
+
def json?
|
19
|
+
parsed_json = JSON.dump(@payload)
|
20
|
+
parsed_json
|
21
|
+
rescue JSON::UnparserError => e
|
22
|
+
raise e, 'Payload could not be parsed to JSON!'
|
23
|
+
end
|
24
|
+
|
25
|
+
def valid_coveralls_payload?
|
26
|
+
raise 'Payload is empty!' if !@payload || @payload.empty?
|
27
|
+
raise 'Payload should be a hash!' unless @payload.is_a?(Hash)
|
28
|
+
|
29
|
+
check_required_keys(TOP_LEVEL_KEYS, 'Missing required top-level key(s)')
|
30
|
+
@payload['source_files'].each do |src_file|
|
31
|
+
check_required_keys(
|
32
|
+
SOURCE_FILE_KEYS, 'Missing required source file key(s)', src_file
|
33
|
+
)
|
34
|
+
end
|
35
|
+
@payload
|
36
|
+
end
|
37
|
+
|
38
|
+
def check_required_keys(required_keys, message = 'Missing required key(s)', payload = @payload)
|
39
|
+
missing_keys = []
|
40
|
+
|
41
|
+
required_keys.each do |key|
|
42
|
+
missing_keys.push key unless payload[key]
|
43
|
+
end
|
44
|
+
|
45
|
+
error = "#{message} - #{missing_keys.join(', ')}"
|
46
|
+
|
47
|
+
raise error unless missing_keys.empty?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coveralls-multi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- CJ Horton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: coveralls
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.21
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.21
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: coveralls-lcov
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.5.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.5.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.11.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.11.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.14.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.14.1
|
111
|
+
description: A configurable Coveralls client that supports merging coverage from multiple
|
112
|
+
languages & test suites.
|
113
|
+
email:
|
114
|
+
- thecjhorton@gmail.com
|
115
|
+
executables:
|
116
|
+
- coveralls-multi
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".rubocop.yml"
|
123
|
+
- ".travis.yml"
|
124
|
+
- CODE_OF_CONDUCT.md
|
125
|
+
- Gemfile
|
126
|
+
- Gemfile.lock
|
127
|
+
- LICENSE.txt
|
128
|
+
- README.md
|
129
|
+
- Rakefile
|
130
|
+
- bin/console
|
131
|
+
- bin/coveralls-multi
|
132
|
+
- bin/setup
|
133
|
+
- bin/test
|
134
|
+
- coveralls-multi.gemspec
|
135
|
+
- lib/coveralls-multi.rb
|
136
|
+
- lib/coveralls-multi/config.rb
|
137
|
+
- lib/coveralls-multi/formatter.rb
|
138
|
+
- lib/coveralls-multi/formatters/lcov.rb
|
139
|
+
- lib/coveralls-multi/formatters/simplecov.rb
|
140
|
+
- lib/coveralls-multi/runner.rb
|
141
|
+
- lib/coveralls-multi/validator.rb
|
142
|
+
- lib/coveralls-multi/version.rb
|
143
|
+
homepage:
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
metadata: {}
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 2.7.6
|
164
|
+
signing_key:
|
165
|
+
specification_version: 4
|
166
|
+
summary: Coveralls client for multi-language repos.
|
167
|
+
test_files: []
|