forked from artsy/eigen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·195 lines (151 loc) · 9.14 KB
/
Makefile
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
WORKSPACE = Artsy.xcworkspace
SCHEME = Artsy
SCHEME_INTEGRATION_TESTS = 'Artsy Integration Tests'
CONFIGURATION = Beta
APP_PLIST = Artsy/App_Resources/Artsy-Info.plist
STICKER_PLIST = Artsy\ Stickers/Info.plist
PLIST_BUDDY = /usr/libexec/PlistBuddy
DEVICE_HOST = platform='iOS Simulator',OS='12.4',name='iPhone X'
# Disable warnings as errors for now, because we’re currently not getting the same errors during dev as deploy.
# OTHER_CFLAGS = OTHER_CFLAGS="\$$(inherited) -Werror"
GIT_COMMIT_REV = $(shell git log -n1 --format='%h')
GIT_COMMIT_SHA = $(shell git log -n1 --format='%H')
GIT_REMOTE_ORIGIN_URL = $(shell git config --get remote.origin.url)
DATE_MONTH = $(shell date "+%e %h" | tr "[:lower:]" "[:upper:]")
DATE_VERSION = $(shell date "+%Y.%m.%d.%H")
CHANGELOG = CHANGELOG.md
LOCAL_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
BRANCH = $(shell echo host=github.com | git credential fill | sed -E 'N; s/.*username=(.+)\n?.*/\1/')-$(shell git rev-parse --abbrev-ref HEAD)
## Allows us to determine how long it takes to compile a
SWIFT_BUILD_FLAGS = OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies"
## Lets us use circle caching for build artifacts
DERIVED_DATA = -derivedDataPath derived_data
RESULT_BUNDLE = -resultBundlePath derived_data/result_bundle
.PHONY: all build ci test oss pr artsy
all: ci
### Aliases
appstore: update_bundle_version
next: update_bundle_version
### General setup
# The ArtsyAPIClientKey and ArtsyAPIClientSecret are provided for open source
# contributors to learn from the app. Please don't abuse the keys or we'll
# need to rotate them and you'll make it harder for everyone to learn.
#
# As these are publicly available, they are not eligable for the Artsy Bug
# Bounty program.
oss:
git submodule update --init
bundle exec pod repo update
bundle exec pod keys set "ArtsyAPIClientSecret" "3a33d2085cbd1176153f99781bbce7c6" Artsy
bundle exec pod keys set "ArtsyAPIClientKey" "e750db60ac506978fc70"
bundle exec pod keys set "ArtsyFacebookAppID" "-"
bundle exec pod keys set "SegmentProductionWriteKey" "-"
bundle exec pod keys set "SegmentDevWriteKey" "-"
bundle exec pod keys set "AdjustProductionAppToken" "-"
bundle exec pod keys set "ArtsyEchoProductionToken" "-"
bundle exec pod keys set "SentryProductionDSN" "-"
bundle exec pod keys set "SentryStagingDSN" "-"
cp Artsy/App/Echo.json.example Artsy/App/Echo.json
artsy:
git update-index --assume-unchanged Artsy/View_Controllers/App_Navigation/ARTopMenuViewController+DeveloperExtras.m
git update-index --assume-unchanged Artsy/View_Controllers/App_Navigation/ARTopMenuViewController+SwiftDeveloperExtras.swift
certs:
echo "Don't log in with [email protected], use your account on our Artsy team."
bundle exec match appstore
distribute: change_version_to_date set_git_properties setup_fastlane_env
brew update
brew install getsentry/tools/sentry-cli
bundle exec fastlane update_plugins
bundle exec fastlane ship_beta
setup_fastlane_env:
rm -f Gemfile.lock Gemfile
cp fastlane/Gemfile .
bundle install
### General Xcode tooling
build:
set -o pipefail && xcodebuild -workspace $(WORKSPACE) -scheme $(SCHEME) -configuration '$(CONFIGURATION)' -sdk iphonesimulator build -destination $(DEVICE_HOST) $(SWIFT_BUILD_FLAGS) $(DERIVED_DATA) | tee ./xcode_build_raw.log | bundle exec xcpretty -c
build-for-tests:
set -o pipefail && xcodebuild -workspace $(WORKSPACE) -scheme $(SCHEME) -configuration Debug -sdk iphonesimulator build -destination $(DEVICE_HOST) $(SWIFT_BUILD_FLAGS) $(DERIVED_DATA) | tee ./xcode_build_raw.log | bundle exec xcpretty -c
test:
set -o pipefail && xcodebuild -workspace $(WORKSPACE) -scheme $(SCHEME) -configuration Debug test -sdk iphonesimulator -destination $(DEVICE_HOST) $(DERIVED_DATA) $(OTHER_CFLAGS) | bundle exec second_curtain 2>&1 | tee ./xcode_test_raw.log | bundle exec xcpretty -c --test --report junit --output ./test-results.xml
# This is currently not being called from our CI yaml file [!]
uitest:
set -o pipefail && xcodebuild -workspace $(WORKSPACE) -scheme $(SCHEME_INTEGRATION_TESTS) -configuration Debug test -sdk iphonesimulator -destination $(DEVICE_HOST) $(DERIVED_DATA) $(RESULT_BUNDLE) | bundle exec second_curtain 2>&1 | tee $,./xcode_uitest_raw.log | bundle exec xcpretty -c --test --report junit --output ./xcode-results.xml
### CI
ci:
if [ "$(LOCAL_BRANCH)" != "beta" ] && [ "$(LOCAL_BRANCH)" != "app_store_submission" ]; then make build-for-tests; else echo "Skipping test build on beta deploy."; fi
ci-test:
if [ "$(LOCAL_BRANCH)" != "beta" ] && [ "$(LOCAL_BRANCH)" != "app_store_submission" ]; then make test; else echo "Skipping test run on beta deploy."; fi
deploy_if_beta_branch:
if [ "$(LOCAL_BRANCH)" == "beta" ]; then make distribute; fi
deploy:
git push origin "$(LOCAL_BRANCH):beta" -f
### App Store Submission
promote_beta_to_submission:
git push origin "$(LOCAL_BRANCH):app_store_submission" -f
promote_if_app_store_submission_branch:
if [ "$(LOCAL_BRANCH)" == "app_store_submission" ]; then make _promote_beta; fi
_promote_beta: setup_fastlane_env
bundle exec fastlane update_plugins
bundle exec fastlane promote_beta
### Utility functions
update_bundle_version:
@printf 'What is the new human-readable release version? '; \
read HUMAN_VERSION; \
$(PLIST_BUDDY) -c "Set CFBundleShortVersionString $$HUMAN_VERSION" $(APP_PLIST); \
$(PLIST_BUDDY) -c "Set CFBundleShortVersionString $$HUMAN_VERSION" $(STICKER_PLIST)
stamp_date:
config/stamp --input Artsy/Resources/Images.xcassets/AppIcon.appiconset/[email protected] --output Artsy/Resources/Images.xcassets/AppIcon.appiconset/[email protected] --text "$(DATE_MONTH)"
config/stamp --input Artsy/Resources/Images.xcassets/AppIcon.appiconset/Icon-76.png --output Artsy/Resources/Images.xcassets/AppIcon.appiconset/Icon-76.png --text "$(DATE_MONTH)"
config/stamp --input Artsy/Resources/Images.xcassets/AppIcon.appiconset/[email protected] --output Artsy/Resources/Images.xcassets/AppIcon.appiconset/[email protected] --text "$(DATE_MONTH)"
config/stamp --input Artsy/Resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40.png --output Artsy/Resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40.png --text "$(DATE_MONTH)"
config/stamp --input Artsy/Resources/Images.xcassets/AppIcon.appiconset/[email protected] --output Artsy/Resources/Images.xcassets/AppIcon.appiconset/[email protected] --text "$(DATE_MONTH)"
config/stamp --input Artsy/Resources/Images.xcassets/AppIcon.appiconset/[email protected] --output Artsy/Resources/Images.xcassets/AppIcon.appiconset/[email protected] --text "$(DATE_MONTH)"
change_version_to_date:
$(PLIST_BUDDY) -c "Set CFBundleVersion $(DATE_VERSION)" $(APP_PLIST)
$(PLIST_BUDDY) -c "Set CFBundleVersion $(DATE_VERSION)" $(STICKER_PLIST)
set_git_properties:
$(PLIST_BUDDY) -c "Set GITCommitRev $(GIT_COMMIT_REV)" $(APP_PLIST)
$(PLIST_BUDDY) -c "Set GITCommitSha $(GIT_COMMIT_SHA)" $(APP_PLIST)
$(PLIST_BUDDY) -c "Set GITRemoteOriginURL $(GIT_REMOTE_ORIGIN_URL)" $(APP_PLIST)
update_echo:
# Circle has trouble accessing CocoaPods keys from the command link. ArtsyEchoProductionToken is an ENV var on CI, so reference it directly if it's non-zero length.
curl https://echo-api-production.herokuapp.com/accounts/1 --header "Http-Authorization: $(shell [[ -z "${ArtsyEchoProductionToken}" ]] && bundle exec pod keys get ArtsyEchoProductionToken Artsy || echo ${ArtsyEchoProductionToken})" --header "Accept: application/vnd.echo-v2+json" > Artsy/App/Echo.json
storyboards:
swiftgen storyboards Artsy --output Artsy/Tooling/Generated/StoryboardConstants.swift
swiftgen images Artsy --output Artsy/Tooling/Generated/StoryboardImages.swift
### Useful commands
synxify:
bundle exec synx --spaces-to-underscores -e "/Documentation" Artsy.xcodeproj
pr:
if [ "$(LOCAL_BRANCH)" == "master" ]; then echo "In master, not PRing"; else git push -u origin "$(LOCAL_BRANCH):$(BRANCH)"; open "https://github.com/artsy/eigen/pull/new/artsy:master...$(BRANCH)"; fi
push:
if [ "$(LOCAL_BRANCH)" == "master" ]; then echo "In master, not pushing"; else git push origin $(LOCAL_BRANCH):$(BRANCH); fi
fpush:
if [ "$(LOCAL_BRANCH)" == "master" ]; then echo "In master, not pushing"; else git push origin $(LOCAL_BRANCH):$(BRANCH) --force; fi
flip_table:
# Clear local caches and build files
@echo 'Clear node modules (┛ಠ_ಠ)┛彡┻━┻'
rm -rf node_modules
@echo 'Clear cocoapods directory (ノಠ益ಠ)ノ彡┻━┻'
rm -rf Pods
@echo 'Clear Xcode derived data (╯°□°)╯︵ ┻━┻'
# sometimes this fails on first try even with -rf
# but a second try takes it home
if ! rm -rf ~/Library/Developer/Xcode/DerivedData; then rm -rf ~/Library/Developer/Xcode/DerivedData; fi
@echo 'Clear relay, jest, and metro caches (┛◉Д◉)┛彡┻━┻'
rm -rf $TMPDIR/RelayFindGraphQLTags-*
rm -rf .jest
rm -rf $TMPDIR/metro*
rm -rf .metro
@echo 'Clear build artefacts (╯ರ ~ ರ)╯︵ ┻━┻'
rm -rf emission/Pod/Assets/Emission*
rm -rf emission/Pod/Assets/assets
@echo 'Reinstall dependencies ┬─┬ノ( º _ ºノ)'
bundle exec pod install --repo-update
flip_table_extreme:
# Clear global and local caches and build files
@echo 'Clean global yarn & pod caches (┛✧Д✧))┛彡┻━┻'
yarn cache clean
bundle exec pod cache clean --all
make flip_table