-
Notifications
You must be signed in to change notification settings - Fork 1.4k
identity improvements #3323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
identity improvements #3323
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,13 +170,16 @@ extension SwiftPackageTool { | |
let workspace = try swiftTool.getActiveWorkspace() | ||
let root = try swiftTool.getWorkspaceRoot() | ||
|
||
let manifests = try temp_await { | ||
let rootManifests = try temp_await { | ||
workspace.loadRootManifests(packages: root.packages, diagnostics: swiftTool.diagnostics, completion: $0) | ||
} | ||
guard let manifest = manifests.first else { return } | ||
guard let rootManifest = rootManifests.first else { | ||
throw StringError("invalid manifests at \(root.packages)") | ||
} | ||
|
||
let builder = PackageBuilder( | ||
manifest: manifest, | ||
identity: .root(name: rootManifest.name), | ||
manifest: rootManifest, | ||
productFilter: .everything, | ||
path: try swiftTool.getPackageRoot(), | ||
xcTestMinimumDeploymentTargets: MinimumDeploymentTarget.default.xcTestMinimumDeploymentTargets, | ||
|
@@ -237,12 +240,16 @@ extension SwiftPackageTool { | |
// Get the root package. | ||
let workspace = try swiftTool.getActiveWorkspace() | ||
let root = try swiftTool.getWorkspaceRoot() | ||
let manifest = try temp_await { | ||
let rootManifests = try temp_await { | ||
workspace.loadRootManifests(packages: root.packages, diagnostics: swiftTool.diagnostics, completion: $0) | ||
}[0] | ||
} | ||
guard let rootManifest = rootManifests.first else { | ||
throw StringError("invalid manifests at \(root.packages)") | ||
} | ||
|
||
let builder = PackageBuilder( | ||
manifest: manifest, | ||
identity: .root(name: rootManifest.name), | ||
manifest: rootManifest, | ||
productFilter: .everything, | ||
path: try swiftTool.getPackageRoot(), | ||
xcTestMinimumDeploymentTargets: [:], // Minimum deployment target does not matter for this operation. | ||
|
@@ -366,15 +373,17 @@ extension SwiftPackageTool { | |
let workspace = try swiftTool.getActiveWorkspace() | ||
let root = try swiftTool.getWorkspaceRoot() | ||
|
||
let manifests = try temp_await { | ||
let rootManifests = try temp_await { | ||
workspace.loadRootManifests(packages: root.packages, diagnostics: swiftTool.diagnostics, completion: $0) | ||
} | ||
guard let manifest = manifests.first else { return } | ||
guard let rootManifest = rootManifests.first else { | ||
throw StringError("invalid manifests at \(root.packages)") | ||
} | ||
|
||
let encoder = JSONEncoder.makeWithDefaults() | ||
encoder.userInfo[Manifest.dumpPackageKey] = true | ||
|
||
let jsonData = try encoder.encode(manifest) | ||
let jsonData = try encoder.encode(rootManifest) | ||
let jsonString = String(data: jsonData, encoding: .utf8)! | ||
print(jsonString) | ||
} | ||
|
@@ -582,7 +591,7 @@ extension SwiftPackageTool { | |
destination = output | ||
} else { | ||
let graph = try swiftTool.loadPackageGraph() | ||
let packageName = graph.rootPackages[0].name | ||
let packageName = graph.rootPackages[0].manifestName // TODO: use identity instead? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This depends on what we want to do with name moving forward. If identity is an opaque string, it might make sense to have a canonical display form of it. Or should this intentionally be exactly the same string as one would put in the manifest when specifying the package in the registry? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on the other changes here, it seems that we'll need to use the identity string instead of the name (which isn't necessarily wrong). That might be a good thing to move to across-the-board. I wonder if IDEs should also show that in their user interface — there has been this unfortunate ambiguity between the name of the package directory vs the name declared in the manifest. I had been thinking of the identity as opaque but it probably is the right thing to use in diagnostics and descriptions after all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tried to keep the changes to behavior minimal in this PR -- a follow up PR to clean up the remain usage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds great! Thanks for taking this on! |
||
destination = packageRoot.appending(component: "\(packageName).zip") | ||
} | ||
|
||
|
@@ -657,10 +666,10 @@ extension SwiftPackageTool { | |
dstdir = outpath.parentDirectory | ||
case let outpath?: | ||
dstdir = outpath | ||
projectName = graph.rootPackages[0].name | ||
projectName = graph.rootPackages[0].manifestName // TODO: use identity instead? | ||
case _: | ||
dstdir = try swiftTool.getPackageRoot() | ||
projectName = graph.rootPackages[0].name | ||
projectName = graph.rootPackages[0].manifestName // TODO: use identity instead? | ||
} | ||
let xcodeprojPath = Xcodeproj.buildXcodeprojPath(outputDir: dstdir, projectName: projectName) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,9 +224,12 @@ public struct SwiftTestTool: SwiftCommand { | |
case .codeCovPath: | ||
let workspace = try swiftTool.getActiveWorkspace() | ||
let root = try swiftTool.getWorkspaceRoot() | ||
let rootManifest = try temp_await { | ||
let rootManifests = try temp_await { | ||
workspace.loadRootManifests(packages: root.packages, diagnostics: swiftTool.diagnostics, completion: $0) | ||
}[0] | ||
} | ||
guard let rootManifest = rootManifests.first else { | ||
throw StringError("invalid manifests at \(root.packages)") | ||
} | ||
let buildParameters = try swiftTool.buildParametersForTest() | ||
print(codeCovAsJSONPath(buildParameters: buildParameters, packageName: rootManifest.name)) | ||
|
||
|
@@ -352,6 +355,15 @@ public struct SwiftTestTool: SwiftCommand { | |
|
||
/// Processes the code coverage data and emits a json. | ||
private func processCodeCoverage(_ testProducts: [BuiltTestProduct], swiftTool: SwiftTool) throws { | ||
let workspace = try swiftTool.getActiveWorkspace() | ||
let root = try swiftTool.getWorkspaceRoot() | ||
let rootManifests = try temp_await { | ||
workspace.loadRootManifests(packages: root.packages, diagnostics: swiftTool.diagnostics, completion: $0) | ||
} | ||
guard let rootManifest = rootManifests.first else { | ||
throw StringError("invalid manifests at \(root.packages)") | ||
} | ||
|
||
// Merge all the profraw files to produce a single profdata file. | ||
try mergeCodeCovRawDataFiles(swiftTool: swiftTool) | ||
|
||
|
@@ -360,7 +372,7 @@ public struct SwiftTestTool: SwiftCommand { | |
// Export the codecov data as JSON. | ||
let jsonPath = codeCovAsJSONPath( | ||
buildParameters: buildParameters, | ||
packageName: product.packageName) | ||
packageName: rootManifest.name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would then presumably also be the identity? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
try exportCodeCovAsJSON(to: jsonPath, testBinary: product.binaryPath, swiftTool: swiftTool) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about that — it doesn't seem clear to end users if there is both a package name and a manifest name. Or am I misunderstanding the question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, per the comment below, maybe this should be the identity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3323 (comment)