Skip to content

Commit d85f160

Browse files
authored
Create CI build script for spm quickstarts (#1253)
* Add universal spm ci script * Remove redundant exit status * Add spm test script * Fix unbound variable
1 parent 15abd85 commit d85f160

File tree

2 files changed

+58
-10
lines changed

2 files changed

+58
-10
lines changed

.github/workflows/abtesting.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,12 @@ jobs:
4747
LEGACY: true
4848
- name: Build and Test SwiftUI
4949
run: |
50-
cd abtesting
51-
../scripts/install_prereqs/abtesting.sh
52-
xcodebuild \
53-
-project 'ABTestingExample.xcodeproj' \
54-
-scheme 'ABTestingExample (iOS)' \
55-
-sdk iphonesimulator \
56-
-destination 'platform=iOS Simulator,name=iPhone 11' \
57-
build \
58-
test \
59-
| xcpretty
50+
./scripts/test_spm.sh
6051
env:
6152
SAMPLE: ABTesting
53+
DIR: abtesting
54+
OS: iOS
55+
PLATFORM: iphone
56+
DEVICE: iPhone 11
57+
SWIFT_DEFINES: ""
58+
secrets_passphrase: ${{ secrets.GHASECRETSGPGPASSPHRASE1 }}

scripts/test_spm.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2021 Google
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
# Build the quickstart. If we're running on the main repo (not a fork), we
19+
# also run the tests along with the decoded GoogleService-Info.plist files.
20+
21+
set -euo pipefail
22+
23+
# Set have_secrets to true or false.
24+
have_secrets=false
25+
26+
. ./scripts/check_secrets.sh
27+
28+
if [[ "$have_secrets" == true ]]; then
29+
xcodebuild \
30+
-project "${DIR}/${SAMPLE}Example.xcodeproj" \
31+
-scheme "${SAMPLE}Example (${OS})" \
32+
-sdk "${PLATFORM}simulator" \
33+
-destination "platform=${OS} Simulator,name=${DEVICE}" \
34+
build \
35+
test \
36+
ONLY_ACTIVE_ARCH=YES \
37+
OTHER_SWIFT_FLAGS=${SWIFT_DEFINES} \
38+
| xcpretty
39+
else
40+
# Skip running tests if GoogleService-Info.plist's weren't decoded.
41+
xcodebuild \
42+
-project "${DIR}/${SAMPLE}Example.xcodeproj" \
43+
-scheme "${SAMPLE}Example (${OS})" \
44+
-sdk "${PLATFORM}simulator" \
45+
-destination "platform=${OS} Simulator,name=${DEVICE}" \
46+
build \
47+
ONLY_ACTIVE_ARCH=YES \
48+
OTHER_SWIFT_FLAGS=${SWIFT_DEFINES} \
49+
| xcpretty
50+
echo "Missing secrets: tests did not run."
51+
fi

0 commit comments

Comments
 (0)