-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: upload coverage to coveralls (#642)
* ci: upload coverage to coveralls * add missing make dot-env * merge profraw files and use coveralls ci action * fix unwrapping nil value in ci * add generate-coverage.sh script for merging and exporting coverage files * install lcov * ignore .derivedData * config coveralls action * remove coverage.info * add coverage badge
- Loading branch information
Showing
7 changed files
with
103 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }} | ||
|
@@ -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) | ||
|
@@ -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 }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,3 +100,5 @@ iOSInjectionProject/ | |
.env | ||
Secrets.swift | ||
DotEnv.swift | ||
lcov.info | ||
temp_coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
208 changes: 0 additions & 208 deletions
208
Supabase.xcworkspace/xcshareddata/xcschemes/Supabase.xcscheme
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |