Skip to content

Commit 4041a69

Browse files
authored
Use LCOV code coverage format (#195)
* Use LCOV code coverage format instead of the broken JSON Swift still generates by default
1 parent f876692 commit 4041a69

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,18 @@ jobs:
2323
- name: Check out package
2424
uses: actions/checkout@v2
2525
- name: Run unit tests with code coverage
26+
run: swift test --enable-test-discovery --filter=^PostgresNIOTests --enable-code-coverage
27+
- name: Convert code coverage report to most expressive format
2628
run: |
27-
swift test --enable-test-discovery --filter=^PostgresNIOTests --enable-code-coverage && \
28-
echo "CODECOV_FILE=$(swift test --show-codecov-path)" >> $GITHUB_ENV
29+
export pkgname="$(swift package dump-package | perl -e 'use JSON::PP; print (decode_json(join("",(<>)))->{name});')" \
30+
subpath="$([ "$(uname -s)" = 'Darwin' ] && echo "/Contents/MacOS/${pkgname}PackageTests" || true)" \
31+
exc_prefix="$(which xcrun || true)" && \
32+
${exc_prefix} llvm-cov export -format lcov \
33+
-instr-profile="$(dirname "$(swift test --show-codecov-path)")/default.profdata" \
34+
--ignore-filename-regex='\.build/' \
35+
"$(swift build --show-bin-path)/${pkgname}PackageTests.xctest${subpath}" \
36+
>"${pkgname}.lcov"
37+
echo "CODECOV_FILE=$(pwd)/${pkgname}.lcov" >> $GITHUB_ENV
2938
- name: Send coverage report to codecov.io
3039
uses: codecov/codecov-action@v2
3140
with:

0 commit comments

Comments
 (0)