diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1c396fe..517eff3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: - main pull_request: branches: - - '*' + - "*" workflow_dispatch: concurrency: @@ -19,13 +19,24 @@ jobs: runs-on: macos-14 strategy: matrix: - command: [test, ''] - platform: [iOS, macOS, tvOS, watchOS, visionOS, macCatalyst] - xcode: [15.4, '16.0'] + command: [test, ""] + platform: [IOS, MAC_CATALYST, MACOS, TVOS, VISIONOS, WATCHOS] + xcode: [15.4, "16.0"] + include: + - { command: test, skip_release: 1 } steps: - uses: actions/checkout@v4 - name: Select Xcode ${{ matrix.xcode }} run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app + - name: Install visionOS runtime + if: matrix.platform == 'visionOS' + run: | + sudo xcodebuild -runFirstLaunch + sudo xcrun simctl list + sudo xcodebuild -downloadPlatform visionOS + sudo xcodebuild -runFirstLaunch + - name: List available devices + run: xcrun simctl list devices available - name: Cache derived data uses: actions/cache@v3 with: @@ -35,15 +46,16 @@ jobs: 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 + - name: Set IgnoreFileSystemDeviceInodeChanges flag run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES - - name: Update mtime for incremental builds + - name: Update mtime for incremental builds uses: chetan/git-restore-mtime-action@v2 + - run: make dot-env - name: Debug - run: make COMMAND="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" xcodebuild + run: make XCODEBUILD_ARGUMENT="${{ 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 + run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild linux: name: linux @@ -69,7 +81,6 @@ jobs: - name: Run tests run: swift test --skip IntegrationTests - # library-evolution: # name: Library (evolution) # runs-on: macos-14 @@ -100,9 +111,8 @@ jobs: - name: Update mtime for incremental builds uses: chetan/git-restore-mtime-action@v2 - name: Examples - run: make SCHEME="Examples" build-example + run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="Examples" XCODEBUILD_ARGUMENT=build xcodebuild - name: SlackClone - run: make SCHEME="SlackClone" build-example + run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="SlackClone" XCODEBUILD_ARGUMENT=build xcodebuild - name: UserManagement - run: make SCHEME="UserManagement" build-example - \ No newline at end of file + run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="UserManagement" XCODEBUILD_ARGUMENT=build xcodebuild diff --git a/Examples/Examples.xcodeproj/project.pbxproj b/Examples/Examples.xcodeproj/project.pbxproj index 787af0c1..4a19d2bf 100644 --- a/Examples/Examples.xcodeproj/project.pbxproj +++ b/Examples/Examples.xcodeproj/project.pbxproj @@ -20,7 +20,7 @@ 794C61D62BAD1E12000E6B0F /* UserIdentityList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794C61D52BAD1E12000E6B0F /* UserIdentityList.swift */; }; 794EF1222955F26A008C9526 /* AddTodoListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794EF1212955F26A008C9526 /* AddTodoListView.swift */; }; 794EF1242955F3DE008C9526 /* TodoListRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794EF1232955F3DE008C9526 /* TodoListRow.swift */; }; - 7956405E2954ADE00088A06F /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7956405D2954ADE00088A06F /* Secrets.swift */; }; + 7956405E2954ADE00088A06F /* SupabaseConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7956405D2954ADE00088A06F /* SupabaseConfig.swift */; }; 795640602954AE140088A06F /* AuthController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7956405F2954AE140088A06F /* AuthController.swift */; }; 795640622955AD2B0088A06F /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 795640612955AD2B0088A06F /* HomeView.swift */; }; 795640662955AE9C0088A06F /* TodoListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 795640652955AE9C0088A06F /* TodoListView.swift */; }; @@ -75,6 +75,7 @@ 79FEFFC52B078D7900D36347 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC42B078D7900D36347 /* Models.swift */; }; 79FEFFC72B078FB000D36347 /* SwiftUIHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC62B078FB000D36347 /* SwiftUIHelpers.swift */; }; 79FEFFC92B0797F600D36347 /* AvatarImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC82B0797F600D36347 /* AvatarImage.swift */; }; + 79FFA5B32CC04F8B00F8A807 /* Supabase.plist in Resources */ = {isa = PBXBuildFile; fileRef = 79FFA5B22CC04F8B00F8A807 /* Supabase.plist */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -93,7 +94,7 @@ 794C61D52BAD1E12000E6B0F /* UserIdentityList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserIdentityList.swift; sourceTree = ""; }; 794EF1212955F26A008C9526 /* AddTodoListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTodoListView.swift; sourceTree = ""; }; 794EF1232955F3DE008C9526 /* TodoListRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoListRow.swift; sourceTree = ""; }; - 7956405D2954ADE00088A06F /* Secrets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Secrets.swift; sourceTree = ""; }; + 7956405D2954ADE00088A06F /* SupabaseConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupabaseConfig.swift; sourceTree = ""; }; 7956405F2954AE140088A06F /* AuthController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthController.swift; sourceTree = ""; }; 795640612955AD2B0088A06F /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; 795640652955AE9C0088A06F /* TodoListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoListView.swift; sourceTree = ""; }; @@ -146,6 +147,7 @@ 79FEFFC42B078D7900D36347 /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = ""; }; 79FEFFC62B078FB000D36347 /* SwiftUIHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIHelpers.swift; sourceTree = ""; }; 79FEFFC82B0797F600D36347 /* AvatarImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarImage.swift; sourceTree = ""; }; + 79FFA5B22CC04F8B00F8A807 /* Supabase.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Supabase.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -215,7 +217,7 @@ 793895C92954ABFF0044F2B8 /* ExamplesApp.swift */, 793895D02954AC000044F2B8 /* Preview Content */, 793895CB2954ABFF0044F2B8 /* RootView.swift */, - 7956405D2954ADE00088A06F /* Secrets.swift */, + 7956405D2954ADE00088A06F /* SupabaseConfig.swift */, 795640612955AD2B0088A06F /* HomeView.swift */, 795640652955AE9C0088A06F /* TodoListView.swift */, 795640672955AEB30088A06F /* Models.swift */, @@ -230,6 +232,7 @@ 797EFB672BABD90500098D6B /* Stringfy.swift */, 79B1C80D2BAC017C00D991AA /* AnyJSONView.swift */, 79401F342BC708C8004C9C0F /* UIViewControllerWrapper.swift */, + 79FFA5B22CC04F8B00F8A807 /* Supabase.plist */, ); path = Examples; sourceTree = ""; @@ -465,6 +468,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 79FFA5B32CC04F8B00F8A807 /* Supabase.plist in Resources */, 793895D22954AC000044F2B8 /* Preview Assets.xcassets in Resources */, 793895CE2954AC000044F2B8 /* Assets.xcassets in Resources */, ); @@ -514,7 +518,7 @@ 79E2B55C2B97A2310042CD21 /* UIApplicationExtensions.swift in Sources */, 794EF1222955F26A008C9526 /* AddTodoListView.swift in Sources */, 7928145D2CAB2CE2000B4ADB /* ResetPasswordView.swift in Sources */, - 7956405E2954ADE00088A06F /* Secrets.swift in Sources */, + 7956405E2954ADE00088A06F /* SupabaseConfig.swift in Sources */, 795640682955AEB30088A06F /* Models.swift in Sources */, 79B1C80C2BABFF8000D991AA /* ProfileView.swift in Sources */, 795640662955AE9C0088A06F /* TodoListView.swift in Sources */, diff --git a/Examples/Examples/ExamplesApp.swift b/Examples/Examples/ExamplesApp.swift index 948a293a..e38c80c2 100644 --- a/Examples/Examples/ExamplesApp.swift +++ b/Examples/Examples/ExamplesApp.swift @@ -23,8 +23,8 @@ struct ExamplesApp: App { } let supabase = SupabaseClient( - supabaseURL: Secrets.supabaseURL, - supabaseKey: Secrets.supabaseAnonKey, + supabaseURL: URL(string: SupabaseConfig["SUPABASE_URL"]!)!, + supabaseKey: SupabaseConfig["SUPABASE_ANON_KEY"]!, options: .init( auth: .init(redirectToURL: Constants.redirectToURL), global: .init( diff --git a/Examples/Examples/Supabase.plist b/Examples/Examples/Supabase.plist new file mode 100644 index 00000000..bd7700ca --- /dev/null +++ b/Examples/Examples/Supabase.plist @@ -0,0 +1,10 @@ + + + + + SUPABASE_URL + http://127.0.0.1:54321 + SUPABASE_ANON_KEY + eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0 + + diff --git a/Examples/Examples/SupabaseConfig.swift b/Examples/Examples/SupabaseConfig.swift new file mode 100644 index 00000000..7653cbb1 --- /dev/null +++ b/Examples/Examples/SupabaseConfig.swift @@ -0,0 +1,13 @@ +import Foundation + +enum SupabaseConfig { + static subscript(key: String) -> String? { + guard let plistFileURL = Bundle.main.url(forResource: "Supabase", withExtension: "plist"), + let plistData = try? Data(contentsOf: plistFileURL), + let plist = try? PropertyListSerialization.propertyList(from: plistData, format: nil) + as? [String: Any] + else { return nil } + + return plist[key] as? String + } +} diff --git a/Examples/Examples/_Secrets.swift b/Examples/Examples/_Secrets.swift deleted file mode 100644 index b65997d2..00000000 --- a/Examples/Examples/_Secrets.swift +++ /dev/null @@ -1,6 +0,0 @@ -import Foundation - -enum Secrets { - static let supabaseURL = URL(string: "http://localhost:54321")! - static let supabaseAnonKey = "SUPABASE_ANON_KEY" -} diff --git a/Makefile b/Makefile index f4e8f16e..4961c1b4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ -CONFIG = debug -PLATFORM = iOS +CONFIG = Debug + +DERIVED_DATA_PATH = ~/.derivedData/$(CONFIG) + PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS,iPhone \d\+ Pro [^M]) PLATFORM_MACOS = macOS PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst @@ -7,6 +9,34 @@ 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) + +PLATFORM = IOS +DESTINATION = platform="$(PLATFORM_$(PLATFORM))" + +SCHEME = Supabase + +WORKSPACE = Supabase.xcworkspace + +XCODEBUILD_ARGUMENT = test + +XCODEBUILD_FLAGS = \ + -configuration $(CONFIG) \ + -derivedDataPath $(DERIVED_DATA_PATH) \ + -destination $(DESTINATION) \ + -scheme "$(SCHEME)" \ + -skipMacroValidation \ + -workspace $(WORKSPACE) + +XCODEBUILD_COMMAND = xcodebuild $(XCODEBUILD_ARGUMENT) $(XCODEBUILD_FLAGS) + +ifneq ($(strip $(shell which xcbeautify)),) + XCODEBUILD = set -o pipefail && $(XCODEBUILD_COMMAND) | xcbeautify --quiet +else + XCODEBUILD = $(XCODEBUILD_COMMAND) +endif + +TEST_RUNNER_CI = $(CI) + export SECRETS define SECRETS enum DotEnv { @@ -16,63 +46,8 @@ 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; + $(XCODEBUILD) load-env: @. ./scripts/load_env.sh @@ -80,46 +55,8 @@ load-env: dot-env: @echo "$$SECRETS" > Tests/IntegrationTests/DotEnv.swift - -build-all-platforms: - for platform in "iOS" "macOS" "macOS,variant=Mac Catalyst" "tvOS" "visionOS" "watchOS"; do \ - xcodebuild \ - -skipMacroValidation \ - -configuration "$(CONFIG)" \ - -workspace Supabase.xcworkspace \ - -scheme "$(SCHEME)" \ - -testPlan AllTests \ - -destination platform="$$platform" | xcpretty || exit 1; \ - done - -test-auth: - $(MAKE) SCHEME=Auth test-library - -test-functions: - $(MAKE) SCHEME=Functions test-library - -test-postgrest: - $(MAKE) SCHEME=PostgREST test-library - -test-realtime: - $(MAKE) SCHEME=Realtime test-library - -test-storage: - $(MAKE) SCHEME=Storage test-library - test-integration: dot-env - set -o pipefail && \ - xcodebuild test \ - -skipMacroValidation \ - -workspace Supabase.xcworkspace \ - -scheme Supabase \ - -testPlan Integration \ - -destination platform="$(PLATFORM_IOS)" | xcpretty - - -test-linux: - docker build -t supabase-swift . - docker run supabase-swift + $(MAKE) TEST_PLAN=Integration xcodebuild build-for-library-evolution: swift build \ @@ -141,19 +78,10 @@ test-docs: || (echo "xcodebuild docbuild failed:\n\n$(DOC_WARNINGS)" | tr '\1' '\n' \ && exit 1) -build-example: - xcodebuild build \ - -skipMacroValidation \ - -workspace Supabase.xcworkspace \ - -scheme "$(SCHEME)" \ - -destination platform="$(PLATFORM_IOS)" \ - -derivedDataPath ~/.derivedData | xcpretty; - - format: @swift format -i -r --ignore-unparsable-files . -.PHONY: test-library test-linux build-example +.PHONY: build-for-library-evolution format xcodebuild test-docs test-integration define udid_for $(shell xcrun simctl list devices available '$(1)' | grep '$(2)' | sort -r | head -1 | awk -F '[()]' '{ print $$(NF-3) }')