Skip to content

test: add tests for HTTPError and PostgrestError types #737

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

Merged
merged 8 commits into from
Jul 10, 2025
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
94 changes: 34 additions & 60 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions:

jobs:
xcodebuild-latest:
name: xcodebuild (16)
name: xcodebuild (16.3)
runs-on: macos-15
strategy:
matrix:
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Release
if: matrix.skip_release != '1'
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild
- name: Instal lcov
- name: Install lcov
if: matrix.command == 'test' && matrix.platform == 'IOS'
run: brew install lcov
- name: Export code coverage
Expand All @@ -55,34 +55,20 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: lcov.info

xcodebuild:
name: xcodebuild (15)
xcodebuild-legacy:
name: xcodebuild (15.4)
runs-on: macos-14
strategy:
matrix:
command: [test, ""]
platform: [IOS, MAC_CATALYST, MACOS, TVOS, VISIONOS, WATCHOS]
xcode: [15.2, 15.4]
exclude:
- { xcode: 15.2, command: test }
- { xcode: 15.2, platform: MAC_CATALYST }
- { xcode: 15.2, platform: TVOS }
- { xcode: 15.2, platform: VISIONOS }
- { xcode: 15.2, platform: WATCHOS }
- { command: test, platform: WATCHOS }
platform: [IOS, MACOS, MAC_CATALYST]
xcode: ["15.4"]
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
Expand All @@ -104,55 +90,43 @@ jobs:
if: matrix.skip_release != '1'
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild

linux_android:
name: Linux and Android
runs-on: ubuntu-24.04
linux:
name: Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Remove IntegrationTests"
run: rm -r Tests/IntegrationTests/*
- name: "Build Swift Package on Linux"
- name: "Build Swift Package"
run: swift build
- name: "Test Swift Package on Android"
uses: skiptools/swift-android-action@v2
with:
# need to copy over the Tests folder because it contains __Snapshots__
copy-files: Tests
# tests are not yet passing on Android
run-tests: false

# linux:
# name: linux
# strategy:
# matrix:
# swift-version: ["5.10"]

# android:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really support android as a build target, and this check was added by an external contributor, I won't spent much time on trying to debug it.

# name: Android
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: swift-actions/setup-swift@v2
# - name: "Remove IntegrationTests"
# run: rm -r Tests/IntegrationTests/*
# - name: "Test Swift Package"
# uses: skiptools/swift-android-action@v2
# with:
# swift-version: ${{ matrix.swift-version }}
# - name: Cache build
# uses: actions/cache@v3
# with:
# path: |
# .build
# key: |
# build-spm-linux-${{ matrix.swift-version }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift', '**/Package.resolved') }}
# restore-keys: |
# build-spm-linux-${{ matrix.swift-version }}-
# - name: Run tests
# run: swift test --skip IntegrationTests
# # need to copy over the Tests folder because it contains __Snapshots__
# copy-files: Tests
# # tests are not yet passing on Android
# run-tests: false

# 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
library-evolution:
name: Library (evolution)
runs-on: macos-15
strategy:
matrix:
xcode: ["16.3"]
steps:
- uses: actions/checkout@v4
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Build for library evolution
run: make build-for-library-evolution

examples:
name: Examples
Expand Down Expand Up @@ -186,4 +160,4 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Test docs
run: make test-docs
run: make test-docs
15 changes: 0 additions & 15 deletions Dockerfile

This file was deleted.

45 changes: 20 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ 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))"

PLATFORM_ID = $(shell echo "$(DESTINATION)" | sed -E "s/.+,id=(.+)/\1/")

SCHEME = Supabase

WORKSPACE = Supabase.xcworkspace
Expand All @@ -26,19 +27,25 @@ XCODEBUILD_FLAGS = \
-destination $(DESTINATION) \
-scheme "$(SCHEME)" \
-skipMacroValidation \
-workspace $(WORKSPACE) \
-workspace $(WORKSPACE)

XCODEBUILD_COMMAND = xcodebuild $(XCODEBUILD_ARGUMENT) $(XCODEBUILD_FLAGS)

ifneq ($(strip $(shell which xcbeautify)),)
XCODEBUILD = set -o pipefail && $(XCODEBUILD_COMMAND) | xcbeautify --quiet
XCODEBUILD = set -o pipefail && $(XCODEBUILD_COMMAND) | xcbeautify
else
XCODEBUILD = $(XCODEBUILD_COMMAND)
endif

TEST_RUNNER_CI = $(CI)

xcodebuild:
warm-simulator:
@test "$(PLATFORM_ID)" != "" \
&& xcrun simctl boot $(PLATFORM_ID) \
&& open -a Simulator --args -CurrentDeviceUDID $(PLATFORM_ID) \
|| exit 0

xcodebuild: warm-simulator
$(XCODEBUILD)

test-integration:
Expand All @@ -48,6 +55,7 @@ test-integration:

build-for-library-evolution:
swift build \
-q \
-c release \
--target Supabase \
-Xswiftc -emit-module-interface \
Expand All @@ -67,31 +75,18 @@ test-docs:
&& exit 1)

format:
@swift format -i -r --ignore-unparsable-files .


test-linux:
docker run \
--rm \
-v "$(PWD):$(PWD)" \
-w "$(PWD)" \
swift:5.10 \
bash -c 'swift test -c $(CONFIG)'

build-linux:
docker run \
--rm \
-v "$(PWD):$(PWD)" \
-w "$(PWD)" \
swift:5.9 \
bash -c 'swift build -c $(CONFIG)'
find . \
-path '*/Documentation/docc' -prune -o \
-name '*.swift' \
-not -path '*/.*' -print0 \
| xargs -0 xcrun swift-format --ignore-unparsable-files --in-place

.PHONY: build-for-library-evolution format xcodebuild test-docs test-integration
.PHONY: build-for-library-evolution format warm-simulator xcodebuild test-docs test-integration

.PHONY: coverage
coverage:
@DERIVED_DATA_PATH=$(DERIVED_DATA_PATH) ./scripts/generate-coverage.sh

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