Merge pull request #302 from SDWebImage/ci

Upgrade the github-ci to macOS 14
This commit is contained in:
DreamPiggy 2024-03-09 23:17:32 +08:00 committed by GitHub
commit 3afc34c73b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 90 additions and 56 deletions

View File

@ -14,18 +14,24 @@ permissions:
jobs: jobs:
Pods: Pods:
name: Cocoapods Lint name: Cocoapods Lint
runs-on: macos-13 runs-on: macos-14
env: env:
DEVELOPER_DIR: /Applications/Xcode_14.1.app DEVELOPER_DIR: /Applications/Xcode_15.2.app
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Install Cocoapods - name: Install Cocoapods
run: gem install cocoapods --no-document --quiet run: gem install cocoapods --no-document --quiet
- name: Install Xcpretty - name: Install Xcpretty
run: gem install xcpretty --no-document --quiet run: gem install xcpretty --no-document --quiet
- name: Pod Update
run: pod repo update --silent
- name: Pod Install
run: pod install
- name: Run SDWebImageSwiftUI podspec lint - name: Run SDWebImageSwiftUI podspec lint
run: | run: |
@ -34,24 +40,23 @@ jobs:
Demo: Demo:
name: Run Demo name: Run Demo
runs-on: macos-13 runs-on: macos-14
env: env:
DEVELOPER_DIR: /Applications/Xcode_14.1.app DEVELOPER_DIR: /Applications/Xcode_15.2.app
WORKSPACE_NAME: SDWebImageSwiftUI.xcworkspace WORKSPACE_NAME: SDWebImageSwiftUI.xcworkspace
OSXSCHEME: SDWebImageSwiftUIDemo-macOS OSXSCHEME: SDWebImageSwiftUIDemo-macOS
iOSSCHEME: SDWebImageSwiftUIDemo iOSSCHEME: SDWebImageSwiftUIDemo
TVSCHEME: SDWebImageSwiftUIDemo-tvOS TVSCHEME: SDWebImageSwiftUIDemo-tvOS
WATCHSCHEME: SDWebImageSwiftUIDemo-watchOS WatchKit App WATCHSCHEME: SDWebImageSwiftUIDemo-watchOS WatchKit App
strategy: iosDestination: platform=iOS Simulator,name=iPhone 15 Pro
matrix: macOSDestination: platform=macOS,arch=x86_64
iosDestination: ["platform=iOS Simulator,name=iPhone 14 Pro"] macCatalystDestination: platform=macOS,arch=x86_64,variant=Mac Catalyst
tvOSDestination: ["platform=tvOS Simulator,name=Apple TV"] tvOSDestination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation)
watchOSDestination: ["platform=watchOS Simulator,name=Apple Watch Series 8 (45mm)"] watchOSDestination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)
macOSDestination: ["platform=macOS"] visionOSDestination: platform=visionOS Simulator,name=Apple Vision Pro
macCatalystDestination: ["platform=macOS,variant=Mac Catalyst"]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Clean DerivedData - name: Clean DerivedData
run: | run: |
@ -73,46 +78,58 @@ jobs:
- name: Run demo for OSX - name: Run demo for OSX
run: | run: |
set -o pipefail set -o pipefail
xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.OSXSCHEME }}" -destination "${{ matrix.macOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.OSXSCHEME }}" -destination "${{ env.macOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c
- name: Run demo for iOS - name: Run demo for iOS
run: | run: |
set -o pipefail set -o pipefail
xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.iOSSCHEME }}" -destination "${{ matrix.iosDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.iOSSCHEME }}" -destination "${{ env.iosDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c
- name: Run demo for TV - name: Run demo for TV
run: | run: |
set -o pipefail set -o pipefail
xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.TVSCHEME }}" -destination "${{ matrix.tvOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.TVSCHEME }}" -destination "${{ env.tvOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c
- name: Run demo for Watch - name: Run demo for Watch
run: | run: |
set -o pipefail set -o pipefail
xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.WATCHSCHEME }}" -destination "${{ matrix.watchOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.WATCHSCHEME }}" -destination "${{ env.watchOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c
Test: Test:
name: Unit Test name: Unit Test
runs-on: macos-13 runs-on: macos-14
env: env:
DEVELOPER_DIR: /Applications/Xcode_14.1.app DEVELOPER_DIR: /Applications/Xcode_15.2.app
WORKSPACE_NAME: SDWebImageSwiftUI.xcworkspace WORKSPACE_NAME: SDWebImageSwiftUI.xcworkspace
OSXSCHEME: SDWebImageSwiftUITests macOS CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
iOSSCHEME: SDWebImageSwiftUITests # use matrix to generate jobs for each platform
TVSCHEME: SDWebImageSwiftUITests tvOS
strategy: strategy:
fail-fast: false
matrix: matrix:
iosDestination: ["platform=iOS Simulator,name=iPhone 14 Pro"] platform: [iOS, macOS, tvOS]
macOSDestination: ["platform=macOS"] include:
tvOSDestination: ["platform=tvOS Simulator,name=Apple TV"] - platform: iOS
destination: platform=iOS Simulator,name=iPhone 15 Pro
scheme: SDWebImageSwiftUITests
flag: ios
- platform: macOS
destination: platform=macOS,arch=x86_64
scheme: SDWebImageSwiftUITests macOS
flag: macos
- platform: tvOS
destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation)
scheme: SDWebImageSwiftUITests tvOS
flag: tvos
# - platform: visionOS
# destination: platform=visionOS Simulator,name=Apple Vision Pro
# scheme: Vision
# flag: visionos
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Clean DerivedData
run: |
rm -rf ~/Library/Developer/Xcode/DerivedData/
mkdir DerivedData
- name: Install Cocoapods - name: Install Cocoapods
run: gem install cocoapods --no-document --quiet run: gem install cocoapods --no-document --quiet
@ -124,47 +141,40 @@ jobs:
- name: Pod Install - name: Pod Install
run: pod install run: pod install
- name: Clean DerivedData
run: |
rm -rf ~/Library/Developer/Xcode/DerivedData/
mkdir DerivedData
- name: Test - ${{ matrix.iosDestination }} - name: Run test
run: | run: |
set -o pipefail set -o pipefail
xcodebuild test -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.iOSSCHEME }}" -destination "${{ matrix.iosDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c xcodebuild build-for-testing -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ matrix.scheme }}" -destination "${{ matrix.destination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c
mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/iOS xcodebuild test-without-building -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ matrix.scheme }}" -destination "${{ matrix.destination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO
mv ~/Library/Developer/Xcode/DerivedData/ "./DerivedData/${{ matrix.platform }}"
- name: Test - ${{ matrix.macOSDestination }}
run: |
set -o pipefail
xcodebuild test -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.OSXSCHEME }}" -destination "${{ matrix.macOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO
mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/macOS
- name: Test - ${{ matrix.tvOSDestination }}
run: |
set -o pipefail
xcodebuild test -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.TVSCHEME }}" -destination "${{ matrix.tvOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c
mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/tvOS
- name: Code Coverage - name: Code Coverage
run: | run: |
set -o pipefail set -o pipefail
export PATH="/usr/local/opt/curl/bin:$PATH" export PATH="/usr/local/opt/curl/bin:$PATH"
curl --version curl --version
bash <(curl -s https://codecov.io/bash) -D './DerivedData/macOS' -J '^SDWebImageSwiftUI$' -c -X gcov -F macos bash <(curl -s https://codecov.io/bash) -v -D "./DerivedData/${{ matrix.platform }}" -J '^SDWebImageSwiftUI$' -c -X gcov -F "${{ matrix.flag }}"
bash <(curl -s https://codecov.io/bash) -D './DerivedData/iOS' -J '^SDWebImageSwiftUI$' -c -X gcov -F ios
bash <(curl -s https://codecov.io/bash) -D './DerivedData/tvOS' -J '^SDWebImageSwiftUI$' -c -X gcov -F tvos
Build: Build:
name: Build Library name: Build Library
runs-on: macos-13 runs-on: macos-14
env: env:
DEVELOPER_DIR: /Applications/Xcode_14.1.app DEVELOPER_DIR: /Applications/Xcode_15.2.app
PROJECT_NAME: SDWebImageSwiftUI.xcodeproj PROJECT_NAME: SDWebImageSwiftUI.xcodeproj
OSXSCHEME: SDWebImageSwiftUI macOS OSXSCHEME: SDWebImageSwiftUI macOS
iOSSCHEME: SDWebImageSwiftUI iOSSCHEME: SDWebImageSwiftUI
TVSCHEME: SDWebImageSwiftUI tvOS TVSCHEME: SDWebImageSwiftUI tvOS
WATCHSCHEME: SDWebImageSwiftUI watchOS WATCHSCHEME: SDWebImageSwiftUI watchOS
VISIONOSSCHEME: SDWebImageSwiftUI visionOS
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Build the SwiftPM - name: Build the SwiftPM
run: | run: |
@ -176,7 +186,7 @@ jobs:
run: brew install carthage run: brew install carthage
- name: Carthage Update - name: Carthage Update
run: ./carthage.sh update --platform "iOS, tvOS, macOS, watchOS" run: ./carthage.sh update --platform "iOS, tvOS, macOS, watchOS, visionOS"
- name: Build as dynamic frameworks - name: Build as dynamic frameworks
run: | run: |
@ -185,3 +195,4 @@ jobs:
xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "${{ env.iOSSCHEME }}" -sdk iphoneos -configuration Release | xcpretty -c xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "${{ env.iOSSCHEME }}" -sdk iphoneos -configuration Release | xcpretty -c
xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "${{ env.TVSCHEME }}" -sdk appletvos -configuration Release | xcpretty -c xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "${{ env.TVSCHEME }}" -sdk appletvos -configuration Release | xcpretty -c
xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "${{ env.WATCHSCHEME }}" -sdk watchos -configuration Release | xcpretty -c xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "${{ env.WATCHSCHEME }}" -sdk watchos -configuration Release | xcpretty -c
xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "${{ env.VISIONOSSCHEME }}" -sdk xros -configuration Release | xcpretty -c

25
Podfile
View File

@ -59,4 +59,27 @@ target 'SDWebImageSwiftUITests tvOS' do
project test_project_path project test_project_path
platform :tvos, '14.0' platform :tvos, '14.0'
all_test_pods all_test_pods
end end
# Inject macro during SDWebImage Demo and Tests
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
if target.product_name == 'SDWebImage'
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) SD_CHECK_CGIMAGE_RETAIN_SOURCE=1'
end
elsif target.product_name == 'SDWebImageSwiftUI'
# Do nothing
else
target.build_configurations.each do |config|
# Override the min deployment target for some test specs to workaround `libarclite.a` missing issue
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.11'
config.build_settings['TVOS_DEPLOYMENT_TARGET'] = '9.0'
config.build_settings['WATCHOS_DEPLOYMENT_TARGET'] = '2.0'
config.build_settings['XROS_DEPLOYMENT_TARGET'] = '1.0'
end
end
end
end

View File

@ -17,7 +17,7 @@ class ImageManagerTests: XCTestCase {
func testImageManager() throws { func testImageManager() throws {
let expectation = self.expectation(description: "ImageManager usage with Combine") let expectation = self.expectation(description: "ImageManager usage with Combine")
let imageUrl = URL(string: "https://via.placeholder.com/500x500.jpg") let imageUrl = URL(string: "https://placehold.co/500x500.jpg")
let imageManager = ImageManager() let imageManager = ImageManager()
imageManager.setOnSuccess { image, cacheType, data in imageManager.setOnSuccess { image, cacheType, data in
XCTAssertNotNil(image) XCTAssertNotNil(image)

View File

@ -137,7 +137,7 @@ class WebImageTests: XCTestCase {
func testWebImageOnSuccessWhenCacheMiss() throws { func testWebImageOnSuccessWhenCacheMiss() throws {
let expectation = self.expectation(description: "WebImage onSuccess when cache miss") let expectation = self.expectation(description: "WebImage onSuccess when cache miss")
let imageUrl = URL(string: "http://via.placeholder.com/100x100.png") let imageUrl = URL(string: "https://placehold.co/100x100.png")
let cacheKey = SDWebImageManager.shared.cacheKey(for: imageUrl) let cacheKey = SDWebImageManager.shared.cacheKey(for: imageUrl)
SDImageCache.shared.removeImageFromMemory(forKey: cacheKey) SDImageCache.shared.removeImageFromMemory(forKey: cacheKey)
SDImageCache.shared.removeImageFromDisk(forKey: cacheKey) SDImageCache.shared.removeImageFromDisk(forKey: cacheKey)