Browse Source

Fix watchOS build lane and reduce test flakiness

onevcat 1 month ago
parent
commit
ec6e6c3d0f
4 changed files with 37 additions and 13 deletions
  1. 2 1
      Gemfile
  2. 12 5
      Gemfile.lock
  3. 3 3
      Tests/KingfisherTests/ImageViewExtensionTests.swift
  4. 20 4
      fastlane/Fastfile

+ 2 - 1
Gemfile

@@ -2,6 +2,7 @@
 
 source "https://rubygems.org"
 
+gem "base64", "~> 0.2.0"
 gem "fastlane"
 gem "cocoapods"
-gem "xcode-install"
+gem "xcode-install"

+ 12 - 5
Gemfile.lock

@@ -23,7 +23,7 @@ GEM
     artifactory (3.0.17)
     atomos (0.1.3)
     aws-eventstream (1.4.0)
-    aws-partitions (1.1195.0)
+    aws-partitions (1.1196.0)
     aws-sdk-core (3.240.0)
       aws-eventstream (~> 1, >= 1.3.0)
       aws-partitions (~> 1, >= 1.992.0)
@@ -42,9 +42,9 @@ GEM
     aws-sigv4 (1.12.1)
       aws-eventstream (~> 1, >= 1.0.2)
     babosa (1.0.4)
-    base64 (0.3.0)
+    base64 (0.2.0)
     benchmark (0.5.0)
-    bigdecimal (4.0.0)
+    bigdecimal (4.0.1)
     claide (1.1.0)
     cocoapods (1.16.2)
       addressable (~> 2.8)
@@ -131,13 +131,14 @@ GEM
     faraday_middleware (1.2.1)
       faraday (~> 1.0)
     fastimage (2.4.0)
-    fastlane (2.229.0)
+    fastlane (2.230.0)
       CFPropertyList (>= 2.3, < 4.0.0)
       abbrev (~> 0.1.2)
       addressable (>= 2.8, < 3.0.0)
       artifactory (~> 3.0)
       aws-sdk-s3 (~> 1.0)
       babosa (>= 1.0.3, < 2.0.0)
+      base64 (~> 0.2.0)
       bundler (>= 1.12.0, < 3.0.0)
       colored (~> 1.2)
       commander (~> 4.6)
@@ -159,10 +160,12 @@ GEM
       http-cookie (~> 1.0.5)
       json (< 3.0.0)
       jwt (>= 2.1.0, < 3)
+      logger (>= 1.6, < 2.0)
       mini_magick (>= 4.9.4, < 5.0.0)
       multipart-post (>= 2.0.0, < 3.0.0)
       mutex_m (~> 0.3.0)
       naturally (~> 2.2)
+      nkf (~> 0.2.0)
       optparse (>= 0.1.1, < 1.0.0)
       plist (>= 3.1.0, < 4.0.0)
       rubyzip (>= 2.0.0, < 3.0.0)
@@ -232,7 +235,8 @@ GEM
     logger (1.7.0)
     mini_magick (4.13.2)
     mini_mime (1.1.5)
-    minitest (5.27.0)
+    minitest (6.0.0)
+      prism (~> 1.5)
     molinillo (0.8.0)
     multi_json (1.18.0)
     multipart-post (2.4.1)
@@ -241,9 +245,11 @@ GEM
     nap (1.1.0)
     naturally (2.3.0)
     netrc (0.11.0)
+    nkf (0.2.0)
     optparse (0.8.1)
     os (1.1.4)
     plist (3.7.2)
+    prism (1.6.0)
     public_suffix (4.0.7)
     rake (13.3.1)
     representable (3.2.0)
@@ -301,6 +307,7 @@ PLATFORMS
   ruby
 
 DEPENDENCIES
+  base64 (~> 0.2.0)
   cocoapods
   fastlane
   xcode-install

+ 3 - 3
Tests/KingfisherTests/ImageViewExtensionTests.swift

@@ -689,21 +689,21 @@ class ImageViewExtensionTests: XCTestCase {
         let group = DispatchGroup()
         
         group.enter()
-        imageView.kf.setImage(with: url, options: [.processor(p1)]) { result in
+        imageView.kf.setImage(with: url, options: [.processor(p1), .cacheMemoryOnly]) { result in
             XCTAssertNotNil(result.error)
             XCTAssertTrue(result.error!.isNotCurrentTask)
             group.leave()
         }
         
         group.enter()
-        imageView.kf.setImage(with: url, options: [.processor(p2)]) { result in
+        imageView.kf.setImage(with: url, options: [.processor(p2), .cacheMemoryOnly]) { result in
             XCTAssertNotNil(result.value)
             XCTAssertEqual(result.value!.image.size, size2)
             group.leave()
         }
         
         group.notify(queue: .main) { exp.fulfill() }
-        waitForExpectations(timeout: 3, handler: nil)
+        waitForExpectations(timeout: 5, handler: nil)
     }
     
     @MainActor func testMemoryImageCacheExtendingExpirationTask() {

+ 20 - 4
fastlane/Fastfile

@@ -3,6 +3,17 @@ fastlane_version "1.37.0"
 default_platform :ios
 
 platform :ios do
+  def normalize_destination(destination)
+    return destination if destination.to_s.empty?
+    return destination if destination.include?("arch=")
+    return destination unless destination.include?("Simulator")
+
+    host_arch = Actions.sh("uname -m", log: false).strip
+    return destination unless host_arch == "arm64"
+
+    "#{destination},arch=arm64"
+  end
+
   desc "Runs all the tests"
   lane :tests do
     test(destination: "platform=macOS")
@@ -24,21 +35,26 @@ platform :ios do
   end
 
   lane :test do |options|
+    destination = normalize_destination(options[:destination])
     scan(
       scheme: "Kingfisher", 
       clean: true, 
       xcargs: "SWIFT_VERSION=5.0",
-      destination: options[:destination]
+      destination: destination
     )
   end
 
   lane :build do |options|
-    gym(
+    destination = normalize_destination(options[:destination])
+    xcodebuild(
       workspace: "Kingfisher.xcworkspace",
       configuration: "Debug",
       scheme: "Kingfisher",
-      xcargs: "SWIFT_VERSION=5.0",
-      destination: options[:destination]
+      destination: destination,
+      build: true,
+      build_settings: {
+        "SWIFT_VERSION" => "5.0"
+      }
     )
   end