diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..a1c396fee --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 + \ No newline at end of file diff --git a/.github/workflows/auth.yml b/.github/workflows_disabled/auth.yml similarity index 100% rename from .github/workflows/auth.yml rename to .github/workflows_disabled/auth.yml diff --git a/.github/workflows/functions.yml b/.github/workflows_disabled/functions.yml similarity index 100% rename from .github/workflows/functions.yml rename to .github/workflows_disabled/functions.yml diff --git a/.github/workflows/postgrest.yml b/.github/workflows_disabled/postgrest.yml similarity index 100% rename from .github/workflows/postgrest.yml rename to .github/workflows_disabled/postgrest.yml diff --git a/.github/workflows/realtime.yml b/.github/workflows_disabled/realtime.yml similarity index 100% rename from .github/workflows/realtime.yml rename to .github/workflows_disabled/realtime.yml diff --git a/.github/workflows/storage.yml b/.github/workflows_disabled/storage.yml similarity index 100% rename from .github/workflows/storage.yml rename to .github/workflows_disabled/storage.yml diff --git a/.github/workflows/supabase.yml b/.github/workflows_disabled/supabase.yml similarity index 100% rename from .github/workflows/supabase.yml rename to .github/workflows_disabled/supabase.yml diff --git a/Makefile b/Makefile index 13b29b8bc..e405f8c46 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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 @@ -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)" \ @@ -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 . diff --git a/TestPlans/Supabase.xctestplan b/TestPlans/Supabase.xctestplan index 26944b6ae..7479acbff 100644 --- a/TestPlans/Supabase.xctestplan +++ b/TestPlans/Supabase.xctestplan @@ -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 diff --git a/Tests/AuthTests/SessionManagerTests.swift b/Tests/AuthTests/SessionManagerTests.swift index 73baf9e1e..ff5ceba10 100644 --- a/Tests/AuthTests/SessionManagerTests.swift +++ b/Tests/AuthTests/SessionManagerTests.swift @@ -32,7 +32,6 @@ final class SessionManagerTests: XCTestCase { configuration: .init( url: clientURL, localStorage: InMemoryLocalStorage(), - logger: TestLogger(), autoRefreshToken: false ), http: http, @@ -112,9 +111,3 @@ final class SessionManagerTests: XCTestCase { } } } - -struct TestLogger: SupabaseLogger { - func log(message: SupabaseLogMessage) { - print(message.description) - } -} diff --git a/Tests/IntegrationTests/RealtimeIntegrationTests.swift b/Tests/IntegrationTests/RealtimeIntegrationTests.swift index 07b498247..4b2b543ab 100644 --- a/Tests/IntegrationTests/RealtimeIntegrationTests.swift +++ b/Tests/IntegrationTests/RealtimeIntegrationTests.swift @@ -13,18 +13,11 @@ 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] ) ) @@ -32,8 +25,7 @@ final class RealtimeIntegrationTests: XCTestCase { url: URL(string: "\(DotEnv.SUPABASE_URL)/rest/v1")!, headers: [ "apikey": DotEnv.SUPABASE_ANON_KEY, - ], - logger: Logger() + ] ) override func invokeTest() { diff --git a/Tests/RealtimeTests/RealtimeTests.swift b/Tests/RealtimeTests/RealtimeTests.swift index be91d3843..405fdb37b 100644 --- a/Tests/RealtimeTests/RealtimeTests.swift +++ b/Tests/RealtimeTests/RealtimeTests.swift @@ -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 diff --git a/Tests/StorageTests/SupabaseStorageClient+Test.swift b/Tests/StorageTests/SupabaseStorageClient+Test.swift index 44581fb42..7e819aa63 100644 --- a/Tests/StorageTests/SupabaseStorageClient+Test.swift +++ b/Tests/StorageTests/SupabaseStorageClient+Test.swift @@ -21,8 +21,7 @@ extension SupabaseStorageClient { "Authorization": "Bearer \(apiKey)", "Apikey": apiKey, ], - session: session, - logger: ConsoleLogger() + session: session ) ) }