Skip to content

Commit 227c559

Browse files
authored
test: add tests for HTTPError and PostgrestError types (#737)
* test(AnyJSON): add comprehensive and edge-case tests for AnyJSON Covers value accessors, literal initializers, error handling, extensions, and edge cases to ensure full correctness and robustness. * test(helpers): add comprehensive tests for HTTPError Add tests for the HTTPError type covering initialization, property access, and LocalizedError conformance for various data scenarios. Ensures robust error reporting and future-proofing for HTTP error handling. * ci: split linux_android job into separate linux and android jobs - Split combined linux_android job into separate linux and android jobs for better isolation - Uncomment library-evolution job that was previously commented out - Improve CI workflow organization and maintainability * test: add PostgrestError LocalizedError conformance test - Add test to verify PostgrestError properly conforms to LocalizedError protocol - Test ensures errorDescription property returns the expected error message - Improves test coverage for error handling functionality * ci: run library evolution step on latest Xcode * ci: run evolution on latest macos * perf(ci): optimize platform coverage to reduce build times - Remove Xcode 15.2 testing (keep only 15.4 for backward compatibility) - Remove tvOS, visionOS, and watchOS platforms (less critical for backend SDK) - Keep iOS, macOS, and macCatalyst for comprehensive coverage - Maintain Linux and Android cross-platform testing - Expected 50-60% reduction in CI time while maintaining good coverage This optimization focuses on the most commonly used platforms while significantly reducing CI resource usage and wait times. * ci: comment out Android job
1 parent 56da0a9 commit 227c559

File tree

6 files changed

+580
-100
lines changed

6 files changed

+580
-100
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ permissions:
1818

1919
jobs:
2020
xcodebuild-latest:
21-
name: xcodebuild (16)
21+
name: xcodebuild (16.3)
2222
runs-on: macos-15
2323
strategy:
2424
matrix:
@@ -42,7 +42,7 @@ jobs:
4242
- name: Release
4343
if: matrix.skip_release != '1'
4444
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild
45-
- name: Instal lcov
45+
- name: Install lcov
4646
if: matrix.command == 'test' && matrix.platform == 'IOS'
4747
run: brew install lcov
4848
- name: Export code coverage
@@ -55,34 +55,20 @@ jobs:
5555
github-token: ${{ secrets.GITHUB_TOKEN }}
5656
file: lcov.info
5757

58-
xcodebuild:
59-
name: xcodebuild (15)
58+
xcodebuild-legacy:
59+
name: xcodebuild (15.4)
6060
runs-on: macos-14
6161
strategy:
6262
matrix:
6363
command: [test, ""]
64-
platform: [IOS, MAC_CATALYST, MACOS, TVOS, VISIONOS, WATCHOS]
65-
xcode: [15.2, 15.4]
66-
exclude:
67-
- { xcode: 15.2, command: test }
68-
- { xcode: 15.2, platform: MAC_CATALYST }
69-
- { xcode: 15.2, platform: TVOS }
70-
- { xcode: 15.2, platform: VISIONOS }
71-
- { xcode: 15.2, platform: WATCHOS }
72-
- { command: test, platform: WATCHOS }
64+
platform: [IOS, MACOS, MAC_CATALYST]
65+
xcode: ["15.4"]
7366
include:
7467
- { command: test, skip_release: 1 }
7568
steps:
7669
- uses: actions/checkout@v4
7770
- name: Select Xcode ${{ matrix.xcode }}
7871
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
79-
- name: Install visionOS runtime
80-
if: matrix.platform == 'visionOS'
81-
run: |
82-
sudo xcodebuild -runFirstLaunch
83-
sudo xcrun simctl list
84-
sudo xcodebuild -downloadPlatform visionOS
85-
sudo xcodebuild -runFirstLaunch
8672
- name: List available devices
8773
run: xcrun simctl list devices available
8874
- name: Cache derived data
@@ -104,55 +90,43 @@ jobs:
10490
if: matrix.skip_release != '1'
10591
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild
10692

107-
linux_android:
108-
name: Linux and Android
109-
runs-on: ubuntu-24.04
93+
linux:
94+
name: Linux
95+
runs-on: ubuntu-latest
11096
steps:
11197
- uses: actions/checkout@v4
11298
- name: "Remove IntegrationTests"
11399
run: rm -r Tests/IntegrationTests/*
114-
- name: "Build Swift Package on Linux"
100+
- name: "Build Swift Package"
115101
run: swift build
116-
- name: "Test Swift Package on Android"
117-
uses: skiptools/swift-android-action@v2
118-
with:
119-
# need to copy over the Tests folder because it contains __Snapshots__
120-
copy-files: Tests
121-
# tests are not yet passing on Android
122-
run-tests: false
123-
124-
# linux:
125-
# name: linux
126-
# strategy:
127-
# matrix:
128-
# swift-version: ["5.10"]
102+
103+
# android:
104+
# name: Android
129105
# runs-on: ubuntu-latest
130106
# steps:
131107
# - uses: actions/checkout@v4
132-
# - uses: swift-actions/setup-swift@v2
108+
# - name: "Remove IntegrationTests"
109+
# run: rm -r Tests/IntegrationTests/*
110+
# - name: "Test Swift Package"
111+
# uses: skiptools/swift-android-action@v2
133112
# with:
134-
# swift-version: ${{ matrix.swift-version }}
135-
# - name: Cache build
136-
# uses: actions/cache@v3
137-
# with:
138-
# path: |
139-
# .build
140-
# key: |
141-
# build-spm-linux-${{ matrix.swift-version }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift', '**/Package.resolved') }}
142-
# restore-keys: |
143-
# build-spm-linux-${{ matrix.swift-version }}-
144-
# - name: Run tests
145-
# run: swift test --skip IntegrationTests
113+
# # need to copy over the Tests folder because it contains __Snapshots__
114+
# copy-files: Tests
115+
# # tests are not yet passing on Android
116+
# run-tests: false
146117

147-
# library-evolution:
148-
# name: Library (evolution)
149-
# runs-on: macos-14
150-
# steps:
151-
# - uses: actions/checkout@v4
152-
# - name: Select Xcode 15.4
153-
# run: sudo xcode-select -s /Applications/Xcode_15.4.app
154-
# - name: Build for library evolution
155-
# run: make build-for-library-evolution
118+
library-evolution:
119+
name: Library (evolution)
120+
runs-on: macos-15
121+
strategy:
122+
matrix:
123+
xcode: ["16.3"]
124+
steps:
125+
- uses: actions/checkout@v4
126+
- name: Select Xcode ${{ matrix.xcode }}
127+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
128+
- name: Build for library evolution
129+
run: make build-for-library-evolution
156130

157131
examples:
158132
name: Examples
@@ -186,4 +160,4 @@ jobs:
186160
steps:
187161
- uses: actions/checkout@v4
188162
- name: Test docs
189-
run: make test-docs
163+
run: make test-docs

Dockerfile

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

Makefile

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ PLATFORM_TVOS = tvOS Simulator,id=$(call udid_for,tvOS,TV)
1010
PLATFORM_VISIONOS = visionOS Simulator,id=$(call udid_for,visionOS,Vision)
1111
PLATFORM_WATCHOS = watchOS Simulator,id=$(call udid_for,watchOS,Watch)
1212

13-
1413
PLATFORM = IOS
1514
DESTINATION = platform="$(PLATFORM_$(PLATFORM))"
1615

16+
PLATFORM_ID = $(shell echo "$(DESTINATION)" | sed -E "s/.+,id=(.+)/\1/")
17+
1718
SCHEME = Supabase
1819

1920
WORKSPACE = Supabase.xcworkspace
@@ -26,19 +27,25 @@ XCODEBUILD_FLAGS = \
2627
-destination $(DESTINATION) \
2728
-scheme "$(SCHEME)" \
2829
-skipMacroValidation \
29-
-workspace $(WORKSPACE) \
30+
-workspace $(WORKSPACE)
3031

3132
XCODEBUILD_COMMAND = xcodebuild $(XCODEBUILD_ARGUMENT) $(XCODEBUILD_FLAGS)
3233

3334
ifneq ($(strip $(shell which xcbeautify)),)
34-
XCODEBUILD = set -o pipefail && $(XCODEBUILD_COMMAND) | xcbeautify --quiet
35+
XCODEBUILD = set -o pipefail && $(XCODEBUILD_COMMAND) | xcbeautify
3536
else
3637
XCODEBUILD = $(XCODEBUILD_COMMAND)
3738
endif
3839

3940
TEST_RUNNER_CI = $(CI)
4041

41-
xcodebuild:
42+
warm-simulator:
43+
@test "$(PLATFORM_ID)" != "" \
44+
&& xcrun simctl boot $(PLATFORM_ID) \
45+
&& open -a Simulator --args -CurrentDeviceUDID $(PLATFORM_ID) \
46+
|| exit 0
47+
48+
xcodebuild: warm-simulator
4249
$(XCODEBUILD)
4350

4451
test-integration:
@@ -48,6 +55,7 @@ test-integration:
4855

4956
build-for-library-evolution:
5057
swift build \
58+
-q \
5159
-c release \
5260
--target Supabase \
5361
-Xswiftc -emit-module-interface \
@@ -67,31 +75,18 @@ test-docs:
6775
&& exit 1)
6876

6977
format:
70-
@swift format -i -r --ignore-unparsable-files .
71-
72-
73-
test-linux:
74-
docker run \
75-
--rm \
76-
-v "$(PWD):$(PWD)" \
77-
-w "$(PWD)" \
78-
swift:5.10 \
79-
bash -c 'swift test -c $(CONFIG)'
80-
81-
build-linux:
82-
docker run \
83-
--rm \
84-
-v "$(PWD):$(PWD)" \
85-
-w "$(PWD)" \
86-
swift:5.9 \
87-
bash -c 'swift build -c $(CONFIG)'
78+
find . \
79+
-path '*/Documentation/docc' -prune -o \
80+
-name '*.swift' \
81+
-not -path '*/.*' -print0 \
82+
| xargs -0 xcrun swift-format --ignore-unparsable-files --in-place
8883

89-
.PHONY: build-for-library-evolution format xcodebuild test-docs test-integration
84+
.PHONY: build-for-library-evolution format warm-simulator xcodebuild test-docs test-integration
9085

9186
.PHONY: coverage
9287
coverage:
9388
@DERIVED_DATA_PATH=$(DERIVED_DATA_PATH) ./scripts/generate-coverage.sh
9489

9590
define udid_for
96-
$(shell xcrun simctl list devices available '$(1)' | grep '$(2)' | sort -r | head -1 | awk -F '[()]' '{ print $$(NF-3) }')
97-
endef
91+
$(shell xcrun simctl list --json devices available '$(1)' | jq -r '[.devices|to_entries|sort_by(.key)|reverse|.[].value|select(length > 0)|.[0]][0].udid')
92+
endef

0 commit comments

Comments
 (0)