-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (76 loc) · 2.55 KB
/
Makefile
File metadata and controls
86 lines (76 loc) · 2.55 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
PROJECT ?= Relay.xcodeproj
SCHEME ?= Relay
CONFIGURATION ?= Debug
DESTINATION ?= platform=macOS
DERIVED_DATA_PATH ?= .build/DerivedData
TEST_RESULT_BUNDLE ?= .build/TestResults.xcresult
COVERAGE_THRESHOLD ?= 80
BENCHMARK_TESTS ?= RelayTests/ReplayBenchmarkTests
TRUTHY_VALUES := 1 true yes y t on enable enabled
RUN_BENCHMARKS ?= true
RUN_BENCHMARKS_NORMALIZED := $(strip $(shell printf '%s' '$(RUN_BENCHMARKS)' | tr '[:upper:]' '[:lower:]'))
RUN_BENCHMARKS_TRUE := $(filter $(TRUTHY_VALUES),$(RUN_BENCHMARKS_NORMALIZED))
ifneq ($(RUN_BENCHMARKS_TRUE),)
BENCHMARK_ARGS :=
else
BENCHMARK_ARGS := -skip-testing:$(BENCHMARK_TESTS)
endif
.PHONY: check
check:
RUN_BENCHMARKS="$(RUN_BENCHMARKS)" lefthook run pre-commit -f --all-files --no-stage-fixed $(EXTRA_LEFTHOOK_ARGS)
.PHONY: analyze
analyze:
@set -euo pipefail; \
xcodebuild \
-project "$(PROJECT)" \
-scheme "$(SCHEME)" \
-configuration "$(CONFIGURATION)" \
-destination "$(DESTINATION)" \
-derivedDataPath "$(DERIVED_DATA_PATH)" \
-parallelizeTargets \
-showBuildTimingSummary \
-skipPackagePluginValidation \
-skipMacroValidation \
$(EXTRA_XCODEBUILD_ARGS) \
clean analyze | xcbeautify
.PHONY: test
test:
@set -euo pipefail; \
rm -rf "$(TEST_RESULT_BUNDLE)"; \
xcodebuild \
-project "$(PROJECT)" \
-scheme "$(SCHEME)" \
-configuration "$(CONFIGURATION)" \
-destination "$(DESTINATION)" \
-derivedDataPath "$(DERIVED_DATA_PATH)" \
-resultBundlePath "$(TEST_RESULT_BUNDLE)" \
-skipPackagePluginValidation \
-skipMacroValidation \
$(BENCHMARK_ARGS) \
$(EXTRA_XCODEBUILD_ARGS) \
clean test | xcbeautify; \
xcrun xcresulttool get test-results summary --path "$(TEST_RESULT_BUNDLE)"
.PHONY: verify-test-coverage
verify-test-coverage: test
@set -euo pipefail; \
report="$$(xcresultparser -o txt -c --coverage-report-format totals -s "" -t Relay.app -n "$(TEST_RESULT_BUNDLE)")"; \
coverage="$$(printf '%s\n' "$$report" | awk '/^Total coverage: / { sub(/%.*/, "", $$3); print $$3; exit }')"; \
if [ -z "$$coverage" ]; then \
echo "❌ Unable to extract coverage from report"; \
exit 1; \
fi; \
printf 'Coverage: %.2f%%\n' "$$coverage"; \
if awk 'BEGIN { exit !('"$$coverage"' < '"$(COVERAGE_THRESHOLD)"') }'; then \
echo "❌ Coverage is < $(COVERAGE_THRESHOLD)%"; \
exit 1; \
fi; \
echo "✅ Coverage is >= $(COVERAGE_THRESHOLD)%"
.PHONY: release-patch
release-patch: check
npx release-it patch
.PHONY: release-minor
release-minor: check
npx release-it minor
.PHONY: release-major
release-major: check
npx release-it major