Skip to content

Commit

Permalink
Merge a6d432a into cecbefd
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox authored Apr 27, 2023
2 parents cecbefd + a6d432a commit db21adc
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: 1.7.3
crystal: 1.8.1

- run: shards install --production

Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: 1.7.3
crystal: 1.8.1

- name: Install dependencies
run: shards install --production
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: 1.7.3
crystal: 1.8.1
- name: Install dependencies
run: shards install
- name: Run tests
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: 1.7.3
crystal: 1.8.1
- name: Install dependencies
run: shards install
- name: Run linter
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: 1.7.3
crystal: 1.8.1
- run: shards install
- run: make
- name: Install kcov
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FROM crystallang/crystal:1.7.3-alpine
ARG CRYSTAL_VERSION
FROM crystallang/crystal:${CRYSTAL_VERSION}-alpine

RUN apk add sqlite-dev sqlite-static
RUN apk add xz-dev xz-static libxml2-dev libxml2-static sqlite-dev sqlite-static
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
UUID := $(shell id -u)
GUID := $(shell id -g)
CRYSTAL_VERSION := 1.7.3
CRYSTAL_VERSION := 1.8.1

compile:
crystal build src/cli.cr -o dist/coveralls --progress

release_linux:
docker build . --tag coverage-reporter:1.0
docker build . --build-arg CRYSTAL_VERSION=$(CRYSTAL_VERSION) --tag coverage-reporter:1.0
docker run --rm -t -v $(shell pwd):/app \
-w /app --user $(UUID):$(GUID) \
coverage-reporter:1.0 \
Expand Down
7 changes: 6 additions & 1 deletion src/coverage_reporter/parsers/gcov_parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ require "digest"

module CoverageReporter
class GcovParser < BaseParser
COVERAGE_RE = Regex.new(
"^\\s*([0-9]+|-|#####):\\s*([0-9]+):(.*)",
Regex::CompileOptions::MATCH_INVALID_UTF # don't raise error against non-UTF chars
)

# Use *base_path* to join with paths found in reports.
def initialize(@base_path : String?)
end
Expand All @@ -24,7 +29,7 @@ module CoverageReporter
name : String? = nil
source_digest : String? = nil
File.each_line(filename, chomp: true) do |line|
match = /^\s*([0-9]+|-|#####):\s*([0-9]+):(.*)/.match(line).try(&.to_a)
match = COVERAGE_RE.match(line).try(&.to_a)
next if !match || !match.try(&.size) == 4

count, number, text = match[1..3]
Expand Down
5 changes: 4 additions & 1 deletion src/coverage_reporter/parsers/golang_parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ require "./base_parser"

module CoverageReporter
class GolangParser < BaseParser
COVERAGE_RE = /^[\w.-]+\/[\w.-]+\/[\w.-]+\/(?:v\d+\/)?(.*\.go):(\d+)\.\d+,(\d+)\.\d+\s+\d+\s+(\d+)/
COVERAGE_RE = Regex.new(
"^[\\w.-]+\\/[\\w.-]+\\/[\\w.-]+\\/(?:v\\d+\\/)?(.*\\.go):(\\d+)\\.\\d+,(\\d+)\\.\\d+\\s+\\d+\\s+(\\d+)",
Regex::CompileOptions::MATCH_INVALID_UTF # don't raise error agains non-UTF chars
)

def globs : Array(String)
[] of String
Expand Down
14 changes: 10 additions & 4 deletions src/coverage_reporter/parsers/lcov_parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ module CoverageReporter
source_file = nil : String?
File.each_line(filename, chomp: true) do |line|
case line
when /\ASF:(.+)/
when re("\\ASF:(.+)")
source_file = base_path ? File.join(base_path, $1) : $1
when /\ADA:(\d+),(\d+)/
when re("\\ADA:(\\d+),(\\d+)")
line_no = $1.to_i64
count = $2.to_i64
coverage = info[source_file].coverage
coverage[line_no] = (coverage[line_no]? || 0.to_i64) + count
when /\ABRDA:(\d+),(\d+),(\d+),(\d+|-)/
when re("\\ABRDA:(\\d+),(\\d+),(\\d+),(\\d+|-)")
line_no = $1.to_i64
block_no = $2.to_i64
branch_no = $3.to_i64
Expand All @@ -67,7 +67,7 @@ module CoverageReporter
branches_block = branches_line[block_no] =
branches_line[block_no]? || {} of Int64 => Int64
branches_block[branch_no] = (branches_block[branch_no]? || 0.to_i64) + hits
when /\Aend_of_record/
when re("\\Aend_of_record")
source_file = nil
end
end
Expand Down Expand Up @@ -108,5 +108,11 @@ module CoverageReporter
format: self.class.name,
)
end

# Returns a regular expression that doesn't raise an error when string
# contains non-UTF characters.
private def re(regex : String) : Regex
Regex.new(regex, Regex::CompileOptions::MATCH_INVALID_UTF)
end
end
end

0 comments on commit db21adc

Please sign in to comment.