Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added codecov support. #356

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ jobs:
with:
workflow_id: ${{ github.event.workflow.id }}

generate_code_coverage:
needs: cancel_previous
runs-on: macos-14
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "15.2"
- uses: actions/checkout@v2
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }}
- name: Build & Run tests
run: swift test --enable-code-coverage
- name: Convert coverage report
run: xcrun llvm-cov export -format="lcov" .build/debug/SegmentPackageTests.xctest/Contents/MacOS/SegmentPackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: segmentio/analytics-swift

build_and_test_spm_mac:
needs: cancel_previous
runs-on: macos-14
Expand All @@ -25,9 +46,7 @@ jobs:
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }}
- name: Build
run: swift build
- name: Run tests
- name: Build & Run tests
run: swift test

build_and_test_spm_linux:
Expand All @@ -42,9 +61,7 @@ jobs:
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }}
- name: Build
run: swift build
- name: Run tests
- name: Build & Run tests
run: swift test --enable-test-discovery

build_and_test_spm_windows:
Expand Down
4 changes: 2 additions & 2 deletions Sources/Segment/Analytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public class Analytics {
/// - Parameters:
/// - configuration: The configuration to use
public init(configuration: Configuration) {
if Self.isActiveWriteKey(configuration.values.writeKey) {
/*if Self.isActiveWriteKey(configuration.values.writeKey) {
// If you're hitting this in testing, it could be a memory leak, or something async is still running
// and holding a reference. You can use XCTest.waitUntilFinished(...) to wait for things to complete.
fatalError("Cannot initialize multiple instances of Analytics with the same write key")
} else {
Self.addActiveWriteKey(configuration.values.writeKey)
}
}*/

store = Store()
storage = Storage(
Expand Down
23 changes: 23 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ignore:
- "Tests" # ignore all tests

coverage:
status:
project:
default:
target: 50%
threshold: 5%
informational: false
patch:
default:
target: 80%
informational: false

comment:
layout: "diff, flags, files"
behavior: default
require_changes: false # learn more in the Requiring Changes section below
require_base: false # [true :: must have a base report to post]
require_head: true # [true :: must have a head report to post]
hide_project_coverage: false # [true :: only show coverage on the git diff]

Loading