Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: simplify ci #569

Merged
merged 6 commits into from
Oct 19, 2024
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
36 changes: 23 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
pull_request:
branches:
- '*'
- "*"
workflow_dispatch:

concurrency:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -69,7 +81,6 @@ jobs:
- name: Run tests
run: swift test --skip IntegrationTests


# library-evolution:
# name: Library (evolution)
# runs-on: macos-14
Expand Down Expand Up @@ -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

run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="UserManagement" XCODEBUILD_ARGUMENT=build xcodebuild
12 changes: 8 additions & 4 deletions Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 */
Expand All @@ -93,7 +94,7 @@
794C61D52BAD1E12000E6B0F /* UserIdentityList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserIdentityList.swift; sourceTree = "<group>"; };
794EF1212955F26A008C9526 /* AddTodoListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTodoListView.swift; sourceTree = "<group>"; };
794EF1232955F3DE008C9526 /* TodoListRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoListRow.swift; sourceTree = "<group>"; };
7956405D2954ADE00088A06F /* Secrets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Secrets.swift; sourceTree = "<group>"; };
7956405D2954ADE00088A06F /* SupabaseConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupabaseConfig.swift; sourceTree = "<group>"; };
7956405F2954AE140088A06F /* AuthController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthController.swift; sourceTree = "<group>"; };
795640612955AD2B0088A06F /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
795640652955AE9C0088A06F /* TodoListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoListView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -146,6 +147,7 @@
79FEFFC42B078D7900D36347 /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = "<group>"; };
79FEFFC62B078FB000D36347 /* SwiftUIHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIHelpers.swift; sourceTree = "<group>"; };
79FEFFC82B0797F600D36347 /* AvatarImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarImage.swift; sourceTree = "<group>"; };
79FFA5B22CC04F8B00F8A807 /* Supabase.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Supabase.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -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 */,
Expand All @@ -230,6 +232,7 @@
797EFB672BABD90500098D6B /* Stringfy.swift */,
79B1C80D2BAC017C00D991AA /* AnyJSONView.swift */,
79401F342BC708C8004C9C0F /* UIViewControllerWrapper.swift */,
79FFA5B22CC04F8B00F8A807 /* Supabase.plist */,
);
path = Examples;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
);
Expand Down Expand Up @@ -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 */,
Expand Down
4 changes: 2 additions & 2 deletions Examples/Examples/ExamplesApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions Examples/Examples/Supabase.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SUPABASE_URL</key>
<string>http://127.0.0.1:54321</string>
<key>SUPABASE_ANON_KEY</key>
<string>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0</string>
</dict>
</plist>
13 changes: 13 additions & 0 deletions Examples/Examples/SupabaseConfig.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
6 changes: 0 additions & 6 deletions Examples/Examples/_Secrets.swift

This file was deleted.

142 changes: 35 additions & 107 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
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
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 {
Expand All @@ -16,110 +46,17 @@ 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

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 \
Expand All @@ -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) }')
Expand Down
Loading