Skip to content

Commit f5d783c

Browse files
committed
Add Codecov badge and upload LCOV coverage
1 parent 2b8695d commit f5d783c

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

.github/workflows/swift.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,21 @@ jobs:
2626
run: swift build -v
2727
- name: Test with coverage
2828
run: swift test --enable-code-coverage -v
29-
- name: Coverage path
29+
- name: Export LCOV
3030
id: coverage
31-
run: echo "path=$(swift test --show-codecov-path)" >> "$GITHUB_OUTPUT"
31+
run: |
32+
COVERAGE_PATH="$(swift test --show-codecov-path)"
33+
CODECOV_DIR="$(dirname "$COVERAGE_PATH")"
34+
BIN_PATH="$(swift build --show-bin-path)"
35+
TEST_BINARY="$BIN_PATH/SwiftNEWPackageTests.xctest/Contents/MacOS/SwiftNEWPackageTests"
36+
37+
xcrun llvm-cov export "$TEST_BINARY" \
38+
-instr-profile "$CODECOV_DIR/default.profdata" \
39+
-format=lcov \
40+
-ignore-filename-regex='/.build/|/Tests/' \
41+
| sed "s#SF:$PWD/#SF:#" > coverage.lcov
42+
43+
echo "path=coverage.lcov" >> "$GITHUB_OUTPUT"
3244
- name: Upload coverage to Codecov
3345
uses: codecov/codecov-action@v6
3446
with:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
![Stable](https://img.shields.io/github/v/release/1998code/SwiftNEWKit?color=03A791&label=Stable)
66
![Beta](https://img.shields.io/github/v/release/1998code/SwiftNEWKit?include_prereleases&color=3A59D1&label=Beta)
77
[![Validate JSON Files](https://github.com/1998code/SwiftNEWKit/actions/workflows/validate-json.yml/badge.svg)](https://github.com/1998code/SwiftNEWKit/actions/workflows/validate-json.yml)
8+
[![codecov](https://codecov.io/github/1998code/SwiftNEWKit/branch/main/graph/badge.svg?token=GI0KRUHVH1)](https://codecov.io/github/1998code/SwiftNEWKit)
89
![Swift Version](https://img.shields.io/badge/Swift-5.9/6.1-teal.svg)
910
![Platforms](https://img.shields.io/badge/Platforms-iOS%2015.0+%20|%20macOS%2014.0+%20|%20tvOS%2017.0+%20|%20visionOS%201.0+-15437D.svg)
1011
![License](https://img.shields.io/badge/License-MIT-C8ECFE.svg)

0 commit comments

Comments
 (0)