Skip to content
Merged
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
108 changes: 108 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- '*'
workflow_dispatch:

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
xcodebuild:
name: xcodebuild
runs-on: macos-14
strategy:
matrix:
command: [test, '']
platform: [iOS, macOS, tvOS, watchOS, visionOS, macCatalyst]
xcode: [15.4, '16.0']
steps:
- uses: actions/checkout@v4
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Cache derived data
uses: actions/cache@v3
with:
path: |
~/.derivedData
key: |
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
restore-keys: |
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-
- name: Set IgnoreFileSystemDeviceInodeChanges flag
run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES
- name: Update mtime for incremental builds
uses: chetan/git-restore-mtime-action@v2
- name: Debug
run: make COMMAND="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" xcodebuild
- name: Release
if: matrix.skip_release != '1'
run: make COMMAND="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild

linux:
name: linux
strategy:
matrix:
swift-version: ["5.10"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift-version }}
- name: Cache build
uses: actions/cache@v3
with:
path: |
.build
key: |
build-spm-linux-${{ matrix.swift-verion }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift', '**/Package.resolved') }}
restore-keys: |
build-spm-linux-${{ matrix.swift-verion }}-
- run: make dot-env
- name: Run tests
run: swift test --skip IntegrationTests


# library-evolution:
# name: Library (evolution)
# runs-on: macos-14
# steps:
# - uses: actions/checkout@v4
# - name: Select Xcode 15.4
# run: sudo xcode-select -s /Applications/Xcode_15.4.app
# - name: Build for library evolution
# run: make build-for-library-evolution

examples:
name: Examples
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Cache derived data
uses: actions/cache@v3
with:
path: ~/.derivedData
key: |
deriveddata-examples-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift', '**/Examples/**/*.swift') }}
restore-keys: |
deriveddata-examples-
- name: Select Xcode 16
run: sudo xcode-select -s /Applications/Xcode_16.app
- name: Set IgnoreFileSystemDeviceInodeChanges flag
run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES
- name: Update mtime for incremental builds
uses: chetan/git-restore-mtime-action@v2
- name: Examples
run: make SCHEME="Examples" build-example
- name: SlackClone
run: make SCHEME="SlackClone" build-example
- name: UserManagement
run: make SCHEME="UserManagement" build-example

File renamed without changes.
97 changes: 70 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
CONFIG = debug
PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS 17.5,iPhone \d\+ Pro [^M])
PLATFORM = iOS
PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS,iPhone \d\+ Pro [^M])
PLATFORM_MACOS = macOS
PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst
PLATFORM_TVOS = tvOS Simulator,id=$(call udid_for,tvOS 17.5,TV)
PLATFORM_VISIONOS = visionOS Simulator,id=$(call udid_for,visionOS 1.2,Vision)
PLATFORM_WATCHOS = watchOS Simulator,id=$(call udid_for,watchOS 10.5,Watch)

SCHEME ?= Supabase
PLATFORM ?= $(PLATFORM_IOS)
PLATFORM_TVOS = tvOS Simulator,id=$(call udid_for,tvOS,TV)
PLATFORM_VISIONOS = visionOS Simulator,id=$(call udid_for,visionOS,Vision)
PLATFORM_WATCHOS = watchOS Simulator,id=$(call udid_for,watchOS,Watch)

export SECRETS
define SECRETS
Expand All @@ -18,6 +16,64 @@ enum DotEnv {
}
endef

default: test-all

test-all:
$(MAKE) CONFIG=debug test-library
$(MAKE) CONFIG=release test-library

xcodebuild:
if test "$(PLATFORM)" = "iOS"; \
then xcodebuild $(COMMAND) \
-skipMacroValidation \
-configuration $(CONFIG) \
-workspace Supabase.xcworkspace \
-scheme Supabase \
-destination platform="$(PLATFORM_IOS)" \
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
elif test "$(PLATFORM)" = "macOS"; \
then xcodebuild $(COMMAND) \
-skipMacroValidation \
-configuration $(CONFIG) \
-workspace Supabase.xcworkspace \
-scheme Supabase \
-destination platform="$(PLATFORM_MACOS)" \
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
elif test "$(PLATFORM)" = "tvOS"; \
then xcodebuild $(COMMAND) \
-skipMacroValidation \
-configuration $(CONFIG) \
-workspace Supabase.xcworkspace \
-scheme Supabase \
-destination platform="$(PLATFORM_TVOS)" \
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
elif test "$(PLATFORM)" = "watchOS"; \
then xcodebuild $(COMMAND) \
-skipMacroValidation \
-configuration $(CONFIG) \
-workspace Supabase.xcworkspace \
-scheme Supabase \
-destination platform="$(PLATFORM_WATCHOS)" \
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
elif test "$(PLATFORM)" = "visionOS"; \
then xcodebuild $(COMMAND) \
-skipMacroValidation \
-configuration $(CONFIG) \
-workspace Supabase.xcworkspace \
-scheme Supabase \
-destination platform="$(PLATFORM_VISIONOS)" \
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
elif test "$(PLATFORM)" = "macCatalyst"; \
then xcodebuild $(COMMAND) \
-skipMacroValidation \
-configuration $(CONFIG) \
-workspace Supabase.xcworkspace \
-scheme Supabase \
-destination platform="$(PLATFORM_MAC_CATALYST)" \
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
else exit 1; \
fi;

load-env:
@. ./scripts/load_env.sh

Expand All @@ -36,16 +92,6 @@ build-all-platforms:
-destination platform="$$platform" | xcpretty || exit 1; \
done

test-library: dot-env
for platform in "$(PLATFORM_IOS)" "$(PLATFORM_MACOS)" "$(PLATFORM_MAC_CATALYST)" "$(PLATFORM_TVOS)" "$(PLATFORM_VISIONOS)" "$(PLATFORM_WATCHOS)"; do \
xcodebuild test \
-skipMacroValidation \
-configuration "$(CONFIG)" \
-workspace Supabase.xcworkspace \
-scheme "$(SCHEME)" \
-destination platform="$$platform" | xcpretty || exit 1; \
done

test-auth:
$(MAKE) SCHEME=Auth test-library

Expand Down Expand Up @@ -82,7 +128,6 @@ build-for-library-evolution:
-Xswiftc -emit-module-interface \
-Xswiftc -enable-library-evolution


DOC_WARNINGS = $(shell xcodebuild clean docbuild \
-scheme Supabase \
-destination platform="$(PLATFORM_MACOS)" \
Expand All @@ -96,15 +141,13 @@ test-docs:
|| (echo "xcodebuild docbuild failed:\n\n$(DOC_WARNINGS)" | tr '\1' '\n' \
&& exit 1)

build-examples:
for scheme in Examples UserManagement SlackClone; do \
set -o pipefail && \
xcodebuild build \
-skipMacroValidation \
-workspace Supabase.xcworkspace \
-scheme "$$scheme" \
-destination platform="$(PLATFORM_IOS)" | xcpretty; \
done
build-example:
xcodebuild build \
-skipMacroValidation \
-workspace Supabase.xcworkspace \
-scheme "$(SCHEME)" \
-destination platform="$(PLATFORM_IOS)" \
-derivedDataPath ~/.derivedData | xcpretty;

format:
@swiftformat .
Expand Down
42 changes: 42 additions & 0 deletions TestPlans/Supabase.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,54 @@

},
"testTargets" : [
{
"target" : {
"containerPath" : "container:",
"identifier" : "AuthTests",
"name" : "AuthTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "HelpersTests",
"name" : "HelpersTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "SupabaseTests",
"name" : "SupabaseTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "StorageTests",
"name" : "StorageTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "PostgRESTTests",
"name" : "PostgRESTTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "FunctionsTests",
"name" : "FunctionsTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "RealtimeTests",
"name" : "RealtimeTests"
}
}
],
"version" : 1
Expand Down
7 changes: 0 additions & 7 deletions Tests/AuthTests/SessionManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ final class SessionManagerTests: XCTestCase {
configuration: .init(
url: clientURL,
localStorage: InMemoryLocalStorage(),
logger: TestLogger(),
autoRefreshToken: false
),
http: http,
Expand Down Expand Up @@ -112,9 +111,3 @@ final class SessionManagerTests: XCTestCase {
}
}
}

struct TestLogger: SupabaseLogger {
func log(message: SupabaseLogMessage) {
print(message.description)
}
}
12 changes: 2 additions & 10 deletions Tests/IntegrationTests/RealtimeIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,19 @@ import Supabase
import TestHelpers
import XCTest

struct Logger: SupabaseLogger {
func log(message: SupabaseLogMessage) {
print(message.description)
}
}

final class RealtimeIntegrationTests: XCTestCase {
let realtime = RealtimeClientV2(
url: URL(string: "\(DotEnv.SUPABASE_URL)/realtime/v1")!,
options: RealtimeClientOptions(
headers: ["apikey": DotEnv.SUPABASE_ANON_KEY],
logger: Logger()
headers: ["apikey": DotEnv.SUPABASE_ANON_KEY]
)
)

let db = PostgrestClient(
url: URL(string: "\(DotEnv.SUPABASE_URL)/rest/v1")!,
headers: [
"apikey": DotEnv.SUPABASE_ANON_KEY,
],
logger: Logger()
]
)

override func invokeTest() {
Expand Down
3 changes: 1 addition & 2 deletions Tests/RealtimeTests/RealtimeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ final class RealtimeTests: XCTestCase {
headers: ["apikey": apiKey],
heartbeatInterval: 1,
reconnectDelay: 1,
timeoutInterval: 2,
logger: TestLogger()
timeoutInterval: 2
),
ws: ws,
http: http
Expand Down
3 changes: 1 addition & 2 deletions Tests/StorageTests/SupabaseStorageClient+Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ extension SupabaseStorageClient {
"Authorization": "Bearer \(apiKey)",
"Apikey": apiKey,
],
session: session,
logger: ConsoleLogger()
session: session
)
)
}
Expand Down
Loading