Skip to content

Commit

Permalink
added debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmerwin committed Nov 13, 2020
1 parent 597719e commit aae9ca9
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Auto-detects your coverage artifact files and CI environment to post to [Coveral

```
$ coveralls -h
Coveralls Coverage Reporter v0.1.5
Coveralls Coverage Reporter vX.Y.Z
Usage coveralls [arguments]
-rTOKEN, --repo-token=TOKEN Sets coveralls repo token, overrides settings in yaml or environment variable
-cPATH, --config-path=PATH Set the coveralls yaml config file location, will default to check '.coveralls.yml'
Expand All @@ -25,6 +25,7 @@ Usage coveralls [arguments]
-d, --done Call webhook after all parallel jobs (-p) done.
-n, --no-logo Do not show Coveralls logo in logs
-q, --quiet Suppress all output
--debug Debug mode. Data being sent to Coveralls will be outputted to console.
-h, --help Show this help
```

Expand Down
4 changes: 1 addition & 3 deletions fixtures/test.lcov
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
make[1]: Entering directory `/home/cainus/urlgrey'
SF:fixtures/test.js
DA:1,1
DA:2,1
Expand Down Expand Up @@ -112,5 +111,4 @@ DA:218,21
DA:219,21
DA:220,21
DA:222,165
end_of_record
make[1]: Leaving directory `/home/cainus/urlgrey'
end_of_record
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: coverage-reporter
version: 0.1.7
version: 0.1.8

authors:
- Jordan Oroshiba <[email protected]>
Expand Down
4 changes: 4 additions & 0 deletions src/cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ parser = OptionParser.parse do |parser|
CoverageReporter.quiet!
end

parser.on("--debug", "Debug mode. Data being sent to Coveralls will be outputted to console.") do
CoverageReporter.debug!
end

parser.on("-h", "--help", "Show this help") do
# TODO: add environment variable notes
puts "Coveralls Coverage Reporter v#{CoverageReporter::VERSION}"
Expand Down
10 changes: 9 additions & 1 deletion src/coverage_reporter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require "./coverage_reporter/*"


module CoverageReporter
VERSION = "0.1.7"
VERSION = "0.1.8"

def self.run(coverage_file : String, repo_token : String | Nil, yaml_file_location : String, job_flag : String | Nil, parallel : Bool)
yaml = YamlConfig.new(yaml_file_location)
Expand All @@ -27,4 +27,12 @@ module CoverageReporter
def self.quiet?
@@quiet
end

def self.debug!
@@debug = true
end

def self.debug?
@@debug
end
end
12 changes: 12 additions & 0 deletions src/coverage_reporter/api.cr
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ module CoverageReporter
puts "🚀 Posting coverage data to #{api_url}"
end

if debug?
puts "---\n⛑ Debug Output:\n#{data.to_json}"
end

res = Crest.post(
api_url,
headers: { "Content-Type" => "application/json" },
Expand Down Expand Up @@ -85,6 +89,10 @@ module CoverageReporter
}
}

if debug?
puts "---\n⛑ Debug Output:\n#{data.to_json}"
end

res = Crest.post(
webhook_url,
headers: { "Content-Type" => "application/json" },
Expand Down Expand Up @@ -119,5 +127,9 @@ module CoverageReporter
private def quiet?
CoverageReporter.quiet?
end

private def debug?
CoverageReporter.debug?
end
end
end

0 comments on commit aae9ca9

Please sign in to comment.