Skip to content

Commit ebf7066

Browse files
authored
SPI & Codecov (#10)
1 parent e132d11 commit ebf7066

5 files changed

Lines changed: 75 additions & 2 deletions

File tree

.github/workflows/pull-request.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
name: Pull request
2-
on: pull_request
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, ready_for_review]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
310

411
env:
512
XCODE_VERSION: "16.3"
@@ -92,6 +99,7 @@ jobs:
9299
- name: Build (SPM)
93100
if: ${{ matrix.platform == 'macos' }}
94101
run: swift build
102+
95103
- name: Build (Xcode)
96104
if: ${{ matrix.platform != 'macos' }}
97105
run: |
@@ -105,7 +113,13 @@ jobs:
105113
if: ${{ matrix.platform == 'macos' }}
106114
run: |
107115
set -o pipefail
108-
swift test | xcbeautify --renderer github-actions
116+
swift test --enable-code-coverage | xcbeautify --renderer github-actions
117+
TEST_BUNDLE=$(find .build/debug/ -name "*.xctest" | head -n 1)
118+
TEST_EXECUTABLE="$TEST_BUNDLE/Contents/MacOS/$(basename "$TEST_BUNDLE" .xctest)"
119+
xcrun llvm-cov export -format="lcov" \
120+
-instr-profile .build/debug/codecov/default.profdata \
121+
"$TEST_EXECUTABLE" > info.lcov
122+
109123
- name: Test (Xcode)
110124
if: ${{ matrix.platform != 'macos' }}
111125
run: |
@@ -114,3 +128,9 @@ jobs:
114128
-scheme ${{ needs.prepare.outputs.scheme }} \
115129
-destination "${{ steps.destination.outputs.destination }}" | \
116130
xcbeautify --renderer github-actions
131+
132+
- name: Check coverage (SPM)
133+
if: ${{ matrix.platform == 'macos' }}
134+
uses: codecov/codecov-action@v5
135+
with:
136+
fail_ci_if_error: true

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Release
2+
23
on:
34
push:
45
tags:

.spi.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 1
2+
builder:
3+
configs:
4+
- documentation_targets:
5+
- Principle
6+
- PrincipleConcurrency
7+
- PrincipleCollections

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Principle
22

33
![Swift](https://img.shields.io/badge/Swift-6.0-EF5239?logo=swift&labelColor=white)
4+
[![Codecov](https://codecov.io/gh/NSFatalError/Principle/graph/badge.svg?token=ITK16CK7NL)](https://codecov.io/gh/NSFatalError/Principle)
45

56
Essential tools that extend the capabilities of Swift Standard Library.
67

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// SingleUseTransferTests.swift
3+
// Principle
4+
//
5+
// Created by Kamil Strzelecki on 28/04/2025.
6+
// Copyright © 2025 Kamil Strzelecki. All rights reserved.
7+
//
8+
9+
@testable import PrincipleConcurrency
10+
import Synchronization
11+
import Testing
12+
13+
internal struct SingleUseTransferTests {
14+
15+
@Test
16+
func testFinalize() {
17+
let mutex = Mutex(NonSendable())
18+
let instance = NonSendable()
19+
var transfer = SingleUseTransfer(instance)
20+
21+
mutex.withLock { protected in
22+
protected = transfer.finalize()
23+
}
24+
}
25+
26+
@Test
27+
func testTake() async {
28+
let instance = NonSendable()
29+
var transfer = SingleUseTransfer(instance)
30+
31+
await withTaskGroup { group in
32+
var transfer = transfer.take()
33+
group.addTask {
34+
_ = transfer.finalize()
35+
}
36+
await group.waitForAll()
37+
}
38+
}
39+
}
40+
41+
extension SingleUseTransferTests {
42+
43+
private final class NonSendable {}
44+
}

0 commit comments

Comments
 (0)