-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
295 lines (269 loc) · 12.1 KB
/
Makefile
File metadata and controls
295 lines (269 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# Pulse Makefile
# Build, test, and development automation
.PHONY: help init install-xcodegen generate setup xcode test test-unit test-ui test-snapshot test-debug clean clean-packages coverage coverage-report coverage-badge deeplink-test lint format build build-release bump-patch bump-minor bump-major docs
# Default target
help:
@echo "Available commands:"
@echo " init - Setup Mint, SwiftFormat, and SwiftLint"
@echo " install-xcodegen - Install XcodeGen using Homebrew"
@echo " generate - Generate Xcode project from project.yml"
@echo " setup - install-xcodegen + generate"
@echo " build - Build for development (Debug)"
@echo " build-release - Build for release"
@echo " lint - Run SwiftLint and SwiftFormat checks"
@echo " format - Auto-fix formatting with SwiftFormat"
@echo " test - Run all tests on iPhone Air (iOS latest)"
@echo " test-unit - Run only unit tests"
@echo " test-ui - Run only UI tests"
@echo " test-snapshot - Run only snapshot tests"
@echo " test-debug - Run tests with full verbose output for debugging"
@echo " clean - Remove generated Xcode project"
@echo " clean-packages - Clean Swift Package Manager dependencies"
@echo " coverage - Run tests with coverage and show app %"
@echo " coverage-report - Show detailed per-file coverage report"
@echo " coverage-badge - Generate SVG badge at badges/coverage.svg"
@echo " deeplink-test - Test deeplink functionality specifically"
@echo " xcode - Generate project and open in Xcode"
@echo " bump-patch - Increase patch version (0.0.x)"
@echo " bump-minor - Increase minor version (0.x.0)"
@echo " bump-major - Increase major version (x.0.0)"
@echo " docs - Generate DocC documentation"
@echo " help - Show this help message"
# Setup Mint, SwiftFormat, and SwiftLint
init:
@echo "Setting up development environment..."
@echo "Checking for Homebrew..."
@if ! command -v brew &> /dev/null; then \
echo "Installing Homebrew..."; \
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
else \
echo "Homebrew already installed"; \
fi
@echo "Installing XcodeGen..."
@brew install xcodegen || true
@echo "Installing Mint..."
@brew install mint || true
@echo "Installing SwiftLint..."
@brew install swiftlint || true
@echo "Installing SwiftFormat via Mint..."
@mint install nicklockwood/SwiftFormat
@echo "Setting up git hooks..."
@mkdir -p .git/hooks
@echo '#!/bin/sh\nmake lint' > .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
@echo "Development environment setup complete!"
# Run linting checks (SwiftFormat + SwiftLint)
lint:
@echo "Running SwiftFormat lint check..."
@mint run nicklockwood/SwiftFormat swiftformat Pulse PulseTests --lint
@echo "SwiftFormat check passed"
@echo ""
@echo "Running SwiftLint..."
@swiftlint lint Pulse PulseTests
@echo "SwiftLint check passed"
# Auto-fix formatting with SwiftFormat
format:
@echo "Running SwiftFormat..."
@mint run nicklockwood/SwiftFormat swiftformat Pulse PulseTests
@echo "Formatting complete!"
# Install XcodeGen
install-xcodegen:
@echo "Installing XcodeGen..."
@brew install xcodegen
# Generate Xcode project
generate:
@echo "Generating Xcode project..."
@xcodegen generate
@echo "Project generated successfully!"
# Install and generate in one command
setup: install-xcodegen generate
@echo "Setup complete!"
# Clean Swift Package Manager dependencies
clean-packages:
@echo "Cleaning Swift Package Manager dependencies..."
@rm -rf Pulse.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
@rm -rf Pulse.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/configuration
@rm -rf Pulse.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/artifacts
@echo "Package dependencies cleaned!"
# Build commands
build:
@echo "Building Pulse (Debug)..."
@xcodebuild build \
-project Pulse.xcodeproj \
-scheme PulseDev \
-destination 'platform=iOS Simulator,name=iPhone Air,OS=latest' \
-configuration Debug \
CODE_SIGNING_ALLOWED=NO -skipMacroValidation
build-release:
@echo "Building Pulse (Release)..."
@xcodebuild build \
-project Pulse.xcodeproj \
-scheme PulseProd \
-destination 'platform=iOS Simulator,name=iPhone Air,OS=latest' \
-configuration Release \
CODE_SIGNING_ALLOWED=NO -skipMacroValidation
# Run all tests
test:
@echo "Running all tests on iPhone Air (iOS latest)..."
@make clean-packages
@if xcodebuild clean test -project Pulse.xcodeproj -scheme PulseDev -destination 'platform=iOS Simulator,name=iPhone Air,OS=latest' CODE_SIGNING_ALLOWED=NO -skipMacroValidation 2>&1 | tee /tmp/test_output.log; then \
echo "All tests completed successfully!"; \
grep -E "(Test run.*passed|Test run.*failed)" /tmp/test_output.log | tail -2; \
else \
echo "Tests failed! Here are the failure details:"; \
echo ""; \
grep -E "(✘|failed|FAIL|Fatal error|error:|Expectation failed)" /tmp/test_output.log | head -20; \
echo ""; \
echo "Full output saved to /tmp/test_output.log"; \
exit 1; \
fi
# Run tests with coverage and print app target percent
coverage:
@echo "Running tests with coverage on iPhone Air (iOS latest)..."
@rm -rf build/TestResults.xcresult
@xcodebuild clean test -project Pulse.xcodeproj -scheme PulseDev -destination 'platform=iOS Simulator,name=iPhone Air,OS=latest' -enableCodeCoverage YES -resultBundlePath build/TestResults.xcresult CODE_SIGNING_ALLOWED=NO -skipMacroValidation 2>&1 | tee /tmp/coverage_output.log | grep -E '(Testing|Test Suite|Test Case|passed|failed)' || true
@echo ""
@if grep -E "Executed .* tests, with [1-9][0-9]* failures" /tmp/coverage_output.log > /dev/null; then \
echo "Tests failed! Coverage report may be incomplete."; \
echo ""; \
echo "Failure details:"; \
grep -E "(✘|failed|FAIL|Fatal error|error:|Expectation failed)" /tmp/coverage_output.log | head -20; \
echo ""; \
echo "Full output saved to /tmp/coverage_output.log"; \
exit 1; \
elif grep -E "Executed .* tests, with 0 failures" /tmp/coverage_output.log > /dev/null; then \
echo "All tests passed!"; \
echo ""; \
echo "Coverage summary (Pulse.app):"; \
xcrun xccov view --report --only-targets build/TestResults.xcresult | awk '/Pulse.app/{print $$0}'; \
echo ""; \
echo "Use 'make coverage-report' for details."; \
else \
echo "Could not determine test status!"; \
echo ""; \
echo "Full output saved to /tmp/coverage_output.log"; \
exit 1; \
fi
# Show full per-file coverage report
coverage-report:
@test -d build/TestResults.xcresult || (echo "No xcresult found. Run 'make coverage' first." && exit 1)
@xcrun xccov view --report build/TestResults.xcresult
# Generate a simple SVG badge with current app coverage
coverage-badge:
@bash scripts/generate-coverage-badge.sh build/TestResults.xcresult
@echo "Badge generated at badges/coverage.svg"
# Run only unit tests
test-unit:
@echo "Running unit tests on iPhone Air (iOS latest)..."
@make clean-packages
@if xcodebuild clean test -project Pulse.xcodeproj -scheme PulseDev -only-testing:PulseTests -destination 'platform=iOS Simulator,name=iPhone Air,OS=latest' CODE_SIGNING_ALLOWED=NO -skipMacroValidation 2>&1 | tee /tmp/test_output.log; then \
echo "Unit tests completed successfully!"; \
grep -E "(Test run.*passed|Test run.*failed)" /tmp/test_output.log | tail -5; \
else \
echo "Unit tests failed! Here are the failure details:"; \
echo ""; \
grep -E "(✘|failed|FAIL|Fatal error|error:|Expectation failed)" /tmp/test_output.log | head -20; \
echo ""; \
echo "Full output saved to /tmp/test_output.log"; \
exit 1; \
fi
# Run only UI tests
test-ui:
@echo "Running UI tests on iPhone Air (iOS latest)..."
@make clean-packages
@if xcodebuild clean test -project Pulse.xcodeproj -scheme PulseDev -only-testing:PulseUITests -destination 'platform=iOS Simulator,name=iPhone Air,OS=latest' CODE_SIGNING_ALLOWED=NO -skipMacroValidation 2>&1 | tee /tmp/test_output.log; then \
echo "UI tests completed successfully!"; \
grep -E "(Test run.*passed|Test run.*failed)" /tmp/test_output.log | tail -1; \
else \
echo "UI tests failed! Here are the failure details:"; \
echo ""; \
grep -E "(✘|failed|FAIL|Fatal error|error:|Expectation failed)" /tmp/test_output.log | head -20; \
echo ""; \
echo "Full output saved to /tmp/test_output.log"; \
exit 1; \
fi
# Run only snapshot tests
test-snapshot:
@echo "Running snapshot tests on iPhone Air (iOS latest)..."
@make clean-packages
@if xcodebuild clean test -project Pulse.xcodeproj -scheme PulseSnapshotTests -destination 'platform=iOS Simulator,name=iPhone Air,OS=latest' CODE_SIGNING_ALLOWED=NO -skipMacroValidation 2>&1 | tee /tmp/test_output.log; then \
echo "Snapshot tests completed successfully!"; \
grep -E "(Test run.*passed|Test run.*failed)" /tmp/test_output.log | tail -1; \
else \
echo "Snapshot tests failed! Here are the failure details:"; \
echo ""; \
grep -E "(✘|failed|FAIL|Fatal error|error:|Expectation failed)" /tmp/test_output.log | head -20; \
echo ""; \
echo "Full output saved to /tmp/test_output.log"; \
exit 1; \
fi
# Run tests with full verbose output for debugging
test-debug:
@echo "Running unit tests with full verbose output for debugging..."
@echo "This will show all test output including passing tests"
@make clean-packages
@xcodebuild clean test -project Pulse.xcodeproj -scheme PulseDev -only-testing:PulseTests -destination 'platform=iOS Simulator,name=iPhone Air,OS=latest' CODE_SIGNING_ALLOWED=NO -skipMacroValidation 2>&1 | tee /tmp/test_debug.log
@echo ""
@echo "Full debug output saved to /tmp/test_debug.log"
# Test deeplink functionality specifically
deeplink-test:
@echo "Testing deeplink functionality..."
@make clean-packages
@xcodebuild clean test -project Pulse.xcodeproj -scheme PulseDev -only-testing:PulseTests/DeeplinkManagerTests -destination 'platform=iOS Simulator,name=iPhone Air,OS=latest' CODE_SIGNING_ALLOWED=NO -skipMacroValidation
@echo "Deeplink tests completed!"
# Clean generated files
clean:
@echo "Cleaning generated files..."
@rm -rf Pulse.xcodeproj
@rm -rf build/TestResults.xcresult
@echo "Cleaned!"
# Generate project and open in Xcode
xcode: generate
@echo "Opening Xcode..."
@open Pulse.xcodeproj
# Bump patch version (0.0.x)
bump-patch:
@echo "Bumping patch version..."
@CURRENT=$$(grep 'MARKETING_VERSION:' project.yml | head -1 | sed 's/.*"\(.*\)"/\1/'); \
MAJOR=$$(echo $$CURRENT | cut -d. -f1); \
MINOR=$$(echo $$CURRENT | cut -d. -f2); \
PATCH=$$(echo $$CURRENT | cut -d. -f3); \
NEW_PATCH=$$((PATCH + 1)); \
NEW_VERSION="$$MAJOR.$$MINOR.$$NEW_PATCH"; \
sed -i '' "s/MARKETING_VERSION: \"$$CURRENT\"/MARKETING_VERSION: \"$$NEW_VERSION\"/g" project.yml; \
echo "Version bumped: $$CURRENT -> $$NEW_VERSION"
# Bump minor version (0.x.0)
bump-minor:
@echo "Bumping minor version..."
@CURRENT=$$(grep 'MARKETING_VERSION:' project.yml | head -1 | sed 's/.*"\(.*\)"/\1/'); \
MAJOR=$$(echo $$CURRENT | cut -d. -f1); \
MINOR=$$(echo $$CURRENT | cut -d. -f2); \
NEW_MINOR=$$((MINOR + 1)); \
NEW_VERSION="$$MAJOR.$$NEW_MINOR.0"; \
sed -i '' "s/MARKETING_VERSION: \"$$CURRENT\"/MARKETING_VERSION: \"$$NEW_VERSION\"/g" project.yml; \
echo "Version bumped: $$CURRENT -> $$NEW_VERSION"
# Bump major version (x.0.0)
bump-major:
@echo "Bumping major version..."
@CURRENT=$$(grep 'MARKETING_VERSION:' project.yml | head -1 | sed 's/.*"\(.*\)"/\1/'); \
MAJOR=$$(echo $$CURRENT | cut -d. -f1); \
NEW_MAJOR=$$((MAJOR + 1)); \
NEW_VERSION="$$NEW_MAJOR.0.0"; \
sed -i '' "s/MARKETING_VERSION: \"$$CURRENT\"/MARKETING_VERSION: \"$$NEW_VERSION\"/g" project.yml; \
echo "Version bumped: $$CURRENT -> $$NEW_VERSION"
# Generate DocC documentation
docs:
@echo "Generating DocC documentation..."
@xcodebuild docbuild \
-project Pulse.xcodeproj \
-scheme PulseDev \
-destination 'generic/platform=iOS' \
-derivedDataPath ./DerivedData \
DOCC_EXTRACT_SWIFT_INFO_FOR_OBJC_SYMBOLS=NO \
CODE_SIGNING_ALLOWED=NO -skipMacroValidation
@echo ""
@echo "Documentation generated at:"
@echo " ./DerivedData/Build/Products/Debug-iphoneos/Pulse.doccarchive"
@echo ""
@echo "To view, run:"
@echo " open ./DerivedData/Build/Products/Debug-iphoneos/Pulse.doccarchive"