Skip to content

Commit d35111b

Browse files
authored
ci: enable linux test coverage (#856)
* ci: test in Linux * keep only linux job * import FoundationNetworking * fix tests in Linux * fix(realtime): stabilize channel tests on ci * test(realtime): disable flaky realtime tests on linux * revert CI to run all jobs * fix test * run tests in parallel and comment out flaky test * ci: add caches * disable parallel tests
1 parent bab4ec0 commit d35111b

File tree

10 files changed

+914
-739
lines changed

10 files changed

+914
-739
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@ on:
66
- main
77
- release/*
88
paths:
9-
- 'Sources/**'
10-
- 'Tests/**'
11-
- 'Examples/**'
12-
- '*.swift'
13-
- 'Package.swift'
14-
- 'Package.resolved'
15-
- '.github/workflows/ci.yml'
16-
- 'Makefile'
17-
- '*.xcodeproj/**'
18-
- '*.xcworkspace/**'
19-
- '.swiftpm/**'
9+
- "Sources/**"
10+
- "Tests/**"
11+
- "Examples/**"
12+
- "*.swift"
13+
- "Package.swift"
14+
- "Package.resolved"
15+
- ".github/workflows/ci.yml"
16+
- "Makefile"
17+
- "*.xcodeproj/**"
18+
- "*.xcworkspace/**"
19+
- ".swiftpm/**"
2020
pull_request:
2121
branches:
2222
- "*"
2323
- release/*
2424
paths:
25-
- 'Sources/**'
26-
- 'Tests/**'
27-
- 'Examples/**'
28-
- '*.swift'
29-
- 'Package.swift'
30-
- 'Package.resolved'
31-
- '.github/workflows/ci.yml'
32-
- 'Makefile'
33-
- '*.xcodeproj/**'
34-
- '*.xcworkspace/**'
35-
- '.swiftpm/**'
25+
- "Sources/**"
26+
- "Tests/**"
27+
- "Examples/**"
28+
- "*.swift"
29+
- "Package.swift"
30+
- "Package.resolved"
31+
- ".github/workflows/ci.yml"
32+
- "Makefile"
33+
- "*.xcodeproj/**"
34+
- "*.xcworkspace/**"
35+
- ".swiftpm/**"
3636
workflow_dispatch:
3737

3838
concurrency:
@@ -55,6 +55,14 @@ jobs:
5555
- { command: test, skip_release: 1 }
5656
steps:
5757
- uses: actions/checkout@v5
58+
- name: Cache derived data
59+
uses: actions/cache@v4
60+
with:
61+
path: ~/.derivedData
62+
key: |
63+
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
64+
restore-keys: |
65+
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-
5866
- name: Select Xcode ${{ matrix.xcode }}
5967
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
6068
- name: List available devices
@@ -119,7 +127,7 @@ jobs:
119127
spm:
120128
runs-on: macos-15
121129
strategy:
122-
matrix:
130+
matrix:
123131
config: [debug, release]
124132
steps:
125133
- uses: actions/checkout@v5
@@ -136,11 +144,18 @@ jobs:
136144
runs-on: ubuntu-latest
137145
steps:
138146
- uses: actions/checkout@v5
139-
- name: "Remove IntegrationTests"
140-
run: rm -r Tests/IntegrationTests/*
147+
- name: "Cache Swift Package"
148+
uses: actions/cache@v4
149+
with:
150+
path: .build
151+
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
152+
restore-keys: |
153+
${{ runner.os }}-spm-
141154
- name: "Build Swift Package"
142155
run: swift build
143-
156+
- name: "Test Swift Package"
157+
run: swift test --skip IntegrationTests
158+
144159
# android:
145160
# name: Android
146161
# runs-on: ubuntu-latest
@@ -164,6 +179,14 @@ jobs:
164179
xcode: ["16.3"]
165180
steps:
166181
- uses: actions/checkout@v5
182+
- name: Cache derived data
183+
uses: actions/cache@v4
184+
with:
185+
path: ~/.derivedData
186+
key: |
187+
deriveddata-library-evolution-${{ matrix.xcode }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
188+
restore-keys: |
189+
deriveddata-library-evolution-${{ matrix.xcode }}-
167190
- name: Select Xcode ${{ matrix.xcode }}
168191
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
169192
- name: Build for library evolution
@@ -200,5 +223,13 @@ jobs:
200223
runs-on: macos-15
201224
steps:
202225
- uses: actions/checkout@v5
226+
- name: Cache Swift build
227+
uses: actions/cache@v4
228+
with:
229+
path: .build
230+
key: |
231+
docs-${{ runner.os }}-${{ hashFiles('**/Package.resolved') }}
232+
restore-keys: |
233+
docs-${{ runner.os }}-
203234
- name: Test docs
204235
run: make test-docs

Sources/Storage/MultipartFormData.swift

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,17 @@ class MultipartFormData {
419419
var buffer = [UInt8](repeating: 0, count: streamBufferSize)
420420
let bytesRead = inputStream.read(&buffer, maxLength: streamBufferSize)
421421

422-
if let error = inputStream.streamError {
423-
throw MultipartFormDataError.inputStreamReadFailed(error: error)
422+
if bytesRead < 0 {
423+
if let error = inputStream.streamError {
424+
throw MultipartFormDataError.inputStreamReadFailed(error: error)
425+
} else {
426+
throw MultipartFormDataError.inputStreamReadFailed(
427+
error: MultipartFormDataError.UnexpectedInputStreamLength(
428+
bytesExpected: bodyPart.bodyContentLength,
429+
bytesRead: UInt64(encoded.count)
430+
)
431+
)
432+
}
424433
}
425434

426435
if bytesRead > 0 {
@@ -474,9 +483,17 @@ class MultipartFormData {
474483
let bufferSize = min(streamBufferSize, Int(bytesLeftToRead))
475484
var buffer = [UInt8](repeating: 0, count: bufferSize)
476485
let bytesRead = inputStream.read(&buffer, maxLength: bufferSize)
477-
478-
if let streamError = inputStream.streamError {
479-
throw MultipartFormDataError.inputStreamReadFailed(error: streamError)
486+
if bytesRead < 0 {
487+
if let streamError = inputStream.streamError {
488+
throw MultipartFormDataError.inputStreamReadFailed(error: streamError)
489+
} else {
490+
throw MultipartFormDataError.inputStreamReadFailed(
491+
error: MultipartFormDataError.UnexpectedInputStreamLength(
492+
bytesExpected: bodyPart.bodyContentLength,
493+
bytesRead: bodyPart.bodyContentLength - bytesLeftToRead
494+
)
495+
)
496+
}
480497
}
481498

482499
if bytesRead > 0 {
@@ -514,8 +531,17 @@ class MultipartFormData {
514531
while bytesToWrite > 0, outputStream.hasSpaceAvailable {
515532
let bytesWritten = outputStream.write(buffer, maxLength: bytesToWrite)
516533

517-
if let error = outputStream.streamError {
518-
throw MultipartFormDataError.outputStreamWriteFailed(error: error)
534+
if bytesWritten < 0 {
535+
if let error = outputStream.streamError {
536+
throw MultipartFormDataError.outputStreamWriteFailed(error: error)
537+
} else {
538+
throw MultipartFormDataError.outputStreamWriteFailed(
539+
error: MultipartFormDataError.UnexpectedInputStreamLength(
540+
bytesExpected: UInt64(buffer.count),
541+
bytesRead: UInt64(buffer.count - bytesToWrite)
542+
)
543+
)
544+
}
519545
}
520546

521547
bytesToWrite -= bytesWritten
@@ -650,10 +676,10 @@ enum MultipartFormDataError: Error {
650676

651677
var underlyingError: (any Error)? {
652678
switch self {
653-
case let .bodyPartFileNotReachableWithError(_, error),
654-
let .bodyPartFileSizeQueryFailedWithError(_, error),
655-
let .inputStreamReadFailed(error),
656-
let .outputStreamWriteFailed(error):
679+
case .bodyPartFileNotReachableWithError(_, let error),
680+
.bodyPartFileSizeQueryFailedWithError(_, let error),
681+
.inputStreamReadFailed(let error),
682+
.outputStreamWriteFailed(let error):
657683
error
658684

659685
case .bodyPartURLInvalid,
@@ -671,17 +697,17 @@ enum MultipartFormDataError: Error {
671697

672698
var url: URL? {
673699
switch self {
674-
case let .bodyPartURLInvalid(url),
675-
let .bodyPartFilenameInvalid(url),
676-
let .bodyPartFileNotReachable(url),
677-
let .bodyPartFileNotReachableWithError(url, _),
678-
let .bodyPartFileIsDirectory(url),
679-
let .bodyPartFileSizeNotAvailable(url),
680-
let .bodyPartFileSizeQueryFailedWithError(url, _),
681-
let .bodyPartInputStreamCreationFailed(url),
682-
let .outputStreamFileAlreadyExists(url),
683-
let .outputStreamURLInvalid(url),
684-
let .outputStreamCreationFailed(url):
700+
case .bodyPartURLInvalid(let url),
701+
.bodyPartFilenameInvalid(let url),
702+
.bodyPartFileNotReachable(let url),
703+
.bodyPartFileNotReachableWithError(let url, _),
704+
.bodyPartFileIsDirectory(let url),
705+
.bodyPartFileSizeNotAvailable(let url),
706+
.bodyPartFileSizeQueryFailedWithError(let url, _),
707+
.bodyPartInputStreamCreationFailed(let url),
708+
.outputStreamFileAlreadyExists(let url),
709+
.outputStreamURLInvalid(let url),
710+
.outputStreamCreationFailed(let url):
685711
url
686712

687713
case .inputStreamReadFailed, .outputStreamWriteFailed:

Supabase.xcworkspace/xcshareddata/xcschemes/Supabase.xcscheme

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@
145145
</CodeCoverageTargets>
146146
<Testables>
147147
<TestableReference
148-
skipped = "NO">
148+
skipped = "NO"
149+
parallelizable = "NO">
149150
<BuildableReference
150151
BuildableIdentifier = "primary"
151152
BlueprintIdentifier = "AuthTests"
@@ -155,7 +156,8 @@
155156
</BuildableReference>
156157
</TestableReference>
157158
<TestableReference
158-
skipped = "NO">
159+
skipped = "NO"
160+
parallelizable = "NO">
159161
<BuildableReference
160162
BuildableIdentifier = "primary"
161163
BlueprintIdentifier = "FunctionsTests"
@@ -165,7 +167,8 @@
165167
</BuildableReference>
166168
</TestableReference>
167169
<TestableReference
168-
skipped = "NO">
170+
skipped = "NO"
171+
parallelizable = "NO">
169172
<BuildableReference
170173
BuildableIdentifier = "primary"
171174
BlueprintIdentifier = "HelpersTests"
@@ -175,7 +178,8 @@
175178
</BuildableReference>
176179
</TestableReference>
177180
<TestableReference
178-
skipped = "NO">
181+
skipped = "NO"
182+
parallelizable = "NO">
179183
<BuildableReference
180184
BuildableIdentifier = "primary"
181185
BlueprintIdentifier = "PostgRESTTests"
@@ -185,7 +189,8 @@
185189
</BuildableReference>
186190
</TestableReference>
187191
<TestableReference
188-
skipped = "NO">
192+
skipped = "NO"
193+
parallelizable = "NO">
189194
<BuildableReference
190195
BuildableIdentifier = "primary"
191196
BlueprintIdentifier = "RealtimeTests"
@@ -195,7 +200,8 @@
195200
</BuildableReference>
196201
</TestableReference>
197202
<TestableReference
198-
skipped = "NO">
203+
skipped = "NO"
204+
parallelizable = "NO">
199205
<BuildableReference
200206
BuildableIdentifier = "primary"
201207
BlueprintIdentifier = "StorageTests"
@@ -205,7 +211,8 @@
205211
</BuildableReference>
206212
</TestableReference>
207213
<TestableReference
208-
skipped = "NO">
214+
skipped = "NO"
215+
parallelizable = "NO">
209216
<BuildableReference
210217
BuildableIdentifier = "primary"
211218
BlueprintIdentifier = "SupabaseTests"

0 commit comments

Comments
 (0)