Explorar el Código

Add Catalyst testing for GHA (#5115)

Paul Beusterien hace 6 años
padre
commit
df21e99b7a

+ 9 - 0
.github/workflows/core.yml

@@ -23,6 +23,15 @@ jobs:
     - name: Build and test
       run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseCore.podspec --platforms=${{ matrix.target }}
 
+  catalyst:
+    runs-on: macOS-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: Setup Bundler
+      run: scripts/setup_bundler.sh
+    - name: Setup project and Build Catalyst
+      run: scripts/test_catalyst.sh FirebaseCore build
+
   core-cron-only:
     runs-on: macos-latest
     if: github.event_name == 'schedule'

+ 12 - 0
.github/workflows/datatransport.yml

@@ -25,6 +25,18 @@ jobs:
         ./scripts/third_party/travis/retry.sh ./scripts/pod_lib_lint.rb GoogleDataTransport.podspec --platforms=${{ matrix.target }}
         ./scripts/third_party/travis/retry.sh ./scripts/pod_lib_lint.rb GoogleDataTransportCCTSupport.podspec --platforms=${{ matrix.target }}
 
+  catalyst:
+    runs-on: macOS-latest
+    strategy:
+      matrix:
+        pod: [GoogleDataTransport, GoogleDataTransportCCTSupport]
+    steps:
+    - uses: actions/checkout@v2
+    - name: Setup Bundler
+      run: scripts/setup_bundler.sh
+    - name: Setup project and Test Catalyst
+      run: scripts/test_catalyst.sh ${{ matrix.pod }} test
+
 # Scheduled jobs
 
   datatransport-cron-only:

+ 9 - 0
.github/workflows/messaging.yml

@@ -27,6 +27,15 @@ jobs:
     - name: Build and test
       run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseMessaging.podspec --platforms=${{ matrix.target }}
 
+  catalyst:
+    runs-on: macOS-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: Setup Bundler
+      run: scripts/setup_bundler.sh
+    - name: Setup project and Build Catalyst
+      run: scripts/test_catalyst.sh FirebaseMessaging build
+
   pod-lib-lint-watchos:
     runs-on: macOS-latest
 

+ 10 - 0
.github/workflows/storage.yml

@@ -24,6 +24,16 @@ jobs:
     - name: BuildAndTest # can be replaced with pod lib lint with CocoaPods 1.10
       run: scripts/third_party/travis/retry.sh scripts/build.sh Storage all
 
+  catalyst:
+    runs-on: macOS-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: Setup Bundler
+      run: scripts/setup_bundler.sh
+    - name: Setup project and Build for Catalyst
+      # Only run the unit tests on Catalyst
+      run: scripts/test_catalyst.sh FirebaseStorage test FirebaseStorage-Unit-unit
+
   pod-lib-lint:
     runs-on: macOS-latest
 

+ 11 - 1
GoogleDataTransport/GDTCORTests/Unit/GDTCORStorageTest.m

@@ -617,7 +617,17 @@ static NSInteger target = kGDTCORTargetCCT;
                                                               options:0];
   XCTAssertNotNil(v1ArchiveData);
   GDTCORStorage *archiveStorage;
-  XCTAssertNoThrow(archiveStorage = [NSKeyedUnarchiver unarchiveObjectWithData:v1ArchiveData]);
+  if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
+    NSError *error;
+    XCTAssertNoThrow(archiveStorage =
+                         [NSKeyedUnarchiver unarchivedObjectOfClass:[GDTCORStorage class]
+                                                           fromData:v1ArchiveData
+                                                              error:&error]);
+  } else {
+#if !TARGET_OS_MACCATALYST && !TARGET_OS_WATCH
+    XCTAssertNoThrow(archiveStorage = [NSKeyedUnarchiver unarchiveObjectWithData:v1ArchiveData]);
+#endif
+  }
   XCTAssertEqual(archiveStorage.targetToEventSet[@(kGDTCORTargetCCT)].count, 6);
   XCTAssertEqual(archiveStorage.targetToEventSet[@(kGDTCORTargetFLL)].count, 12);
   XCTAssertEqual(archiveStorage.storedEvents.count, 18);

+ 8 - 3
GoogleDataTransport/GDTCORTests/Unit/GDTCORUploadCoordinatorTest.m

@@ -150,14 +150,19 @@
 
 /** Tests that encoding and decoding works without crashing. */
 - (void)testNSSecureCoding {
+#if TARGET_OS_MACCATALYST
+  // TODO - port the archiver calls to Catalyst API
+#else
   GDTCORUploadPackage *package = [[GDTCORUploadPackage alloc] initWithTarget:kGDTCORTargetTest];
   GDTCORUploadCoordinator *coordinator = [[GDTCORUploadCoordinator alloc] init];
   coordinator.targetToInFlightPackages[@(kGDTCORTargetTest)] = package;
-  NSData *data = [NSKeyedArchiver archivedDataWithRootObject:coordinator];
-
+  NSData *data;
+  GDTCORUploadCoordinator *unarchivedCoordinator;
+  data = [NSKeyedArchiver archivedDataWithRootObject:coordinator];
+  unarchivedCoordinator = [NSKeyedUnarchiver unarchiveObjectWithData:data];
   // Unarchiving the coordinator always ends up altering the singleton instance.
-  GDTCORUploadCoordinator *unarchivedCoordinator = [NSKeyedUnarchiver unarchiveObjectWithData:data];
   XCTAssertEqualObjects([GDTCORUploadCoordinator sharedInstance], unarchivedCoordinator);
+#endif
 }
 
 @end

+ 60 - 0
scripts/test_catalyst.sh

@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+
+# Copyright 2020 Google LLC
+#
+# 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.
+
+
+# USAGE: test_catalyst.sh pod build_mode [scheme]
+#
+# Builds and run tests for Catalyst since it's not yet supported by
+# `pod lib lint`.
+# The second argument should be "build" or "test". "test" indicates both build
+# and test.
+
+# TODO - Determine why test specs that include `requires_app_host` fail to
+# launch tests. Locally, they will pass if the only Objective C unit test scheme
+# is specified. However, on GHA, they fail to launch both from the test scheme
+# and the app scheme.
+
+set -xeuo pipefail
+pod="$1"
+build_mode="$2"
+
+if [[ $# -gt 2 ]]; then
+  scheme="$3"
+else
+  scheme="$pod"
+fi
+
+bundle exec pod gen --local-sources=./ --sources=https://cdn.cocoapods.org/ \
+  "$pod".podspec --platforms=ios
+
+args=(
+  # Build or test.
+  "$build_mode"
+  # Tests that require NSAssert's to fire need Debug.
+  "-configuration" "Debug"
+  # The generated workspace.
+  "-workspace" "gen/$pod/$pod.xcworkspace"
+  # Specify the app if all test should run. Otherwise, specify the test scheme.
+  "-scheme" "$scheme"
+  # Specify Catalyst.
+  "ARCHS=x86_64h" "VALID_ARCHS=x86_64h" "SUPPORTS_MACCATALYST=YES"
+  # Run on macOS.
+  "-sdk" "macosx" "-destination platform=\"OS X\"" "TARGETED_DEVICE_FAMILY=2"
+  # Disable signing.
+  "CODE_SIGN_IDENTITY=-" "CODE_SIGNING_REQUIRED=NO" "CODE_SIGNING_ALLOWED=NO"
+)
+
+xcodebuild "${args[@]}" | xcpretty