Skip to content

Commit 97357c0

Browse files
authored
Merge pull request SDWebImage#3710 from dreampiggy/ci/fix_watchos
Try to fix the GitHub CI again because of macOS 14.4.1
2 parents cb75c08 + 11dcb29 commit 97357c0

File tree

9 files changed

+88
-14
lines changed

9 files changed

+88
-14
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
macOSDestination: platform=macOS,arch=x86_64
5050
macCatalystDestination: platform=macOS,arch=x86_64,variant=Mac Catalyst
5151
tvOSDestination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation)
52-
watchOSDestination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)
52+
watchOSDestination: platform=watchOS Simulator,name=Apple Watch Ultra (49mm)
5353
visionOSDestination: platform=visionOS Simulator,name=Apple Vision Pro
5454
steps:
5555
- name: Checkout

Tests/SDWebImage Tests.xcodeproj/xcshareddata/xcschemes/Tests Mac.xcscheme

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
7070
</BuildableReference>
7171
</MacroExpansion>
72+
<EnvironmentVariables>
73+
<EnvironmentVariable
74+
key = "CI"
75+
value = "${CI}"
76+
isEnabled = "YES">
77+
</EnvironmentVariable>
78+
</EnvironmentVariables>
7279
</LaunchAction>
7380
<ProfileAction
7481
buildConfiguration = "Release"

Tests/SDWebImage Tests.xcodeproj/xcshareddata/xcschemes/Tests TV.xcscheme

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES"
3030
codeCoverageEnabled = "YES">
31+
<MacroExpansion>
32+
<BuildableReference
33+
BuildableIdentifier = "primary"
34+
BlueprintIdentifier = "329922292365D9A100EAFD97"
35+
BuildableName = "Tests TV.xctest"
36+
BlueprintName = "Tests TV"
37+
ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
38+
</BuildableReference>
39+
</MacroExpansion>
3140
<Testables>
3241
<TestableReference
3342
skipped = "NO">
@@ -51,6 +60,22 @@
5160
debugDocumentVersioning = "YES"
5261
debugServiceExtension = "internal"
5362
allowLocationSimulation = "YES">
63+
<MacroExpansion>
64+
<BuildableReference
65+
BuildableIdentifier = "primary"
66+
BlueprintIdentifier = "329922292365D9A100EAFD97"
67+
BuildableName = "Tests TV.xctest"
68+
BlueprintName = "Tests TV"
69+
ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
70+
</BuildableReference>
71+
</MacroExpansion>
72+
<EnvironmentVariables>
73+
<EnvironmentVariable
74+
key = "CI"
75+
value = "${CI}"
76+
isEnabled = "YES">
77+
</EnvironmentVariable>
78+
</EnvironmentVariables>
5479
</LaunchAction>
5580
<ProfileAction
5681
buildConfiguration = "Release"

Tests/SDWebImage Tests.xcodeproj/xcshareddata/xcschemes/Tests Vision.xcscheme

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@
4747
debugDocumentVersioning = "YES"
4848
debugServiceExtension = "internal"
4949
allowLocationSimulation = "YES">
50+
<MacroExpansion>
51+
<BuildableReference
52+
BuildableIdentifier = "primary"
53+
BlueprintIdentifier = "32464A882B7B0FF2006BE70E"
54+
BuildableName = "Tests Vision.xctest"
55+
BlueprintName = "Tests Vision"
56+
ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
57+
</BuildableReference>
58+
</MacroExpansion>
59+
<EnvironmentVariables>
60+
<EnvironmentVariable
61+
key = "CI"
62+
value = "${CI}"
63+
isEnabled = "YES">
64+
</EnvironmentVariable>
65+
</EnvironmentVariables>
5066
</LaunchAction>
5167
<ProfileAction
5268
buildConfiguration = "Release"

Tests/SDWebImage Tests.xcodeproj/xcshareddata/xcschemes/Tests iOS.xcscheme

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES"
3030
codeCoverageEnabled = "YES">
31+
<MacroExpansion>
32+
<BuildableReference
33+
BuildableIdentifier = "primary"
34+
BlueprintIdentifier = "DA248D52195472AA00390AB0"
35+
BuildableName = "Tests iOS.xctest"
36+
BlueprintName = "Tests iOS"
37+
ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
38+
</BuildableReference>
39+
</MacroExpansion>
3140
<Testables>
3241
<TestableReference
3342
skipped = "NO">
@@ -60,6 +69,13 @@
6069
ReferencedContainer = "container:SDWebImage Tests.xcodeproj">
6170
</BuildableReference>
6271
</MacroExpansion>
72+
<EnvironmentVariables>
73+
<EnvironmentVariable
74+
key = "CI"
75+
value = "${CI}"
76+
isEnabled = "YES">
77+
</EnvironmentVariable>
78+
</EnvironmentVariables>
6379
</LaunchAction>
6480
<ProfileAction
6581
buildConfiguration = "Release"

Tests/Tests/SDImageCoderTests.m

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,7 @@ - (void)test12ThatGIFWithoutLoopCountPlayOnce {
206206
- (void)test13ThatHEICWorks {
207207
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
208208
NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heic"];
209-
#if SD_UIKIT
210-
BOOL supportsEncoding = YES; // iPhone Simulator after Xcode 9.3 support HEIC encoding
211-
#else
212-
BOOL supportsEncoding = NO; // Travis-CI Mac env currently does not support HEIC encoding
213-
#endif
209+
BOOL supportsEncoding = !SDTestCase.isCI; // GitHub Action Mac env currently does not support HEIC encoding
214210
[self verifyCoder:[SDImageIOCoder sharedCoder]
215211
withLocalImageURL:heicURL
216212
supportsEncoding:supportsEncoding
@@ -221,9 +217,10 @@ - (void)test13ThatHEICWorks {
221217
- (void)test14ThatHEIFWorks {
222218
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
223219
NSURL *heifURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heif"];
220+
BOOL supportsEncoding = !SDTestCase.isCI; // GitHub Action Mac env currently does not support HEIC encoding
224221
[self verifyCoder:[SDImageIOCoder sharedCoder]
225222
withLocalImageURL:heifURL
226-
supportsEncoding:NO
223+
supportsEncoding:supportsEncoding
227224
isAnimatedImage:NO];
228225
}
229226
}
@@ -240,13 +237,8 @@ - (void)test15ThatCodersManagerWorks {
240237
- (void)test16ThatHEICAnimatedWorks {
241238
if (@available(iOS 13, tvOS 13, macOS 10.15, *)) {
242239
NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"heic"];
243-
#if SD_UIKIT
240+
BOOL supportsEncoding = !SDTestCase.isCI; // GitHub Action Mac env currently does not support HEIC encoding
244241
BOOL isAnimatedImage = YES;
245-
BOOL supportsEncoding = YES; // iPhone Simulator after Xcode 9.3 support HEIC encoding
246-
#else
247-
BOOL isAnimatedImage = NO; // Travis-CI Mac env does not upgrade to macOS 10.15
248-
BOOL supportsEncoding = NO; // Travis-CI Mac env currently does not support HEIC encoding
249-
#endif
250242
[self verifyCoder:[SDImageHEICCoder sharedCoder]
251243
withLocalImageURL:heicURL
252244
supportsEncoding:supportsEncoding
@@ -305,6 +297,10 @@ - (void)test20ThatImageIOAnimatedCoderAbstractClass {
305297
}
306298

307299
- (void)test21ThatEmbedThumbnailHEICWorks {
300+
BOOL supportsEncoding = !SDTestCase.isCI; // GitHub Action Mac env currently does not support HEIC encoding
301+
if (!supportsEncoding) {
302+
return;
303+
}
308304
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
309305
// The input HEIC does not contains any embed thumbnail
310306
NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heic"];

Tests/Tests/SDTestCase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ FOUNDATION_EXPORT NSString * _Nonnull const kTestAPNGPURL;
3030
@interface SDTestCase : XCTestCase
3131

3232
@property (nonatomic, strong, null_resettable) UIWindow *window;
33+
@property (nonatomic, readonly, class, getter=isCI) BOOL CI; // Check if GitHub CI
3334

3435
- (void)waitForExpectationsWithCommonTimeout;
3536
- (void)waitForExpectationsWithCommonTimeoutUsingHandler:(nullable XCWaitCompletionHandler)handler;

Tests/Tests/SDTestCase.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ - (void)waitForExpectationsWithCommonTimeoutUsingHandler:(XCWaitCompletionHandle
2727
[self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:handler];
2828
}
2929

30+
+ (BOOL)isCI {
31+
// https://docs.github.com/en/actions/learn-github-actions/variables
32+
NSDictionary *env = NSProcessInfo.processInfo.environment;
33+
static dispatch_once_t onceToken;
34+
dispatch_once(&onceToken, ^{
35+
NSLog(@"printenv: %@", env.description);
36+
});
37+
if ([[env valueForKey:@"CI"] isEqualToString:@"true"]) {
38+
return YES;
39+
}
40+
return NO;
41+
}
42+
3043
#pragma mark - Helper
3144
- (UIWindow *)window {
3245
if (!_window) {

Tests/Tests/SDUtilsTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ - (void)testSDGraphicsImageRenderer {
132132
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:size format:format];
133133
#if SD_MAC
134134
// GitHub action's Mac does not connect to a display, so the ImageRenderer color space is wrong :(
135-
if (NSProcessInfo.processInfo.environment[@"GITHUB_ACTIONS"]) {
135+
if (SDTestCase.isCI) {
136136
return;
137137
}
138138
#endif

0 commit comments

Comments
 (0)