Merge pull request #3710 from dreampiggy/ci/fix_watchos

Try to fix the GitHub CI again because of macOS 14.4.1
This commit is contained in:
DreamPiggy 2024-05-07 19:32:53 +08:00 committed by GitHub
commit 97357c064b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 88 additions and 14 deletions

View File

@ -49,7 +49,7 @@ jobs:
macOSDestination: platform=macOS,arch=x86_64 macOSDestination: platform=macOS,arch=x86_64
macCatalystDestination: platform=macOS,arch=x86_64,variant=Mac Catalyst macCatalystDestination: platform=macOS,arch=x86_64,variant=Mac Catalyst
tvOSDestination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation) tvOSDestination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation)
watchOSDestination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm) watchOSDestination: platform=watchOS Simulator,name=Apple Watch Ultra (49mm)
visionOSDestination: platform=visionOS Simulator,name=Apple Vision Pro visionOSDestination: platform=visionOS Simulator,name=Apple Vision Pro
steps: steps:
- name: Checkout - name: Checkout

View File

@ -69,6 +69,13 @@
ReferencedContainer = "container:SDWebImage Tests.xcodeproj"> ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "CI"
value = "${CI}"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"

View File

@ -28,6 +28,15 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"> codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "329922292365D9A100EAFD97"
BuildableName = "Tests TV.xctest"
BlueprintName = "Tests TV"
ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables> <Testables>
<TestableReference <TestableReference
skipped = "NO"> skipped = "NO">
@ -51,6 +60,22 @@
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
debugServiceExtension = "internal" debugServiceExtension = "internal"
allowLocationSimulation = "YES"> allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "329922292365D9A100EAFD97"
BuildableName = "Tests TV.xctest"
BlueprintName = "Tests TV"
ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "CI"
value = "${CI}"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"

View File

@ -47,6 +47,22 @@
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
debugServiceExtension = "internal" debugServiceExtension = "internal"
allowLocationSimulation = "YES"> allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "32464A882B7B0FF2006BE70E"
BuildableName = "Tests Vision.xctest"
BlueprintName = "Tests Vision"
ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "CI"
value = "${CI}"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"

View File

@ -28,6 +28,15 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"> codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DA248D52195472AA00390AB0"
BuildableName = "Tests iOS.xctest"
BlueprintName = "Tests iOS"
ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables> <Testables>
<TestableReference <TestableReference
skipped = "NO"> skipped = "NO">
@ -60,6 +69,13 @@
ReferencedContainer = "container:SDWebImage Tests.xcodeproj"> ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "CI"
value = "${CI}"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"

View File

@ -206,11 +206,7 @@
- (void)test13ThatHEICWorks { - (void)test13ThatHEICWorks {
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) { if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heic"]; NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heic"];
#if SD_UIKIT BOOL supportsEncoding = !SDTestCase.isCI; // GitHub Action Mac env currently does not support HEIC encoding
BOOL supportsEncoding = YES; // iPhone Simulator after Xcode 9.3 support HEIC encoding
#else
BOOL supportsEncoding = NO; // Travis-CI Mac env currently does not support HEIC encoding
#endif
[self verifyCoder:[SDImageIOCoder sharedCoder] [self verifyCoder:[SDImageIOCoder sharedCoder]
withLocalImageURL:heicURL withLocalImageURL:heicURL
supportsEncoding:supportsEncoding supportsEncoding:supportsEncoding
@ -221,9 +217,10 @@
- (void)test14ThatHEIFWorks { - (void)test14ThatHEIFWorks {
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) { if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
NSURL *heifURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heif"]; NSURL *heifURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heif"];
BOOL supportsEncoding = !SDTestCase.isCI; // GitHub Action Mac env currently does not support HEIC encoding
[self verifyCoder:[SDImageIOCoder sharedCoder] [self verifyCoder:[SDImageIOCoder sharedCoder]
withLocalImageURL:heifURL withLocalImageURL:heifURL
supportsEncoding:NO supportsEncoding:supportsEncoding
isAnimatedImage:NO]; isAnimatedImage:NO];
} }
} }
@ -240,13 +237,8 @@
- (void)test16ThatHEICAnimatedWorks { - (void)test16ThatHEICAnimatedWorks {
if (@available(iOS 13, tvOS 13, macOS 10.15, *)) { if (@available(iOS 13, tvOS 13, macOS 10.15, *)) {
NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"heic"]; NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"heic"];
#if SD_UIKIT BOOL supportsEncoding = !SDTestCase.isCI; // GitHub Action Mac env currently does not support HEIC encoding
BOOL isAnimatedImage = YES; BOOL isAnimatedImage = YES;
BOOL supportsEncoding = YES; // iPhone Simulator after Xcode 9.3 support HEIC encoding
#else
BOOL isAnimatedImage = NO; // Travis-CI Mac env does not upgrade to macOS 10.15
BOOL supportsEncoding = NO; // Travis-CI Mac env currently does not support HEIC encoding
#endif
[self verifyCoder:[SDImageHEICCoder sharedCoder] [self verifyCoder:[SDImageHEICCoder sharedCoder]
withLocalImageURL:heicURL withLocalImageURL:heicURL
supportsEncoding:supportsEncoding supportsEncoding:supportsEncoding
@ -305,6 +297,10 @@
} }
- (void)test21ThatEmbedThumbnailHEICWorks { - (void)test21ThatEmbedThumbnailHEICWorks {
BOOL supportsEncoding = !SDTestCase.isCI; // GitHub Action Mac env currently does not support HEIC encoding
if (!supportsEncoding) {
return;
}
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) { if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
// The input HEIC does not contains any embed thumbnail // The input HEIC does not contains any embed thumbnail
NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heic"]; NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heic"];

View File

@ -30,6 +30,7 @@ FOUNDATION_EXPORT NSString * _Nonnull const kTestAPNGPURL;
@interface SDTestCase : XCTestCase @interface SDTestCase : XCTestCase
@property (nonatomic, strong, null_resettable) UIWindow *window; @property (nonatomic, strong, null_resettable) UIWindow *window;
@property (nonatomic, readonly, class, getter=isCI) BOOL CI; // Check if GitHub CI
- (void)waitForExpectationsWithCommonTimeout; - (void)waitForExpectationsWithCommonTimeout;
- (void)waitForExpectationsWithCommonTimeoutUsingHandler:(nullable XCWaitCompletionHandler)handler; - (void)waitForExpectationsWithCommonTimeoutUsingHandler:(nullable XCWaitCompletionHandler)handler;

View File

@ -27,6 +27,19 @@ NSString *const kTestAPNGPURL = @"https://upload.wikimedia.org/wikipedia/commons
[self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:handler]; [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:handler];
} }
+ (BOOL)isCI {
// https://docs.github.com/en/actions/learn-github-actions/variables
NSDictionary *env = NSProcessInfo.processInfo.environment;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSLog(@"printenv: %@", env.description);
});
if ([[env valueForKey:@"CI"] isEqualToString:@"true"]) {
return YES;
}
return NO;
}
#pragma mark - Helper #pragma mark - Helper
- (UIWindow *)window { - (UIWindow *)window {
if (!_window) { if (!_window) {

View File

@ -132,7 +132,7 @@
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:size format:format]; SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:size format:format];
#if SD_MAC #if SD_MAC
// GitHub action's Mac does not connect to a display, so the ImageRenderer color space is wrong :( // GitHub action's Mac does not connect to a display, so the ImageRenderer color space is wrong :(
if (NSProcessInfo.processInfo.environment[@"GITHUB_ACTIONS"]) { if (SDTestCase.isCI) {
return; return;
} }
#endif #endif