forked from tuist/tuist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upload binary cache and selective testing hashes to the server (tuist…
…#7278) * Upload binary cache and selective testing hashes to the server * Address PR feedback
- Loading branch information
Showing
42 changed files
with
1,661 additions
and
802 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
|
||
public enum RunCacheHit: Codable, Equatable { | ||
case miss, local, remote | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Foundation | ||
|
||
public struct RunCacheTargetMetadata: Codable, Hashable { | ||
public let hash: String | ||
public let hit: RunCacheHit | ||
|
||
public init( | ||
hash: String, | ||
hit: RunCacheHit | ||
) { | ||
self.hash = hash | ||
self.hit = hit | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Foundation | ||
|
||
/// Graph to be sent with the run | ||
public struct RunGraph: Codable, Equatable { | ||
public let name: String | ||
public let projects: [RunProject] | ||
|
||
public init( | ||
name: String, | ||
projects: [RunProject] | ||
) { | ||
self.name = name | ||
self.projects = projects | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Foundation | ||
import Path | ||
import ServiceContextModule | ||
import XcodeGraph | ||
|
||
/// Storage for run metadata, such as binary cache. | ||
public actor RunMetadataStorage { | ||
public init() {} | ||
|
||
/// A unique ID associated with a specific run | ||
public var runId = UUID().uuidString | ||
/// Graph associated with the current run | ||
public private(set) var graph: Graph? | ||
public func update(graph: Graph?) { | ||
self.graph = graph | ||
} | ||
|
||
/// Binar cache-specific cache items | ||
public private(set) var binaryCacheItems: [AbsolutePath: [String: CacheItem]] = [:] | ||
public func update(binaryCacheItems: [AbsolutePath: [String: CacheItem]]) { | ||
self.binaryCacheItems = binaryCacheItems | ||
} | ||
|
||
/// Selective testing-specific cache items | ||
public private(set) var selectiveTestingCacheItems: [AbsolutePath: [String: CacheItem]] = [:] | ||
public func update(selectiveTestingCacheItems: [AbsolutePath: [String: CacheItem]]) { | ||
self.selectiveTestingCacheItems = selectiveTestingCacheItems | ||
} | ||
|
||
/// Preview ID associated with the current run | ||
public private(set) var previewId: String? | ||
public func update(previewId: String?) { | ||
self.previewId = previewId | ||
} | ||
} | ||
|
||
private enum RunMetadataStorageContextKey: ServiceContextKey { | ||
typealias Value = RunMetadataStorage | ||
} | ||
|
||
extension ServiceContext { | ||
public var runMetadataStorage: RunMetadataStorage? { | ||
get { | ||
self[RunMetadataStorageContextKey.self] | ||
} set { | ||
self[RunMetadataStorageContextKey.self] = newValue | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Path | ||
import XcodeGraph | ||
|
||
/// A simplified `GraphTarget` to store in `CommandEvent`. | ||
public struct RunProject: Codable, Hashable { | ||
public let name: String | ||
public let path: RelativePath | ||
public let targets: [RunTarget] | ||
|
||
public init( | ||
name: String, | ||
path: RelativePath, | ||
targets: [RunTarget] | ||
) { | ||
self.name = name | ||
self.path = path | ||
self.targets = targets | ||
} | ||
} | ||
|
||
#if DEBUG | ||
extension RunProject { | ||
public static func test( | ||
name: String = "Project", | ||
// swiftlint:disable:next force_try | ||
path: RelativePath = try! RelativePath(validating: "App"), | ||
targets: [RunTarget] = [] | ||
) -> Self { | ||
Self( | ||
name: name, | ||
path: path, | ||
targets: targets | ||
) | ||
} | ||
} | ||
#endif |
Oops, something went wrong.