forked from firebase/quickstart-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-for-testing.sh
executable file
·110 lines (92 loc) · 2.88 KB
/
build-for-testing.sh
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
#!/usr/bin/env bash
# Copyright 2022 Google
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script is modified from test.sh. It's possible it into merge into test.sh
# This script build the quickstart artifacts to run tests on Firebase Test Lab.
# If we're running on the main repo (not a fork), we also run the tests along
# with the decoded GoogleService-Info.plist files.
set -euo pipefail
# Set default parameters
if [[ -z "${SPM:-}" ]]; then
SPM=false
echo "Defaulting to SPM=$SPM"
if [[ -z "${LEGACY:-}" ]]; then
LEGACY=false
echo "Defaulting to LEGACY=$LEGACY"
fi
fi
# Set have_secrets to true or false.
source scripts/check_secrets.sh
# Get Xcode version
system=$(uname -s)
case "$system" in
Darwin)
xcode_version=$(xcodebuild -version | head -n 1)
xcode_version="${xcode_version/Xcode /}"
xcode_major="${xcode_version/.*/}"
;;
*)
xcode_major="0"
;;
esac
# Initialize flags
flags=()
# Set project / workspace
if [[ "$SPM" == true ]];then
flags+=( -project "${DIR}/${SAMPLE}Example.xcodeproj" )
else
if [[ "$LEGACY" == true ]]; then
WORKSPACE="${SAMPLE}/Legacy${SAMPLE}Quickstart/${SAMPLE}Example.xcworkspace"
else
WORKSPACE="${SAMPLE}/${SAMPLE}Example.xcworkspace"
fi
flags+=( -workspace "$WORKSPACE" )
fi
# Set scheme
if [[ -z "${SCHEME:-}" ]]; then
if [[ "$SPM" == true ]];then
SCHEME="${SAMPLE}Example (${OS})"
else
SCHEME="${SAMPLE}Example${SWIFT_SUFFIX:-}"
fi
fi
flags+=( -scheme "$SCHEME" )
# Set derivedDataPath
DERIVEDDATAPATH="build-for-testing/${SCHEME}"
flags+=( -sdk "iphoneos" -derivedDataPath "$DERIVEDDATAPATH")
# Add extra flags
if [[ "$SAMPLE" == Config ]];then
flags+=( -configuration Debug )
fi
# NOTE: Add your code signature details here for running tests in Firebase Test Lab
flags+=(
CODE_SIGN_IDENTITY=""
CODE_SIGNING_REQUIRED=NO
CODE_SIGNING_ALLOWED=NO
build-for-testing
)
# Check whether to test on top of building
message="Tests did not run."
function xcb() {
echo xcodebuild "$@"
xcodebuild "$@" | xcpretty
}
# Run xcodebuild
sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
xcb "${flags[@]}"
echo "$message"
# Zip build-for-testing into MyTests.zip
cd build-for-testing/${SCHEME}/Build/Products
zip -r MyTests.zip Debug-iphoneos *.xctestrun
echo "build-for-testing/${SCHEME}/Build/Products zipped into MyTests.zip"