Skip to content

Commit df21e99

Browse files
authored
Add Catalyst testing for GHA (#5115)
1 parent 6fca4b0 commit df21e99

File tree

7 files changed

+119
-4
lines changed

7 files changed

+119
-4
lines changed

.github/workflows/core.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ jobs:
2323
- name: Build and test
2424
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseCore.podspec --platforms=${{ matrix.target }}
2525

26+
catalyst:
27+
runs-on: macOS-latest
28+
steps:
29+
- uses: actions/checkout@v2
30+
- name: Setup Bundler
31+
run: scripts/setup_bundler.sh
32+
- name: Setup project and Build Catalyst
33+
run: scripts/test_catalyst.sh FirebaseCore build
34+
2635
core-cron-only:
2736
runs-on: macos-latest
2837
if: github.event_name == 'schedule'

.github/workflows/datatransport.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ jobs:
2525
./scripts/third_party/travis/retry.sh ./scripts/pod_lib_lint.rb GoogleDataTransport.podspec --platforms=${{ matrix.target }}
2626
./scripts/third_party/travis/retry.sh ./scripts/pod_lib_lint.rb GoogleDataTransportCCTSupport.podspec --platforms=${{ matrix.target }}
2727
28+
catalyst:
29+
runs-on: macOS-latest
30+
strategy:
31+
matrix:
32+
pod: [GoogleDataTransport, GoogleDataTransportCCTSupport]
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Setup Bundler
36+
run: scripts/setup_bundler.sh
37+
- name: Setup project and Test Catalyst
38+
run: scripts/test_catalyst.sh ${{ matrix.pod }} test
39+
2840
# Scheduled jobs
2941

3042
datatransport-cron-only:

.github/workflows/messaging.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ jobs:
2727
- name: Build and test
2828
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseMessaging.podspec --platforms=${{ matrix.target }}
2929

30+
catalyst:
31+
runs-on: macOS-latest
32+
steps:
33+
- uses: actions/checkout@v2
34+
- name: Setup Bundler
35+
run: scripts/setup_bundler.sh
36+
- name: Setup project and Build Catalyst
37+
run: scripts/test_catalyst.sh FirebaseMessaging build
38+
3039
pod-lib-lint-watchos:
3140
runs-on: macOS-latest
3241

.github/workflows/storage.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ jobs:
2424
- name: BuildAndTest # can be replaced with pod lib lint with CocoaPods 1.10
2525
run: scripts/third_party/travis/retry.sh scripts/build.sh Storage all
2626

27+
catalyst:
28+
runs-on: macOS-latest
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Setup Bundler
32+
run: scripts/setup_bundler.sh
33+
- name: Setup project and Build for Catalyst
34+
# Only run the unit tests on Catalyst
35+
run: scripts/test_catalyst.sh FirebaseStorage test FirebaseStorage-Unit-unit
36+
2737
pod-lib-lint:
2838
runs-on: macOS-latest
2939

GoogleDataTransport/GDTCORTests/Unit/GDTCORStorageTest.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,17 @@ - (void)testMigrationFromOldVersion {
617617
options:0];
618618
XCTAssertNotNil(v1ArchiveData);
619619
GDTCORStorage *archiveStorage;
620-
XCTAssertNoThrow(archiveStorage = [NSKeyedUnarchiver unarchiveObjectWithData:v1ArchiveData]);
620+
if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
621+
NSError *error;
622+
XCTAssertNoThrow(archiveStorage =
623+
[NSKeyedUnarchiver unarchivedObjectOfClass:[GDTCORStorage class]
624+
fromData:v1ArchiveData
625+
error:&error]);
626+
} else {
627+
#if !TARGET_OS_MACCATALYST && !TARGET_OS_WATCH
628+
XCTAssertNoThrow(archiveStorage = [NSKeyedUnarchiver unarchiveObjectWithData:v1ArchiveData]);
629+
#endif
630+
}
621631
XCTAssertEqual(archiveStorage.targetToEventSet[@(kGDTCORTargetCCT)].count, 6);
622632
XCTAssertEqual(archiveStorage.targetToEventSet[@(kGDTCORTargetFLL)].count, 12);
623633
XCTAssertEqual(archiveStorage.storedEvents.count, 18);

GoogleDataTransport/GDTCORTests/Unit/GDTCORUploadCoordinatorTest.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,19 @@ - (void)testThatAFailedUploadResultsInAnEventualRetry {
150150

151151
/** Tests that encoding and decoding works without crashing. */
152152
- (void)testNSSecureCoding {
153+
#if TARGET_OS_MACCATALYST
154+
// TODO - port the archiver calls to Catalyst API
155+
#else
153156
GDTCORUploadPackage *package = [[GDTCORUploadPackage alloc] initWithTarget:kGDTCORTargetTest];
154157
GDTCORUploadCoordinator *coordinator = [[GDTCORUploadCoordinator alloc] init];
155158
coordinator.targetToInFlightPackages[@(kGDTCORTargetTest)] = package;
156-
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:coordinator];
157-
159+
NSData *data;
160+
GDTCORUploadCoordinator *unarchivedCoordinator;
161+
data = [NSKeyedArchiver archivedDataWithRootObject:coordinator];
162+
unarchivedCoordinator = [NSKeyedUnarchiver unarchiveObjectWithData:data];
158163
// Unarchiving the coordinator always ends up altering the singleton instance.
159-
GDTCORUploadCoordinator *unarchivedCoordinator = [NSKeyedUnarchiver unarchiveObjectWithData:data];
160164
XCTAssertEqualObjects([GDTCORUploadCoordinator sharedInstance], unarchivedCoordinator);
165+
#endif
161166
}
162167

163168
@end

scripts/test_catalyst.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2020 Google LLC
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+
# USAGE: test_catalyst.sh pod build_mode [scheme]
19+
#
20+
# Builds and run tests for Catalyst since it's not yet supported by
21+
# `pod lib lint`.
22+
# The second argument should be "build" or "test". "test" indicates both build
23+
# and test.
24+
25+
# TODO - Determine why test specs that include `requires_app_host` fail to
26+
# launch tests. Locally, they will pass if the only Objective C unit test scheme
27+
# is specified. However, on GHA, they fail to launch both from the test scheme
28+
# and the app scheme.
29+
30+
set -xeuo pipefail
31+
pod="$1"
32+
build_mode="$2"
33+
34+
if [[ $# -gt 2 ]]; then
35+
scheme="$3"
36+
else
37+
scheme="$pod"
38+
fi
39+
40+
bundle exec pod gen --local-sources=./ --sources=https://cdn.cocoapods.org/ \
41+
"$pod".podspec --platforms=ios
42+
43+
args=(
44+
# Build or test.
45+
"$build_mode"
46+
# Tests that require NSAssert's to fire need Debug.
47+
"-configuration" "Debug"
48+
# The generated workspace.
49+
"-workspace" "gen/$pod/$pod.xcworkspace"
50+
# Specify the app if all test should run. Otherwise, specify the test scheme.
51+
"-scheme" "$scheme"
52+
# Specify Catalyst.
53+
"ARCHS=x86_64h" "VALID_ARCHS=x86_64h" "SUPPORTS_MACCATALYST=YES"
54+
# Run on macOS.
55+
"-sdk" "macosx" "-destination platform=\"OS X\"" "TARGETED_DEVICE_FAMILY=2"
56+
# Disable signing.
57+
"CODE_SIGN_IDENTITY=-" "CODE_SIGNING_REQUIRED=NO" "CODE_SIGNING_ALLOWED=NO"
58+
)
59+
60+
xcodebuild "${args[@]}" | xcpretty

0 commit comments

Comments
 (0)