Skip to content

Commit 4231223

Browse files
authored
chore: simplify ci (#569)
* ci * fix * run make dot-env on ci * fix Examples supabase config * fix * wip
1 parent 70158cc commit 4231223

File tree

7 files changed

+91
-132
lines changed

7 files changed

+91
-132
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- main
77
pull_request:
88
branches:
9-
- '*'
9+
- "*"
1010
workflow_dispatch:
1111

1212
concurrency:
@@ -19,13 +19,24 @@ jobs:
1919
runs-on: macos-14
2020
strategy:
2121
matrix:
22-
command: [test, '']
23-
platform: [iOS, macOS, tvOS, watchOS, visionOS, macCatalyst]
24-
xcode: [15.4, '16.0']
22+
command: [test, ""]
23+
platform: [IOS, MAC_CATALYST, MACOS, TVOS, VISIONOS, WATCHOS]
24+
xcode: [15.4, "16.0"]
25+
include:
26+
- { command: test, skip_release: 1 }
2527
steps:
2628
- uses: actions/checkout@v4
2729
- name: Select Xcode ${{ matrix.xcode }}
2830
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
31+
- name: Install visionOS runtime
32+
if: matrix.platform == 'visionOS'
33+
run: |
34+
sudo xcodebuild -runFirstLaunch
35+
sudo xcrun simctl list
36+
sudo xcodebuild -downloadPlatform visionOS
37+
sudo xcodebuild -runFirstLaunch
38+
- name: List available devices
39+
run: xcrun simctl list devices available
2940
- name: Cache derived data
3041
uses: actions/cache@v3
3142
with:
@@ -35,15 +46,16 @@ jobs:
3546
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
3647
restore-keys: |
3748
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-
38-
- name: Set IgnoreFileSystemDeviceInodeChanges flag
49+
- name: Set IgnoreFileSystemDeviceInodeChanges flag
3950
run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES
40-
- name: Update mtime for incremental builds
51+
- name: Update mtime for incremental builds
4152
uses: chetan/git-restore-mtime-action@v2
53+
- run: make dot-env
4254
- name: Debug
43-
run: make COMMAND="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" xcodebuild
55+
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" xcodebuild
4456
- name: Release
4557
if: matrix.skip_release != '1'
46-
run: make COMMAND="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild
58+
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild
4759

4860
linux:
4961
name: linux
@@ -69,7 +81,6 @@ jobs:
6981
- name: Run tests
7082
run: swift test --skip IntegrationTests
7183

72-
7384
# library-evolution:
7485
# name: Library (evolution)
7586
# runs-on: macos-14
@@ -100,9 +111,8 @@ jobs:
100111
- name: Update mtime for incremental builds
101112
uses: chetan/git-restore-mtime-action@v2
102113
- name: Examples
103-
run: make SCHEME="Examples" build-example
114+
run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="Examples" XCODEBUILD_ARGUMENT=build xcodebuild
104115
- name: SlackClone
105-
run: make SCHEME="SlackClone" build-example
116+
run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="SlackClone" XCODEBUILD_ARGUMENT=build xcodebuild
106117
- name: UserManagement
107-
run: make SCHEME="UserManagement" build-example
108-
118+
run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="UserManagement" XCODEBUILD_ARGUMENT=build xcodebuild

Examples/Examples.xcodeproj/project.pbxproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
794C61D62BAD1E12000E6B0F /* UserIdentityList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794C61D52BAD1E12000E6B0F /* UserIdentityList.swift */; };
2121
794EF1222955F26A008C9526 /* AddTodoListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794EF1212955F26A008C9526 /* AddTodoListView.swift */; };
2222
794EF1242955F3DE008C9526 /* TodoListRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794EF1232955F3DE008C9526 /* TodoListRow.swift */; };
23-
7956405E2954ADE00088A06F /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7956405D2954ADE00088A06F /* Secrets.swift */; };
23+
7956405E2954ADE00088A06F /* SupabaseConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7956405D2954ADE00088A06F /* SupabaseConfig.swift */; };
2424
795640602954AE140088A06F /* AuthController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7956405F2954AE140088A06F /* AuthController.swift */; };
2525
795640622955AD2B0088A06F /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 795640612955AD2B0088A06F /* HomeView.swift */; };
2626
795640662955AE9C0088A06F /* TodoListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 795640652955AE9C0088A06F /* TodoListView.swift */; };
@@ -75,6 +75,7 @@
7575
79FEFFC52B078D7900D36347 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC42B078D7900D36347 /* Models.swift */; };
7676
79FEFFC72B078FB000D36347 /* SwiftUIHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC62B078FB000D36347 /* SwiftUIHelpers.swift */; };
7777
79FEFFC92B0797F600D36347 /* AvatarImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC82B0797F600D36347 /* AvatarImage.swift */; };
78+
79FFA5B32CC04F8B00F8A807 /* Supabase.plist in Resources */ = {isa = PBXBuildFile; fileRef = 79FFA5B22CC04F8B00F8A807 /* Supabase.plist */; };
7879
/* End PBXBuildFile section */
7980

8081
/* Begin PBXFileReference section */
@@ -93,7 +94,7 @@
9394
794C61D52BAD1E12000E6B0F /* UserIdentityList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserIdentityList.swift; sourceTree = "<group>"; };
9495
794EF1212955F26A008C9526 /* AddTodoListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTodoListView.swift; sourceTree = "<group>"; };
9596
794EF1232955F3DE008C9526 /* TodoListRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoListRow.swift; sourceTree = "<group>"; };
96-
7956405D2954ADE00088A06F /* Secrets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Secrets.swift; sourceTree = "<group>"; };
97+
7956405D2954ADE00088A06F /* SupabaseConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupabaseConfig.swift; sourceTree = "<group>"; };
9798
7956405F2954AE140088A06F /* AuthController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthController.swift; sourceTree = "<group>"; };
9899
795640612955AD2B0088A06F /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
99100
795640652955AE9C0088A06F /* TodoListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoListView.swift; sourceTree = "<group>"; };
@@ -146,6 +147,7 @@
146147
79FEFFC42B078D7900D36347 /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = "<group>"; };
147148
79FEFFC62B078FB000D36347 /* SwiftUIHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIHelpers.swift; sourceTree = "<group>"; };
148149
79FEFFC82B0797F600D36347 /* AvatarImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarImage.swift; sourceTree = "<group>"; };
150+
79FFA5B22CC04F8B00F8A807 /* Supabase.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Supabase.plist; sourceTree = "<group>"; };
149151
/* End PBXFileReference section */
150152

151153
/* Begin PBXFrameworksBuildPhase section */
@@ -215,7 +217,7 @@
215217
793895C92954ABFF0044F2B8 /* ExamplesApp.swift */,
216218
793895D02954AC000044F2B8 /* Preview Content */,
217219
793895CB2954ABFF0044F2B8 /* RootView.swift */,
218-
7956405D2954ADE00088A06F /* Secrets.swift */,
220+
7956405D2954ADE00088A06F /* SupabaseConfig.swift */,
219221
795640612955AD2B0088A06F /* HomeView.swift */,
220222
795640652955AE9C0088A06F /* TodoListView.swift */,
221223
795640672955AEB30088A06F /* Models.swift */,
@@ -230,6 +232,7 @@
230232
797EFB672BABD90500098D6B /* Stringfy.swift */,
231233
79B1C80D2BAC017C00D991AA /* AnyJSONView.swift */,
232234
79401F342BC708C8004C9C0F /* UIViewControllerWrapper.swift */,
235+
79FFA5B22CC04F8B00F8A807 /* Supabase.plist */,
233236
);
234237
path = Examples;
235238
sourceTree = "<group>";
@@ -465,6 +468,7 @@
465468
isa = PBXResourcesBuildPhase;
466469
buildActionMask = 2147483647;
467470
files = (
471+
79FFA5B32CC04F8B00F8A807 /* Supabase.plist in Resources */,
468472
793895D22954AC000044F2B8 /* Preview Assets.xcassets in Resources */,
469473
793895CE2954AC000044F2B8 /* Assets.xcassets in Resources */,
470474
);
@@ -514,7 +518,7 @@
514518
79E2B55C2B97A2310042CD21 /* UIApplicationExtensions.swift in Sources */,
515519
794EF1222955F26A008C9526 /* AddTodoListView.swift in Sources */,
516520
7928145D2CAB2CE2000B4ADB /* ResetPasswordView.swift in Sources */,
517-
7956405E2954ADE00088A06F /* Secrets.swift in Sources */,
521+
7956405E2954ADE00088A06F /* SupabaseConfig.swift in Sources */,
518522
795640682955AEB30088A06F /* Models.swift in Sources */,
519523
79B1C80C2BABFF8000D991AA /* ProfileView.swift in Sources */,
520524
795640662955AE9C0088A06F /* TodoListView.swift in Sources */,

Examples/Examples/ExamplesApp.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ struct ExamplesApp: App {
2323
}
2424

2525
let supabase = SupabaseClient(
26-
supabaseURL: Secrets.supabaseURL,
27-
supabaseKey: Secrets.supabaseAnonKey,
26+
supabaseURL: URL(string: SupabaseConfig["SUPABASE_URL"]!)!,
27+
supabaseKey: SupabaseConfig["SUPABASE_ANON_KEY"]!,
2828
options: .init(
2929
auth: .init(redirectToURL: Constants.redirectToURL),
3030
global: .init(

Examples/Examples/Supabase.plist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SUPABASE_URL</key>
6+
<string>http://127.0.0.1:54321</string>
7+
<key>SUPABASE_ANON_KEY</key>
8+
<string>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0</string>
9+
</dict>
10+
</plist>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Foundation
2+
3+
enum SupabaseConfig {
4+
static subscript(key: String) -> String? {
5+
guard let plistFileURL = Bundle.main.url(forResource: "Supabase", withExtension: "plist"),
6+
let plistData = try? Data(contentsOf: plistFileURL),
7+
let plist = try? PropertyListSerialization.propertyList(from: plistData, format: nil)
8+
as? [String: Any]
9+
else { return nil }
10+
11+
return plist[key] as? String
12+
}
13+
}

Examples/Examples/_Secrets.swift

Lines changed: 0 additions & 6 deletions
This file was deleted.

Makefile

Lines changed: 35 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
1-
CONFIG = debug
2-
PLATFORM = iOS
1+
CONFIG = Debug
2+
3+
DERIVED_DATA_PATH = ~/.derivedData/$(CONFIG)
4+
35
PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS,iPhone \d\+ Pro [^M])
46
PLATFORM_MACOS = macOS
57
PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst
68
PLATFORM_TVOS = tvOS Simulator,id=$(call udid_for,tvOS,TV)
79
PLATFORM_VISIONOS = visionOS Simulator,id=$(call udid_for,visionOS,Vision)
810
PLATFORM_WATCHOS = watchOS Simulator,id=$(call udid_for,watchOS,Watch)
911

12+
13+
PLATFORM = IOS
14+
DESTINATION = platform="$(PLATFORM_$(PLATFORM))"
15+
16+
SCHEME = Supabase
17+
18+
WORKSPACE = Supabase.xcworkspace
19+
20+
XCODEBUILD_ARGUMENT = test
21+
22+
XCODEBUILD_FLAGS = \
23+
-configuration $(CONFIG) \
24+
-derivedDataPath $(DERIVED_DATA_PATH) \
25+
-destination $(DESTINATION) \
26+
-scheme "$(SCHEME)" \
27+
-skipMacroValidation \
28+
-workspace $(WORKSPACE)
29+
30+
XCODEBUILD_COMMAND = xcodebuild $(XCODEBUILD_ARGUMENT) $(XCODEBUILD_FLAGS)
31+
32+
ifneq ($(strip $(shell which xcbeautify)),)
33+
XCODEBUILD = set -o pipefail && $(XCODEBUILD_COMMAND) | xcbeautify --quiet
34+
else
35+
XCODEBUILD = $(XCODEBUILD_COMMAND)
36+
endif
37+
38+
TEST_RUNNER_CI = $(CI)
39+
1040
export SECRETS
1141
define SECRETS
1242
enum DotEnv {
@@ -16,110 +46,17 @@ enum DotEnv {
1646
}
1747
endef
1848

19-
default: test-all
20-
21-
test-all:
22-
$(MAKE) CONFIG=debug test-library
23-
$(MAKE) CONFIG=release test-library
24-
2549
xcodebuild:
26-
if test "$(PLATFORM)" = "iOS"; \
27-
then xcodebuild $(COMMAND) \
28-
-skipMacroValidation \
29-
-configuration $(CONFIG) \
30-
-workspace Supabase.xcworkspace \
31-
-scheme Supabase \
32-
-destination platform="$(PLATFORM_IOS)" \
33-
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
34-
elif test "$(PLATFORM)" = "macOS"; \
35-
then xcodebuild $(COMMAND) \
36-
-skipMacroValidation \
37-
-configuration $(CONFIG) \
38-
-workspace Supabase.xcworkspace \
39-
-scheme Supabase \
40-
-destination platform="$(PLATFORM_MACOS)" \
41-
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
42-
elif test "$(PLATFORM)" = "tvOS"; \
43-
then xcodebuild $(COMMAND) \
44-
-skipMacroValidation \
45-
-configuration $(CONFIG) \
46-
-workspace Supabase.xcworkspace \
47-
-scheme Supabase \
48-
-destination platform="$(PLATFORM_TVOS)" \
49-
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
50-
elif test "$(PLATFORM)" = "watchOS"; \
51-
then xcodebuild $(COMMAND) \
52-
-skipMacroValidation \
53-
-configuration $(CONFIG) \
54-
-workspace Supabase.xcworkspace \
55-
-scheme Supabase \
56-
-destination platform="$(PLATFORM_WATCHOS)" \
57-
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
58-
elif test "$(PLATFORM)" = "visionOS"; \
59-
then xcodebuild $(COMMAND) \
60-
-skipMacroValidation \
61-
-configuration $(CONFIG) \
62-
-workspace Supabase.xcworkspace \
63-
-scheme Supabase \
64-
-destination platform="$(PLATFORM_VISIONOS)" \
65-
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
66-
elif test "$(PLATFORM)" = "macCatalyst"; \
67-
then xcodebuild $(COMMAND) \
68-
-skipMacroValidation \
69-
-configuration $(CONFIG) \
70-
-workspace Supabase.xcworkspace \
71-
-scheme Supabase \
72-
-destination platform="$(PLATFORM_MAC_CATALYST)" \
73-
-derivedDataPath ~/.derivedData/$(CONFIG) | xcpretty; \
74-
else exit 1; \
75-
fi;
50+
$(XCODEBUILD)
7651

7752
load-env:
7853
@. ./scripts/load_env.sh
7954

8055
dot-env:
8156
@echo "$$SECRETS" > Tests/IntegrationTests/DotEnv.swift
8257

83-
84-
build-all-platforms:
85-
for platform in "iOS" "macOS" "macOS,variant=Mac Catalyst" "tvOS" "visionOS" "watchOS"; do \
86-
xcodebuild \
87-
-skipMacroValidation \
88-
-configuration "$(CONFIG)" \
89-
-workspace Supabase.xcworkspace \
90-
-scheme "$(SCHEME)" \
91-
-testPlan AllTests \
92-
-destination platform="$$platform" | xcpretty || exit 1; \
93-
done
94-
95-
test-auth:
96-
$(MAKE) SCHEME=Auth test-library
97-
98-
test-functions:
99-
$(MAKE) SCHEME=Functions test-library
100-
101-
test-postgrest:
102-
$(MAKE) SCHEME=PostgREST test-library
103-
104-
test-realtime:
105-
$(MAKE) SCHEME=Realtime test-library
106-
107-
test-storage:
108-
$(MAKE) SCHEME=Storage test-library
109-
11058
test-integration: dot-env
111-
set -o pipefail && \
112-
xcodebuild test \
113-
-skipMacroValidation \
114-
-workspace Supabase.xcworkspace \
115-
-scheme Supabase \
116-
-testPlan Integration \
117-
-destination platform="$(PLATFORM_IOS)" | xcpretty
118-
119-
120-
test-linux:
121-
docker build -t supabase-swift .
122-
docker run supabase-swift
59+
$(MAKE) TEST_PLAN=Integration xcodebuild
12360

12461
build-for-library-evolution:
12562
swift build \
@@ -141,19 +78,10 @@ test-docs:
14178
|| (echo "xcodebuild docbuild failed:\n\n$(DOC_WARNINGS)" | tr '\1' '\n' \
14279
&& exit 1)
14380

144-
build-example:
145-
xcodebuild build \
146-
-skipMacroValidation \
147-
-workspace Supabase.xcworkspace \
148-
-scheme "$(SCHEME)" \
149-
-destination platform="$(PLATFORM_IOS)" \
150-
-derivedDataPath ~/.derivedData | xcpretty;
151-
152-
15381
format:
15482
@swift format -i -r --ignore-unparsable-files .
15583

156-
.PHONY: test-library test-linux build-example
84+
.PHONY: build-for-library-evolution format xcodebuild test-docs test-integration
15785

15886
define udid_for
15987
$(shell xcrun simctl list devices available '$(1)' | grep '$(2)' | sort -r | head -1 | awk -F '[()]' '{ print $$(NF-3) }')

0 commit comments

Comments
 (0)