codeclimate_circle_ci_coverage 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 80efd9d157477409d66776b499feef2d0369abb2
4
- data.tar.gz: 065d5b230669202674010522e1fa3f83ddc8d88e
2
+ SHA256:
3
+ metadata.gz: 2f71f70c8e89c3094db834517ac6230d75713190a3e839bcde3e21a54d0067fa
4
+ data.tar.gz: c8af9c061ec72fa28cf89669caf6ad5fe9ad326c2d4d2807479b18fb526fc32e
5
5
  SHA512:
6
- metadata.gz: cdf9361215d3bd25a79c446debe4d4e692f3795a66245669906e5d63f2e19d4214238b0875d97dbcfd6ff5932d81f1711e2282dbbd82ad9ccf53315b507a63ac
7
- data.tar.gz: 5de1ba8c318c31f5a6280dd9bfc6364c346a7e0c6e95687436dfd2dd100a11cc990ab2e1078f610c5dbb081f7636cd7308e68cb75a6c8ad469582eb05588b8dd
6
+ metadata.gz: 14fc78b9b8a9c689d29b6de34f0ffa426f2034fb3648e65b3665252eb30f6110d1bcebf73cbc3c36de796629c11e8cc58e9e6d0feab88dcb6b7453bfdcc2b794
7
+ data.tar.gz: '08c87f8e5690392983e05b79b084decad0953aaf128d6858a1f155f3793ebc32b17e8776d721cd1404580ec6fa957a8127ba0348ad15f8a8b64905cd3b2c8a71'
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  require 'codeclimate_circle_ci_coverage'
3
5
  require 'optparse'
4
6
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "codeclimate_circle_ci_coverage/version"
2
4
  require "codeclimate_circle_ci_coverage/patch_simplecov"
3
5
  require "codeclimate_circle_ci_coverage/coverage_reporter"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fileutils'
2
4
  require 'json'
3
5
 
@@ -32,7 +34,7 @@ class CircleCi1
32
34
 
33
35
  # Load coverage results from all nodes
34
36
  files = Dir.glob(File.join(target_directory, "*.resultset.json"))
35
- files.map do |file, i|
37
+ files.map do |file, _i|
36
38
  JSON.load(File.read(file))
37
39
  end
38
40
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'open-uri'
2
4
  require 'json'
3
5
 
@@ -6,18 +8,33 @@ class CircleCi2
6
8
 
7
9
  def download_files
8
10
  if ENV["CIRCLE_TOKEN"].nil?
9
- puts "You must create a Circle CI API token to use this on Circle CI 2.0"
11
+ puts "You must create a Circle CI Artifacts-API token to use this on Circle CI 2.0"
10
12
  puts "Please create that, and store the key as CIRCLE_TOKEN"
11
13
  return []
12
14
  end
13
-
15
+ # rubocop:disable Metrics/LineLength
14
16
  api_url = "https://circleci.com/api/v1.1/project/github/#{ENV['CIRCLE_PROJECT_USERNAME']}/#{ENV['CIRCLE_PROJECT_REPONAME']}/#{ENV['CIRCLE_BUILD_NUM']}/artifacts?circle-token=#{ENV['CIRCLE_TOKEN']}"
17
+ # rubocop:enable Metrics/LineLength
15
18
  artifacts = open(api_url)
16
19
 
17
- JSON.load(artifacts).select do |artifact|
18
- artifact['path'] == "home/circleci/project/#{ARTIFACT_PREFIX}/.resultset.json"
20
+ paths = matching_urls(JSON.load(artifacts))
21
+
22
+ if paths.none?
23
+ puts "No Results Found. Did you store the artifacts with 'store_artifacts'?"
24
+ puts "did you use 'prefix: coverage'?"
25
+ return []
26
+ end
27
+
28
+ paths.map do |path|
29
+ JSON.load(open("#{path}?circle-token=#{ENV['CIRCLE_TOKEN']}"))
30
+ end
31
+ end
32
+
33
+ def matching_urls(json)
34
+ json.select do |artifact|
35
+ artifact['path'].match("#{ARTIFACT_PREFIX}/.resultset.json")
19
36
  end.map do |artifact|
20
- JSON.load(open("#{artifact['url']}?circle-token=#{ENV['CIRCLE_TOKEN']}"))
37
+ artifact['url']
21
38
  end
22
39
  end
23
40
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # from https://github.com/codeclimate/ruby-test-reporter/issues/10
2
4
  # https://gist.github.com/evanwhalen/f74879e0549b67eb17bb
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "simplecov"
2
4
  # Without this change, merging results erroneously marks blank comment lines as
3
5
  # uncovered.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CodeclimateCircleCiCoverage
2
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe CoverageReporter do
@@ -9,9 +11,9 @@ describe CoverageReporter do
9
11
  {
10
12
  "RSpec" => {
11
13
  "coverage" => {
12
- "#{SimpleCov.root}/spec/fixtures/fake_project/fake_project.rb" => [5,3,nil,0]
14
+ "#{SimpleCov.root}/spec/fixtures/fake_project/fake_project.rb" => [5, 3, nil, 0]
13
15
  },
14
- "timestamp" => Time.now.to_i,
16
+ "timestamp" => Time.now.to_i
15
17
  }
16
18
  }
17
19
  ]
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
4
  require 'codeclimate_circle_ci_coverage'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate_circle_ci_coverage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Dunlop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-07 00:00:00.000000000 Z
11
+ date: 2018-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter
@@ -90,16 +90,16 @@ dependencies:
90
90
  name: rubocop
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - "~>"
93
+ - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: '0.38'
95
+ version: '0'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: '0.38'
102
+ version: '0'
103
103
  description: A set of tools to support reporting SimpleCov Coverage to CodeClimate
104
104
  with Parallel tests on CircleCI
105
105
  email: robin@dunlopweb.com
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.6.7
140
+ rubygems_version: 2.7.6
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: CodeClimate Code Coverage reporting script for CircleCI