7
7
workflow_dispatch :
8
8
9
9
env :
10
- SCHEME : C2PAExample
10
+ SCHEME : Library
11
11
12
12
jobs :
13
+ lint :
14
+ name : Lint
15
+ runs-on : macos-15
16
+ steps :
17
+ - uses : actions/checkout@v4
18
+
19
+ - name : Set up Xcode
20
+ uses : maxim-lobanov/setup-xcode@v1
21
+ with :
22
+ xcode-version : " 16.4"
23
+
24
+ - name : Install SwiftLint
25
+ run : brew install swiftlint
26
+
27
+ - name : Run SwiftLint
28
+ run : make lint
29
+
13
30
test :
14
31
name : ${{ matrix.device }} Xcode ${{ matrix.xcode }}
15
- runs-on : macos-14
32
+ runs-on : macos-15
16
33
strategy :
17
34
fail-fast : false
18
35
matrix :
19
- xcode : ["16.1 "]
36
+ xcode : ["16.4 "]
20
37
device :
21
38
[
22
39
" iPhone 16 Pro" ,
23
- " iPhone 16" ,
24
- " iPhone SE (3rd generation)" ,
25
- " iPad Pro 11-inch (M4)" ,
40
+ " iPhone 16"
26
41
]
27
- ios : ["18.1 "]
42
+ ios : ["18.5 "]
28
43
29
44
steps :
30
45
- uses : actions/checkout@v4
@@ -37,178 +52,85 @@ jobs:
37
52
- name : Verify Xcode version
38
53
run : xcodebuild -version
39
54
40
- - name : Build iOS Framework
41
- run : make ios-framework
42
-
43
- - name : Setup Signing Server
44
- run : |
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
55
+ - name : Build Library
56
+ run : make library DESTINATION="platform=iOS Simulator,name=${{ matrix.device }},OS=${{ matrix.ios }}"
52
57
53
58
- name : Start Signing Server
54
59
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)"
60
+ make signing-server-start
61
+ sleep 5
59
62
60
63
- 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
64
+ run : make signing-server-wait
79
65
80
66
- 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"
67
+ run : make signing-server-verify
97
68
98
69
- name : Build & Test
99
70
run : |
100
71
set -o pipefail
101
- cd example
102
72
echo "CI environment variable: true"
103
73
echo "Testing with server at http://127.0.0.1:8080"
104
- TEST_RUNNER_CI=true xcrun xcodebuild test \
105
- -project C2PAExample.xcodeproj \
106
- -scheme "$SCHEME" \
107
- -sdk iphonesimulator \
108
- -destination "platform=iOS Simulator,name=${{ matrix.device }},OS=${{ matrix.ios }}" \
109
- -resultBundlePath TestResults \
110
- -enableCodeCoverage YES \
111
- | xcpretty --test --color
74
+ TEST_RUNNER_CI=true make test-library DESTINATION="platform=iOS Simulator,name=${{ matrix.device }},OS=${{ matrix.ios }}"
112
75
113
76
- name : Generate test summary
114
77
if : always()
115
- run : |
116
- cd example
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
78
+ run : make test-summary
135
79
136
80
- name : Upload test summary
137
81
if : always()
138
82
uses : actions/upload-artifact@v4
139
83
with :
140
84
name : TestSummary-${{ matrix.xcode }}-${{ matrix.device }}
141
85
path : |
142
- example/test-results.json
143
- example/TestResults.xcresult
86
+ TestResults.xcresult
87
+ if-no-files-found : warn
144
88
145
89
- name : Export coverage LCOV
146
90
if : success()
147
91
run : |
148
- cd example
149
-
150
- # Get DerivedData path from xcodebuild
151
- DERIVED_DATA=$(xcodebuild -showBuildSettings -project C2PAExample.xcodeproj -scheme C2PAExample -sdk iphonesimulator | grep -m 1 " BUILD_DIR " | sed 's/.*= //' | sed 's|/Build/Products||')
152
- echo "Derived data path: $DERIVED_DATA"
153
-
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)
156
-
157
- echo "Coverage.profdata path: $PROFDATA_PATH"
158
-
159
- # Find the test binary
160
- TEST_BINARY_PATH=$(find ~/Library/Developer/Xcode/DerivedData -path "*/C2PAExampleTests.xctest/C2PAExampleTests" -type f 2>/dev/null | grep -i c2paexample | head -1 || true)
161
-
162
- echo "Test binary path: $TEST_BINARY_PATH"
163
-
164
- # Try to generate LCOV if we have both files
165
- if [ -n "$PROFDATA_PATH" ] && [ -n "$TEST_BINARY_PATH" ]; then
166
- # Export to LCOV format
167
- # Use a sanitized filename to avoid shell issues with special characters
168
- DEVICE_NAME="${{ matrix.device }}"
169
- SANITIZED_DEVICE=$(echo "$DEVICE_NAME" | tr ' ()' '---')
170
-
171
- xcrun llvm-cov export \
172
- -format=lcov \
173
- -instr-profile="$PROFDATA_PATH" \
174
- "$TEST_BINARY_PATH" \
175
- > "../coverage-${{ matrix.xcode }}-${SANITIZED_DEVICE}.lcov"
176
-
177
- echo "LCOV coverage report generated successfully"
178
- else
179
- echo "ERROR: Could not generate LCOV report - missing profdata or binary"
180
- echo "PROFDATA_PATH: $PROFDATA_PATH"
181
- echo "TEST_BINARY_PATH: $TEST_BINARY_PATH"
182
- exit 1
92
+ make coverage-lcov
93
+ # Also keep the JSON for better Codecov support
94
+ if [ -f "coverage.json" ]; then
95
+ echo "Coverage JSON found ($(wc -c < coverage.json) bytes)"
96
+ fi
97
+ if [ -f "coverage.lcov" ]; then
98
+ echo "Coverage LCOV found ($(wc -c < coverage.lcov) bytes)"
99
+ # Create a copy with device/xcode info
100
+ SANITIZED_DEVICE=$(echo "${{ matrix.device }}" | tr ' ()' '---')
101
+ cp coverage.lcov "coverage-${{ matrix.xcode }}-${SANITIZED_DEVICE}.lcov"
183
102
fi
184
103
185
104
- name : Upload coverage report to GitHub
186
105
if : success()
187
106
uses : actions/upload-artifact@v4
188
107
with :
189
108
name : coverage-${{ matrix.xcode }}-${{ matrix.device }}
190
- path : coverage-*.lcov
109
+ path : |
110
+ coverage.lcov
111
+ coverage.json
112
+ coverage-*.lcov
113
+ if-no-files-found : warn
191
114
192
115
- name : Upload coverage report to Codecov
193
116
if : success()
194
117
uses : codecov/codecov-action@v5
195
118
with :
196
119
token : ${{ secrets.CODECOV_TOKEN }}
197
120
slug : contentauth/c2pa-ios
121
+ files : ./coverage.lcov,./coverage.json
122
+ flags : unittests
123
+ name : c2pa-ios-${{ matrix.device }}
124
+ fail_ci_if_error : false
125
+ verbose : true
198
126
199
127
- name : Stop Signing Server
200
128
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
129
+ run : make signing-server-stop || true
208
130
209
131
- name : Upload Server Logs
210
132
if : failure()
211
133
uses : actions/upload-artifact@v4
212
134
with :
213
135
name : server-logs-${{ matrix.xcode }}-${{ matrix.device }}
214
- path : signing-server/.build/debug/* .log
136
+ path : signing-server.log
0 commit comments