Skip to content

Commit

Permalink
Merge pull request #302 from SDWebImage/ci
Browse files Browse the repository at this point in the history
Upgrade the github-ci to macOS 14
  • Loading branch information
dreampiggy authored Mar 9, 2024
2 parents e057a3c + fbfd186 commit 3afc34c
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 56 deletions.
117 changes: 64 additions & 53 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@ permissions:
jobs:
Pods:
name: Cocoapods Lint
runs-on: macos-13
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_14.1.app
DEVELOPER_DIR: /Applications/Xcode_15.2.app
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Cocoapods
run: gem install cocoapods --no-document --quiet

- name: Install Xcpretty
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
run: |
Expand All @@ -34,24 +40,23 @@ jobs:
Demo:
name: Run Demo
runs-on: macos-13
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_14.1.app
DEVELOPER_DIR: /Applications/Xcode_15.2.app
WORKSPACE_NAME: SDWebImageSwiftUI.xcworkspace
OSXSCHEME: SDWebImageSwiftUIDemo-macOS
iOSSCHEME: SDWebImageSwiftUIDemo
TVSCHEME: SDWebImageSwiftUIDemo-tvOS
WATCHSCHEME: SDWebImageSwiftUIDemo-watchOS WatchKit App
strategy:
matrix:
iosDestination: ["platform=iOS Simulator,name=iPhone 14 Pro"]
tvOSDestination: ["platform=tvOS Simulator,name=Apple TV"]
watchOSDestination: ["platform=watchOS Simulator,name=Apple Watch Series 8 (45mm)"]
macOSDestination: ["platform=macOS"]
macCatalystDestination: ["platform=macOS,variant=Mac Catalyst"]
iosDestination: platform=iOS Simulator,name=iPhone 15 Pro
macOSDestination: platform=macOS,arch=x86_64
macCatalystDestination: platform=macOS,arch=x86_64,variant=Mac Catalyst
tvOSDestination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation)
watchOSDestination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)
visionOSDestination: platform=visionOS Simulator,name=Apple Vision Pro
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Clean DerivedData
run: |
Expand All @@ -73,46 +78,58 @@ jobs:
- name: Run demo for OSX
run: |
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
run: |
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
run: |
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
run: |
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:
name: Unit Test
runs-on: macos-13
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_14.1.app
DEVELOPER_DIR: /Applications/Xcode_15.2.app
WORKSPACE_NAME: SDWebImageSwiftUI.xcworkspace
OSXSCHEME: SDWebImageSwiftUITests macOS
iOSSCHEME: SDWebImageSwiftUITests
TVSCHEME: SDWebImageSwiftUITests tvOS
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# use matrix to generate jobs for each platform
strategy:
fail-fast: false
matrix:
iosDestination: ["platform=iOS Simulator,name=iPhone 14 Pro"]
macOSDestination: ["platform=macOS"]
tvOSDestination: ["platform=tvOS Simulator,name=Apple TV"]
platform: [iOS, macOS, tvOS]
include:
- 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:
- 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
run: gem install cocoapods --no-document --quiet

Expand All @@ -124,47 +141,40 @@ jobs:

- name: Pod Install
run: pod install

- name: Test - ${{ matrix.iosDestination }}
run: |
set -o pipefail
xcodebuild test -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.iOSSCHEME }}" -destination "${{ matrix.iosDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c
mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/iOS
- name: Test - ${{ matrix.macOSDestination }}

- name: Clean DerivedData
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 }}
rm -rf ~/Library/Developer/Xcode/DerivedData/
mkdir DerivedData
- name: Run test
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
xcodebuild build-for-testing -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ matrix.scheme }}" -destination "${{ matrix.destination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c
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: Code Coverage
run: |
set -o pipefail
export PATH="/usr/local/opt/curl/bin:$PATH"
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) -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
bash <(curl -s https://codecov.io/bash) -v -D "./DerivedData/${{ matrix.platform }}" -J '^SDWebImageSwiftUI$' -c -X gcov -F "${{ matrix.flag }}"
Build:
name: Build Library
runs-on: macos-13
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_14.1.app
DEVELOPER_DIR: /Applications/Xcode_15.2.app
PROJECT_NAME: SDWebImageSwiftUI.xcodeproj
OSXSCHEME: SDWebImageSwiftUI macOS
iOSSCHEME: SDWebImageSwiftUI
TVSCHEME: SDWebImageSwiftUI tvOS
WATCHSCHEME: SDWebImageSwiftUI watchOS
VISIONOSSCHEME: SDWebImageSwiftUI visionOS
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Build the SwiftPM
run: |
Expand All @@ -176,7 +186,7 @@ jobs:
run: brew install carthage

- 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
run: |
Expand All @@ -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.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.VISIONOSSCHEME }}" -sdk xros -configuration Release | xcpretty -c
25 changes: 24 additions & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,27 @@ target 'SDWebImageSwiftUITests tvOS' do
project test_project_path
platform :tvos, '14.0'
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
2 changes: 1 addition & 1 deletion Tests/ImageManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ImageManagerTests: XCTestCase {

func testImageManager() throws {
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()
imageManager.setOnSuccess { image, cacheType, data in
XCTAssertNotNil(image)
Expand Down
2 changes: 1 addition & 1 deletion Tests/WebImageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class WebImageTests: XCTestCase {

func testWebImageOnSuccessWhenCacheMiss() throws {
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)
SDImageCache.shared.removeImageFromMemory(forKey: cacheKey)
SDImageCache.shared.removeImageFromDisk(forKey: cacheKey)
Expand Down

0 comments on commit 3afc34c

Please sign in to comment.