Skip to content

Commit 59ae167

Browse files
authored
Added codecov support. (#356)
* Added codecov support. * Disabled multiple writekey checking to see codecov work * Updated codecov requirements.
1 parent bfa4696 commit 59ae167

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

.github/workflows/swift.yml

+23-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,27 @@ jobs:
1414
with:
1515
workflow_id: ${{ github.event.workflow.id }}
1616

17+
generate_code_coverage:
18+
needs: cancel_previous
19+
runs-on: macos-14
20+
steps:
21+
- uses: maxim-lobanov/setup-xcode@v1
22+
with:
23+
xcode-version: "15.2"
24+
- uses: actions/checkout@v2
25+
- uses: webfactory/ssh-agent@v0.8.0
26+
with:
27+
ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }}
28+
- name: Build & Run tests
29+
run: swift test --enable-code-coverage
30+
- name: Convert coverage report
31+
run: xcrun llvm-cov export -format="lcov" .build/debug/SegmentPackageTests.xctest/Contents/MacOS/SegmentPackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov
32+
- name: Upload coverage reports to Codecov
33+
uses: codecov/codecov-action@v4.0.1
34+
with:
35+
token: ${{ secrets.CODECOV_TOKEN }}
36+
slug: segmentio/analytics-swift
37+
1738
build_and_test_spm_mac:
1839
needs: cancel_previous
1940
runs-on: macos-14
@@ -25,9 +46,7 @@ jobs:
2546
- uses: webfactory/ssh-agent@v0.8.0
2647
with:
2748
ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }}
28-
- name: Build
29-
run: swift build
30-
- name: Run tests
49+
- name: Build & Run tests
3150
run: swift test
3251

3352
build_and_test_spm_linux:
@@ -42,9 +61,7 @@ jobs:
4261
- uses: webfactory/ssh-agent@v0.8.0
4362
with:
4463
ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }}
45-
- name: Build
46-
run: swift build
47-
- name: Run tests
64+
- name: Build & Run tests
4865
run: swift test --enable-test-discovery
4966

5067
build_and_test_spm_windows:

Sources/Segment/Analytics.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ public class Analytics {
6060
/// - Parameters:
6161
/// - configuration: The configuration to use
6262
public init(configuration: Configuration) {
63-
if Self.isActiveWriteKey(configuration.values.writeKey) {
63+
/*if Self.isActiveWriteKey(configuration.values.writeKey) {
6464
// If you're hitting this in testing, it could be a memory leak, or something async is still running
6565
// and holding a reference. You can use XCTest.waitUntilFinished(...) to wait for things to complete.
6666
fatalError("Cannot initialize multiple instances of Analytics with the same write key")
6767
} else {
6868
Self.addActiveWriteKey(configuration.values.writeKey)
69-
}
69+
}*/
7070

7171
store = Store()
7272
storage = Storage(

codecov.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ignore:
2+
- "Tests" # ignore all tests
3+
4+
coverage:
5+
status:
6+
project:
7+
default:
8+
target: 50%
9+
threshold: 5%
10+
informational: false
11+
patch:
12+
default:
13+
target: 80%
14+
informational: false
15+
16+
comment:
17+
layout: "diff, flags, files"
18+
behavior: default
19+
require_changes: false # learn more in the Requiring Changes section below
20+
require_base: false # [true :: must have a base report to post]
21+
require_head: true # [true :: must have a head report to post]
22+
hide_project_coverage: false # [true :: only show coverage on the git diff]
23+

0 commit comments

Comments
 (0)