Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Commit 0b507c9

Browse files
committed
do not publish local results unless specified
1 parent 4eb83af commit 0b507c9

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

codacy-coverage.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
1414
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
1515
gem.name = "codacy-coverage"
1616
gem.require_paths = ["lib"]
17-
gem.version = '0.0.1'
17+
gem.version = '0.1.0'
1818

1919
gem.required_ruby_version = '>= 1.8.7'
2020

lib/codacy/formatter.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@ module Codacy
22
class Formatter
33

44
def format(result)
5-
parse_result = Codacy::Parser.parse_file(result)
6-
Codacy::ClientAPI.post_results(parse_result)
5+
if should_run?
6+
parse_result = Codacy::Parser.parse_file(result)
7+
Codacy::ClientAPI.post_results(parse_result)
8+
else
9+
logger.info("Running locally, skipping Codacy coverage")
10+
end
711
rescue => ex
812
logger.fatal(ex)
913
false
1014
end
1115

1216
private
1317

18+
def should_run?
19+
ENV["CI"] || ENV["JENKINS_URL"] || ENV['TDDIUM'] || ENV["CODACY_RUN_LOCAL"]
20+
end
21+
1422
def logger
1523
Codacy::Configuration.logger
1624
end

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
class InceptionFormatter
44
def format(result)
5+
ENV["CODACY_RUN_LOCAL"] = 'true'
56
Codacy::Formatter.new.format(result)
67
end
78
end

0 commit comments

Comments
 (0)