Skip to content

Commit a2888ec

Browse files
ikesyoclaude
andcommitted
Fix SwiftLint violations
- Remove trailing whitespace from test and source files - Add trailing newline to test file - Break long lines in logger statements to comply with line length rules - Improve code formatting for better readability 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4f0c166 commit a2888ec

File tree

2 files changed

+58
-42
lines changed

2 files changed

+58
-42
lines changed

Sources/ScipioKit/Producer/FrameworkProducer.swift

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ struct FrameworkProducer {
105105
to: storagesWithConsumer,
106106
cacheSystem: cacheSystem
107107
)
108-
108+
109109
if !restored.isEmpty {
110110
await shareRestoredCachesToProducers(restored, cacheSystem: cacheSystem)
111111
}
112-
112+
113113
let skipTargets = valid.union(restored)
114114
targetGraph.remove(skipTargets)
115115
}
@@ -374,21 +374,31 @@ struct FrameworkProducer {
374374
logger.warning("⚠️ Could not create VersionFile. This framework will not be cached.", metadata: .color(.yellow))
375375
}
376376
}
377-
378-
internal func shareRestoredCachesToProducers(_ restoredTargets: Set<CacheSystem.CacheTarget>, cacheSystem: CacheSystem) async {
377+
378+
internal func shareRestoredCachesToProducers(
379+
_ restoredTargets: Set<CacheSystem.CacheTarget>,
380+
cacheSystem: CacheSystem
381+
) async {
379382
let storagesWithProducer = cachePolicies.storages(for: .producer)
380383
guard !storagesWithProducer.isEmpty else { return }
381-
382-
logger.info("🔄 Sharing \(restoredTargets.count) restored framework(s) to other cache storages", metadata: .color(.blue))
383-
384+
385+
logger.info(
386+
"🔄 Sharing \(restoredTargets.count) restored framework(s) to other cache storages",
387+
metadata: .color(.blue)
388+
)
389+
384390
for storage in storagesWithProducer {
385391
await shareCachesToStorage(restoredTargets, to: storage, cacheSystem: cacheSystem)
386392
}
387393
}
388-
389-
private func shareCachesToStorage(_ targets: Set<CacheSystem.CacheTarget>, to storage: any CacheStorage, cacheSystem: CacheSystem) async {
394+
395+
private func shareCachesToStorage(
396+
_ targets: Set<CacheSystem.CacheTarget>,
397+
to storage: any CacheStorage,
398+
cacheSystem: CacheSystem
399+
) async {
390400
let chunked = targets.chunks(ofCount: storage.parallelNumber ?? CacheSystem.defaultParalellNumber)
391-
401+
392402
for chunk in chunked {
393403
await withTaskGroup(of: Void.self) { group in
394404
for target in chunk {
@@ -397,14 +407,20 @@ struct FrameworkProducer {
397407
let cacheKey = try await cacheSystem.calculateCacheKey(of: target)
398408
let hasCache = try await storage.existsValidCache(for: cacheKey)
399409
guard !hasCache else { return }
400-
410+
401411
let frameworkName = target.buildProduct.frameworkName
402412
let frameworkPath = outputDir.appendingPathComponent(frameworkName)
403-
404-
logger.info("🔄 Share \(frameworkName) to cache storage: \(storage.displayName)", metadata: .color(.blue))
413+
414+
logger.info(
415+
"🔄 Share \(frameworkName) to cache storage: \(storage.displayName)",
416+
metadata: .color(.blue)
417+
)
405418
try await storage.cacheFramework(frameworkPath, for: cacheKey)
406419
} catch {
407-
logger.warning("⚠️ Failed to share cache to \(storage.displayName): \(error.localizedDescription)", metadata: .color(.yellow))
420+
logger.warning(
421+
"⚠️ Failed to share cache to \(storage.displayName): \(error.localizedDescription)",
422+
metadata: .color(.yellow)
423+
)
408424
}
409425
}
410426
}

Tests/ScipioKitTests/FrameworkProducerTests.swift

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ import ScipioStorage
55
import Logging
66

77
struct FrameworkProducerTests {
8-
8+
99
init() {
1010
LoggingSystem.bootstrap { _ in SwiftLogNoOpLogHandler() }
1111
}
12-
12+
1313
@Test func cacheSharing() async throws {
1414
let tempDir = FileManager.default.temporaryDirectory
1515
let outputDir = tempDir.appendingPathComponent("test-output-\(UUID().uuidString)")
16-
16+
1717
try FileManager.default.createDirectory(at: outputDir, withIntermediateDirectories: true)
18-
18+
1919
defer {
2020
try? FileManager.default.removeItem(at: outputDir)
2121
}
22-
22+
2323
// Create mock cache storages
2424
let consumerStorage = MockCacheStorage(name: "consumer")
2525
let producer1Storage = MockCacheStorage(name: "producer1")
2626
let producer2Storage = MockCacheStorage(name: "producer2")
27-
27+
2828
// Create cache policies
2929
let consumerPolicy = Runner.Options.CachePolicy(
3030
storage: consumerStorage,
@@ -38,23 +38,23 @@ struct FrameworkProducerTests {
3838
storage: producer2Storage,
3939
actors: [.producer]
4040
)
41-
41+
4242
let cachePolicies = [consumerPolicy, producerPolicy1, producerPolicy2]
43-
43+
4444
// Use CacheKeyTests/AsRemotePackage fixture to avoid revision detection issues
4545
let testPackagePath = URL(fileURLWithPath: #filePath)
4646
.deletingLastPathComponent()
4747
.appendingPathComponent("Resources")
4848
.appendingPathComponent("Fixtures")
4949
.appendingPathComponent("CacheKeyTests")
5050
.appendingPathComponent("AsRemotePackage")
51-
51+
5252
let descriptionPackage = try await DescriptionPackage(
5353
packageDirectory: testPackagePath,
5454
mode: .prepareDependencies,
5555
onlyUseVersionsFromResolvedFile: false
5656
)
57-
57+
5858
let frameworkProducer = FrameworkProducer(
5959
descriptionPackage: descriptionPackage,
6060
buildOptions: BuildOptions(
@@ -74,9 +74,9 @@ struct FrameworkProducerTests {
7474
overwrite: false,
7575
outputDir: outputDir
7676
)
77-
77+
7878
let cacheSystem = CacheSystem(outputDirectory: outputDir)
79-
79+
8080
// Create a mock cache target using the real package info
8181
let package = try #require(
8282
descriptionPackage
@@ -102,29 +102,29 @@ struct FrameworkProducerTests {
102102
stripStaticDWARFSymbols: false
103103
)
104104
)
105-
105+
106106
let restoredTargets: Set<CacheSystem.CacheTarget> = [mockTarget]
107107
let mockCacheKey = try await cacheSystem.calculateCacheKey(of: mockTarget)
108-
108+
109109
// Setup initial state: producer1 has cache, producer2 doesn't
110110
try await producer1Storage.setHasCache(for: mockCacheKey, value: true)
111111
try await producer2Storage.setHasCache(for: mockCacheKey, value: false)
112-
112+
113113
// Test FrameworkProducer's cache sharing functionality
114114
await frameworkProducer.shareRestoredCachesToProducers(restoredTargets, cacheSystem: cacheSystem)
115-
115+
116116
let producer1CacheCalls = await producer1Storage.getCacheFrameworkCalls()
117117
let producer2CacheCalls = await producer2Storage.getCacheFrameworkCalls()
118-
118+
119119
// Verify behavior: producer1 already has cache so no call, producer2 doesn't have cache so gets a call
120120
#expect(producer1CacheCalls.count == 0, "Producer1 already has cache, so cacheFramework should not be called")
121121
try #require(producer2CacheCalls.count == 1, "Producer2 doesn't have cache, so cacheFramework should be called once")
122-
122+
123123
// Verify the cache call was made with correct parameters
124124
let actualFrameworkPath = producer2CacheCalls[0].frameworkPath
125125
let expectedFrameworkPath = outputDir.appendingPathComponent(buildProduct.frameworkName)
126126
#expect(actualFrameworkPath == expectedFrameworkPath, "Framework path should match")
127-
127+
128128
// Verify the cache call was made with the correct cache key
129129
let expectedCacheKey = try mockCacheKey.calculateChecksum()
130130
#expect(producer2CacheCalls[0].cacheKey == expectedCacheKey, "Cache key should match the actual cache key used")
@@ -135,7 +135,7 @@ struct FrameworkProducerTests {
135135

136136
private struct MockCacheKey: CacheKey {
137137
let targetName: String
138-
138+
139139
func calculateChecksum() throws -> String {
140140
return "mock-checksum-\(targetName)"
141141
}
@@ -146,36 +146,36 @@ private struct MockCacheKey: CacheKey {
146146
private actor MockCacheStorage: CacheStorage {
147147
let displayName: String
148148
let parallelNumber: Int? = 1
149-
149+
150150
private var hasCacheMap: [String: Bool] = [:]
151151
private var cacheFrameworkCalls: [(frameworkPath: URL, cacheKey: String)] = []
152-
152+
153153
init(name: String) {
154154
self.displayName = name
155155
}
156-
156+
157157
func existsValidCache(for cacheKey: some CacheKey) async throws -> Bool {
158158
let keyString = try cacheKey.calculateChecksum()
159159
return hasCacheMap[keyString] ?? false
160160
}
161-
161+
162162
func fetchArtifacts(for cacheKey: some CacheKey, to destinationDir: URL) async throws {
163163
// Mock implementation - no-op
164164
}
165-
165+
166166
func cacheFramework(_ frameworkPath: URL, for cacheKey: some CacheKey) async throws {
167167
let keyString = try cacheKey.calculateChecksum()
168168
let call = (frameworkPath: frameworkPath, cacheKey: keyString)
169169
cacheFrameworkCalls.append(call)
170170
}
171-
171+
172172
// Test helper methods
173173
func setHasCache(for cacheKey: some CacheKey, value: Bool) async throws {
174174
let keyString = try cacheKey.calculateChecksum()
175175
hasCacheMap[keyString] = value
176176
}
177-
177+
178178
func getCacheFrameworkCalls() -> [(frameworkPath: URL, cacheKey: String)] {
179179
return cacheFrameworkCalls
180180
}
181-
}
181+
}

0 commit comments

Comments
 (0)