@@ -23,7 +23,8 @@ set -euo pipefail
23
23
readonly NIGHTLY_RELEASE_TESTING=" nightly_release_testing"
24
24
readonly PRERELEASE_TESTING=" prerelease_testing"
25
25
26
- # All script logic is contained in functions. The main function is called at the end.
26
+ # All script logic is contained in functions. The main function is called at
27
+ # the end.
27
28
# Global variables:
28
29
# - readonly constants are defined at the top.
29
30
# - scripts_dir and root_dir are set after constants.
@@ -38,23 +39,30 @@ Usage: $(basename "$0") <sample_name> [testing_mode]
38
39
This script sets up a quickstart sample for SPM integration testing.
39
40
40
41
ARGUMENTS:
41
- <sample_name> The name of the quickstart sample directory (e.g., "authentication").
42
+ <sample_name> The name of the quickstart sample directory
43
+ (e.g., "authentication").
42
44
[testing_mode] Optional. Specifies the testing mode. Can be one of:
43
- - "${NIGHTLY_RELEASE_TESTING} ": Points SPM to the latest CocoaPods tag.
44
- - "${PRERELEASE_TESTING} ": Points SPM to the tip of the main branch.
45
+ - "${NIGHTLY_RELEASE_TESTING} ": Points SPM to the latest
46
+ CocoaPods tag.
47
+ - "${PRERELEASE_TESTING} ": Points SPM to the tip of the main
48
+ branch.
45
49
- (default): Points SPM to the current commit for PR testing.
46
50
47
51
ENVIRONMENT VARIABLES:
48
52
QUICKSTART_REPO: Optional. Path to a local clone of the quickstart-ios repo.
49
53
If not set, the script will clone it from GitHub.
50
- Example: QUICKSTART_REPO=/path/to/quickstart-ios $( basename " $0 " ) authentication
54
+ Example:
55
+ QUICKSTART_REPO=/path/to/quickstart-ios $( basename " $0 " ) authentication
51
56
52
57
QUICKSTART_BRANCH: Optional. The branch to checkout in the quickstart repo.
53
58
Defaults to the repo's default branch.
54
- Example: QUICKSTART_BRANCH=my-feature-branch $( basename " $0 " ) authentication
59
+ Example:
60
+ QUICKSTART_BRANCH=my-feature-branch $( basename " $0 " ) authentication
55
61
56
- BYPASS_SECRET_CHECK: Optional. Set to "true" to bypass the CI secret check for local runs.
57
- Example: BYPASS_SECRET_CHECK=true $( basename " $0 " ) authentication
62
+ BYPASS_SECRET_CHECK: Optional. Set to "true" to bypass the CI secret check
63
+ for local runs.
64
+ Example:
65
+ BYPASS_SECRET_CHECK=true $( basename " $0 " ) authentication
58
66
59
67
DEBUG: Optional. Set to "true" to enable shell trace mode (` set -x` ).
60
68
Example: DEBUG=true $( basename " $0 " ) authentication
@@ -77,13 +85,16 @@ setup_quickstart_repo() {
77
85
if [[ -n " ${QUICKSTART_REPO:- } " ]]; then
78
86
# If the user provided a path, it must be a valid directory.
79
87
if [[ ! -d " ${QUICKSTART_REPO} " ]]; then
80
- echo " Error: QUICKSTART_REPO is set to '${QUICKSTART_REPO} ', but this is not a valid directory." >&2
88
+ echo " Error: QUICKSTART_REPO is set to '${QUICKSTART_REPO} '," \
89
+ " but this is not a valid directory." >&2
81
90
exit 1
82
91
fi
83
92
echo " Using local quickstart repository at ${QUICKSTART_REPO} " >&2
84
93
quickstart_dir=" ${QUICKSTART_REPO} "
85
- if ! (cd " ${quickstart_dir} " && git rev-parse --is-inside-work-tree > /dev/null 2>&1 ); then
86
- echo " Error: QUICKSTART_REPO ('${quickstart_dir} ') is not a git repository." >&2
94
+ if ! (cd " ${quickstart_dir} " && \
95
+ git rev-parse --is-inside-work-tree > /dev/null 2>&1 ); then
96
+ echo " Error: QUICKSTART_REPO ('${quickstart_dir} ') is not a git" \
97
+ " repository." >&2
87
98
exit 1
88
99
fi
89
100
else
@@ -95,7 +106,8 @@ setup_quickstart_repo() {
95
106
echo " Cloning quickstart repository into '${quickstart_dir} ' directory..." >&2
96
107
# Do a partial, sparse clone to speed up CI. See
97
108
# https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
98
- git clone --filter=blob:none --sparse https://github.com/firebase/quickstart-ios.git " ${quickstart_dir} "
109
+ git clone --filter=blob:none --sparse \
110
+ https://github.com/firebase/quickstart-ios.git " ${quickstart_dir} "
99
111
fi
100
112
(
101
113
cd " ${quickstart_dir} "
@@ -137,29 +149,34 @@ update_spm_dependency() {
137
149
" ${NIGHTLY_RELEASE_TESTING} " )
138
150
# For release testing, find the latest CocoaPods tag.
139
151
local latest_tag
140
- latest_tag=$( git -C " $root_dir " tag -l " CocoaPods-*" --sort=-v:refname | awk ' /^CocoaPods-[0-9]+\.[0-9]+\.[0-9]+$/ { print; exit }' )
152
+ latest_tag=$( git -C " $root_dir " tag -l " CocoaPods-*" --sort=-v:refname | \
153
+ awk ' /^CocoaPods-[0-9]+\.[0-9]+\.[0-9]+$/ { print; exit }' )
141
154
if [[ -z " $latest_tag " ]]; then
142
155
echo " Error: Could not find a 'CocoaPods-X.Y.Z' tag." >&2
143
156
exit 1
144
157
fi
145
158
local tag_revision
146
159
tag_revision=$( git -C " $root_dir " rev-list -n 1 " $latest_tag " )
147
- echo " Setting SPM dependency to revision for tag ${latest_tag} : ${tag_revision} "
148
- " $scripts_dir /update_firebase_spm_dependency.sh" " $absolute_project_file " --revision " $tag_revision "
160
+ echo " Setting SPM dependency to revision for tag ${latest_tag} :" \
161
+ " ${tag_revision} "
162
+ " $scripts_dir /update_firebase_spm_dependency.sh" \
163
+ " $absolute_project_file " --revision " $tag_revision "
149
164
;;
150
165
151
166
" ${PRERELEASE_TESTING} " )
152
167
# For prerelease testing, point to the tip of the main branch.
153
168
echo " Setting SPM dependency to the tip of the main branch."
154
- " $scripts_dir /update_firebase_spm_dependency.sh" " $absolute_project_file " --prerelease
169
+ " $scripts_dir /update_firebase_spm_dependency.sh" \
170
+ " $absolute_project_file " --prerelease
155
171
;;
156
172
157
173
* )
158
174
# For PR testing, point to the current commit.
159
175
local current_revision
160
176
current_revision=$( git -C " $root_dir " rev-parse HEAD)
161
177
echo " Setting SPM dependency to current revision: ${current_revision} "
162
- " $scripts_dir /update_firebase_spm_dependency.sh" " $absolute_project_file " --revision " $current_revision "
178
+ " $scripts_dir /update_firebase_spm_dependency.sh" \
179
+ " $absolute_project_file " --revision " $current_revision "
163
180
;;
164
181
esac
165
182
}
@@ -196,8 +213,9 @@ main() {
196
213
# Source function to check if CI secrets are available.
197
214
source " $scripts_dir /check_secrets.sh"
198
215
199
- # Some quickstarts may not need a real GoogleService-Info.plist for their tests.
200
- # When QUICKSTART_REPO is set, we are running locally and should skip the secrets check.
216
+ # Some quickstarts may not need a real GoogleService-Info.plist for their
217
+ # tests. When QUICKSTART_REPO is set, we are running locally and should skip
218
+ # the secrets check.
201
219
if [[ -z " ${QUICKSTART_REPO:- } " ]] && \
202
220
[[ " ${BYPASS_SECRET_CHECK:- } " != " true" ]] && \
203
221
! check_secrets && \
@@ -219,13 +237,15 @@ main() {
219
237
220
238
# Find the .xcodeproj file within the sample directory.
221
239
# Fail if there isn't exactly one.
222
- # Enable nullglob to ensure the glob expands to an empty list if no files are found.
240
+ # Enable nullglob to ensure the glob expands to an empty list if no files
241
+ # are found.
223
242
shopt -s nullglob
224
243
local project_files=(" ${quickstart_project_dir} " /* .xcodeproj)
225
244
# Restore default globbing behavior.
226
245
shopt -u nullglob
227
246
if [[ " ${# project_files[@]} " -ne 1 ]]; then
228
- echo " Error: Expected 1 .xcodeproj file in '${quickstart_project_dir} ', but found ${# project_files[@]} ." >&2
247
+ echo " Error: Expected 1 .xcodeproj file in" \
248
+ " '${quickstart_project_dir} ', but found ${# project_files[@]} ." >&2
229
249
exit 1
230
250
fi
231
251
local project_file=" ${project_files[0]} "
@@ -234,4 +254,4 @@ main() {
234
254
}
235
255
236
256
# Run the main function with all provided arguments.
237
- main " $@ "
257
+ main " $@ "
0 commit comments