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

ci: upload coverage to coveralls #642

Merged
merged 10 commits into from
Jan 16, 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
27 changes: 20 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
platform: [IOS, MACOS]
xcode: ["16.2"]
include:
- {command: test, skip_release: 1}
- { command: test, skip_release: 1 }
steps:
- uses: actions/checkout@v4
- name: Select Xcode ${{ matrix.xcode }}
Expand All @@ -49,6 +49,19 @@ jobs:
- name: Release
if: matrix.skip_release != '1'
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild
- name: Instal lcov
if: matrix.command == 'test' && matrix.platform == 'IOS'
run: brew install lcov
- name: Export code coverage
id: coverage
if: matrix.command == 'test' && matrix.platform == 'IOS'
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" coverage
- uses: coverallsapp/[email protected]
if: steps.coverage.outcome == 'success'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: lcov.info


xcodebuild:
name: xcodebuild (15)
Expand All @@ -59,13 +72,13 @@ jobs:
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}
- { 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 }
include:
- {command: test, skip_release: 1}
- { command: test, skip_release: 1 }
steps:
- uses: actions/checkout@v4
- name: Select Xcode ${{ matrix.xcode }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ iOSInjectionProject/
.env
Secrets.swift
DotEnv.swift
lcov.info
temp_coverage
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CONFIG = Debug

DERIVED_DATA_PATH = ~/.derivedData/$(CONFIG)
TEMP_COVERAGE_DIR := temp_coverage

PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS,iPhone \d\+ Pro [^M])
PLATFORM_MACOS = macOS
Expand All @@ -25,7 +26,7 @@ XCODEBUILD_FLAGS = \
-destination $(DESTINATION) \
-scheme "$(SCHEME)" \
-skipMacroValidation \
-workspace $(WORKSPACE)
-workspace $(WORKSPACE) \

XCODEBUILD_COMMAND = xcodebuild $(XCODEBUILD_ARGUMENT) $(XCODEBUILD_FLAGS)

Expand Down Expand Up @@ -100,6 +101,10 @@ build-linux:

.PHONY: build-for-library-evolution format 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# supabase-swift
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fsupabase%2Fsupabase-swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/supabase/supabase-swift)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fsupabase%2Fsupabase-swift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/supabase/supabase-swift)
[![Coverage Status](https://coveralls.io/repos/github/supabase/supabase-swift/badge.svg?branch=coveralls)](https://coveralls.io/github/supabase/supabase-swift?branch=coveralls)

Supabase client for Swift. Mirrors the design of [supabase-js](https://github.com/supabase/supabase-js/blob/master/README.md).

Expand Down
208 changes: 0 additions & 208 deletions Supabase.xcworkspace/xcshareddata/xcschemes/Supabase.xcscheme

This file was deleted.

2 changes: 1 addition & 1 deletion Tests/IntegrationTests/RealtimeIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class RealtimeIntegrationTests: XCTestCase {
let testClock = TestClock<Duration>()

let client = SupabaseClient(
supabaseURL: URL(string: DotEnv.SUPABASE_URL)!,
supabaseURL: URL(string: DotEnv.SUPABASE_URL) ?? URL(string: "http://localhost:54321")!,
supabaseKey: DotEnv.SUPABASE_ANON_KEY
)

Expand Down
73 changes: 73 additions & 0 deletions scripts/generate-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

# Define variables
SCHEME="Supabase" # Replace with your Xcode scheme name
OUTPUT_FILE="lcov.info" # Output coverage file name
TEMP_COVERAGE_DIR="temp_coverage" # Temporary directory for intermediate coverage files

# Step 2: Find the profdata file
PROFDATA_DIR="$DERIVED_DATA_PATH/Build/ProfileData"
PROFDATA_FILE=$(find "$PROFDATA_DIR" -name "*.profdata" | head -n 1)

if [ -z "$PROFDATA_FILE" ]; then
echo "No profdata file found. Exiting."
exit 1
fi

echo "Found profdata file: $PROFDATA_FILE"

# Step 3: Get all test bundles
echo "Searching for test bundles in Debug-iphonesimulator..."
TEST_BUNDLES=$(find "$DERIVED_DATA_PATH/Build/Products/Debug-iphonesimulator" -type d -name "*.xctest")

if [ -z "$TEST_BUNDLES" ]; then
echo "No test bundles found. Ensure the tests are built successfully."
exit 1
fi

echo "Found test bundles:"
echo "$TEST_BUNDLES"

# Step 4: Export coverage data for each test bundle
mkdir -p "$TEMP_COVERAGE_DIR"
for TEST_BUNDLE in $TEST_BUNDLES; do
BINARY_NAME=$(basename "$TEST_BUNDLE" .xctest)
BINARY_PATH="$TEST_BUNDLE/$BINARY_NAME"

if [ ! -f "$BINARY_PATH" ]; then
echo "No binary found in $TEST_BUNDLE. Skipping..."
continue
fi

echo "Exporting coverage data for binary: $BINARY_PATH"
xcrun llvm-cov export \
-format=lcov \
-instr-profile "$PROFDATA_FILE" \
-ignore-filename-regex "Tests/|.build|DerivedData|.derivedData" \
"$BINARY_PATH" > "$TEMP_COVERAGE_DIR/$BINARY_NAME.info"

if [ $? -ne 0 ]; then
echo "Failed to export coverage for $BINARY_NAME. Skipping..."
continue
fi
done

# Step 5: Merge coverage data into a single file
echo "Merging coverage data..."
rm -f "$OUTPUT_FILE" # Ensure the output file doesn't already exist

for INFO_FILE in "$TEMP_COVERAGE_DIR"/*.info; do
if [ -f "$INFO_FILE" ]; then
lcov --add-tracefile "$INFO_FILE" --output-file "$OUTPUT_FILE"
if [ $? -ne 0 ]; then
echo "Failed to merge $INFO_FILE into $OUTPUT_FILE. Exiting."
exit 1
fi
fi
done

echo "Coverage data exported to $OUTPUT_FILE"

# Step 6: Clean up
rm -rf "$TEMP_COVERAGE_DIR"
echo "Temporary files cleaned up."
Loading