@@ -40,11 +40,68 @@ jobs:
40
40
- name : Build iOS Framework
41
41
run : make ios-framework
42
42
43
- - name : Build & test
43
+ - name : Setup Signing Server
44
44
run : |
45
- set -eo pipefail
45
+ echo "Setting up C2PA signing server..."
46
+ make setup-server
47
+
48
+ - name : Build Signing Server
49
+ run : |
50
+ cd signing-server
51
+ swift build
52
+
53
+ - name : Start Signing Server
54
+ run : |
55
+ cd signing-server
56
+ DYLD_LIBRARY_PATH=libs:$DYLD_LIBRARY_PATH .build/debug/Run serve --env development --hostname 127.0.0.1 --port 8080 &
57
+ echo $! > ../server.pid
58
+ echo "Server started with PID $(cat ../server.pid)"
59
+
60
+ - name : Wait for Server to be Ready
61
+ run : |
62
+ echo "Waiting for signing server to be ready..."
63
+ max_attempts=30
64
+ attempt=0
65
+ while [ $attempt -lt $max_attempts ]; do
66
+ if curl -s http://127.0.0.1:8080/health > /dev/null 2>&1; then
67
+ echo "✓ Signing server is ready"
68
+ break
69
+ fi
70
+ echo "Waiting for server... (attempt $((attempt + 1))/$max_attempts)"
71
+ sleep 2
72
+ attempt=$((attempt + 1))
73
+ done
74
+
75
+ if [ $attempt -eq $max_attempts ]; then
76
+ echo "❌ Server failed to start after $max_attempts attempts"
77
+ exit 1
78
+ fi
79
+
80
+ - name : Verify Server Endpoints
81
+ run : |
82
+ echo "Testing server endpoints..."
83
+ curl -v http://127.0.0.1:8080/health || echo "Health check failed"
84
+ echo ""
85
+ echo "Server is listening on:"
86
+ lsof -i :8080 || echo "No process on port 8080"
87
+
88
+ - name : Clean Build Directory
89
+ run : |
90
+ cd example
91
+ xcodebuild clean -project C2PAExample.xcodeproj -scheme "$SCHEME"
92
+
93
+ - name : Resolve Package Dependencies
94
+ run : |
95
+ cd example
96
+ xcodebuild -resolvePackageDependencies -project C2PAExample.xcodeproj -scheme "$SCHEME"
97
+
98
+ - name : Build & Test
99
+ run : |
100
+ set -o pipefail
46
101
cd example
47
- xcrun xcodebuild test \
102
+ echo "CI environment variable: true"
103
+ echo "Testing with server at http://127.0.0.1:8080"
104
+ TEST_RUNNER_CI=true xcrun xcodebuild test \
48
105
-project C2PAExample.xcodeproj \
49
106
-scheme "$SCHEME" \
50
107
-sdk iphonesimulator \
@@ -54,17 +111,36 @@ jobs:
54
111
| xcpretty --test --color
55
112
56
113
- name : Generate test summary
114
+ if : always()
57
115
run : |
58
116
cd example
59
- xcrun xcresulttool get test-results summary --path TestResults.xcresult || true
60
- xcrun xcresulttool get object --path TestResults.xcresult --format json > test-results.json || true
61
- xcrun xcresulttool get test-results tests --path TestResults.xcresult || true
117
+ if [ -d TestResults.xcresult ]; then
118
+ echo "=== Test Summary ==="
119
+ xcrun xcresulttool get test-results summary --path TestResults.xcresult || true
120
+ echo ""
121
+ echo "=== Test Results ==="
122
+ xcrun xcresulttool get test-results tests --path TestResults.xcresult || true
123
+ echo ""
124
+ echo "=== Exporting JSON ==="
125
+ # Use the legacy flag as required by newer versions
126
+ xcrun xcresulttool get --legacy --path TestResults.xcresult --format json > test-results.json 2>&1 || echo "Failed to export JSON"
127
+ if [ -s test-results.json ]; then
128
+ echo "Successfully exported test results to JSON ($(wc -c < test-results.json) bytes)"
129
+ else
130
+ echo "Warning: test-results.json is empty or not created"
131
+ fi
132
+ else
133
+ echo "TestResults.xcresult not found"
134
+ fi
62
135
63
136
- name : Upload test summary
137
+ if : always()
64
138
uses : actions/upload-artifact@v4
65
139
with :
66
140
name : TestSummary-${{ matrix.xcode }}-${{ matrix.device }}
67
- path : example/test-results.json
141
+ path : |
142
+ example/test-results.json
143
+ example/TestResults.xcresult
68
144
69
145
- name : Export coverage LCOV
70
146
if : success()
@@ -75,29 +151,13 @@ jobs:
75
151
DERIVED_DATA=$(xcodebuild -showBuildSettings -project C2PAExample.xcodeproj -scheme C2PAExample -sdk iphonesimulator | grep -m 1 " BUILD_DIR " | sed 's/.*= //' | sed 's|/Build/Products||')
76
152
echo "Derived data path: $DERIVED_DATA"
77
153
78
- # Find Coverage.profdata
79
- PROFDATA_PATH=""
80
- if [ -n "$DERIVED_DATA" ]; then
81
- PROFDATA_PATH=$(find "$DERIVED_DATA/Build/ProfileData" -name "Coverage.profdata" -type f 2>/dev/null | head -1 || true)
82
- fi
83
-
84
- # Method 2: If not found, look in common CI locations
85
- if [ -z "$PROFDATA_PATH" ]; then
86
- PROFDATA_PATH=$(find ~/Library/Developer/Xcode/DerivedData -path "*/Build/ProfileData/*/Coverage.profdata" -type f 2>/dev/null | grep -i c2paexample | head -1 || true)
87
- fi
154
+ # Find Coverage.profdata - search in common locations
155
+ PROFDATA_PATH=$(find ~/Library/Developer/Xcode/DerivedData -path "*/Build/ProfileData/*/Coverage.profdata" -type f 2>/dev/null | grep -i c2paexample | head -1 || true)
88
156
89
157
echo "Coverage.profdata path: $PROFDATA_PATH"
90
158
91
159
# Find the test binary
92
- TEST_BINARY_PATH=""
93
- if [ -n "$DERIVED_DATA" ]; then
94
- TEST_BINARY_PATH=$(find "$DERIVED_DATA/Build/Products" -path "*/C2PAExampleTests.xctest/C2PAExampleTests" -type f 2>/dev/null | head -1 || true)
95
- fi
96
-
97
- # If not found, search more broadly
98
- if [ -z "$TEST_BINARY_PATH" ]; then
99
- TEST_BINARY_PATH=$(find ~/Library/Developer/Xcode/DerivedData -path "*/C2PAExampleTests.xctest/C2PAExampleTests" -type f 2>/dev/null | grep -i c2paexample | head -1 || true)
100
- fi
160
+ TEST_BINARY_PATH=$(find ~/Library/Developer/Xcode/DerivedData -path "*/C2PAExampleTests.xctest/C2PAExampleTests" -type f 2>/dev/null | grep -i c2paexample | head -1 || true)
101
161
102
162
echo "Test binary path: $TEST_BINARY_PATH"
103
163
@@ -135,3 +195,20 @@ jobs:
135
195
with :
136
196
token : ${{ secrets.CODECOV_TOKEN }}
137
197
slug : contentauth/c2pa-ios
198
+
199
+ - name : Stop Signing Server
200
+ if : always()
201
+ run : |
202
+ if [ -f server.pid ]; then
203
+ SERVER_PID=$(cat server.pid)
204
+ echo "Stopping signing server (PID: $SERVER_PID)..."
205
+ kill $SERVER_PID || true
206
+ rm server.pid
207
+ fi
208
+
209
+ - name : Upload Server Logs
210
+ if : failure()
211
+ uses : actions/upload-artifact@v4
212
+ with :
213
+ name : server-logs-${{ matrix.xcode }}-${{ matrix.device }}
214
+ path : signing-server/.build/debug/*.log
0 commit comments