-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enhance packages endpoint with shortest dependency path data
Add information about the shortest dependency path data to the response of the packages endpoint. This will later be added to be shown in the UI in order to get a sense of the importance to address issues found in the packages. Signed-off-by: Johanna Lamppu <[email protected]>
- Loading branch information
Showing
10 changed files
with
257 additions
and
63 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 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
35 changes: 35 additions & 0 deletions
35
api/v1/model/src/commonMain/kotlin/ShortestDependencyPath.kt
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,35 @@ | ||
/* | ||
* Copyright (C) 2025 The ORT Server Authors (See <https://github.com/eclipse-apoapsis/ort-server/blob/main/NOTICE>) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* License-Filename: LICENSE | ||
*/ | ||
|
||
package org.eclipse.apoapsis.ortserver.api.v1.model | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
/** The shortest dependency path for a Package. */ | ||
@Serializable | ||
data class ShortestDependencyPath( | ||
/** The identifier of the root project of this path. */ | ||
val projectIdentifier: Identifier, | ||
|
||
/** The scope in which this shortest path of the dependency is found in. */ | ||
val scope: String, | ||
|
||
/** Path of dependency identifiers to the dependency. */ | ||
val path: List<Identifier> | ||
) |
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 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 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 |
---|---|---|
|
@@ -112,6 +112,7 @@ import org.eclipse.apoapsis.ortserver.model.runs.OrtRuleViolation | |
import org.eclipse.apoapsis.ortserver.model.runs.Package | ||
import org.eclipse.apoapsis.ortserver.model.runs.ProcessedDeclaredLicense | ||
import org.eclipse.apoapsis.ortserver.model.runs.RemoteArtifact | ||
import org.eclipse.apoapsis.ortserver.model.runs.ShortestDependencyPath | ||
import org.eclipse.apoapsis.ortserver.model.runs.VcsInfo | ||
import org.eclipse.apoapsis.ortserver.model.runs.advisor.AdvisorConfiguration | ||
import org.eclipse.apoapsis.ortserver.model.runs.advisor.AdvisorResult | ||
|
@@ -890,6 +891,10 @@ class RunsRouteIntegrationTest : AbstractIntegrationTest({ | |
configuration = AnalyzerJobConfiguration() | ||
) | ||
|
||
val project = dbExtension.fixtures.getProject() | ||
val identifier1 = Identifier("Maven", "com.example", "example", "1.0") | ||
val identifier2 = Identifier("Maven", "com.example", "example2", "1.0") | ||
|
||
dbExtension.fixtures.analyzerRunRepository.create( | ||
analyzerJobId = analyzerJob.id, | ||
startTime = Clock.System.now().toDatabasePrecision(), | ||
|
@@ -910,10 +915,10 @@ class RunsRouteIntegrationTest : AbstractIntegrationTest({ | |
packageManagers = emptyMap(), | ||
skipExcluded = true | ||
), | ||
projects = emptySet(), | ||
projects = setOf(project), | ||
packages = setOf( | ||
Package( | ||
Identifier("Maven", "com.example", "example", "1.0"), | ||
identifier1, | ||
purl = "pkg:maven/com.example/[email protected]", | ||
cpe = null, | ||
authors = setOf("Author One", "Author Two"), | ||
|
@@ -954,12 +959,7 @@ class RunsRouteIntegrationTest : AbstractIntegrationTest({ | |
isModified = false | ||
), | ||
Package( | ||
Identifier( | ||
type = "Maven", | ||
namespace = "com.example", | ||
name = "example2", | ||
version = "1.0" | ||
), | ||
identifier2, | ||
purl = "pkg:maven/com.example/[email protected]", | ||
cpe = null, | ||
authors = emptySet(), | ||
|
@@ -998,7 +998,19 @@ class RunsRouteIntegrationTest : AbstractIntegrationTest({ | |
) | ||
), | ||
issues = emptyList(), | ||
dependencyGraphs = emptyMap() | ||
dependencyGraphs = emptyMap(), | ||
shortestDependencyPaths = mapOf( | ||
identifier1 to ShortestDependencyPath( | ||
project, | ||
"compileClassPath", | ||
emptyList() | ||
), | ||
identifier2 to ShortestDependencyPath( | ||
project, | ||
"compileClassPath", | ||
listOf(identifier1) | ||
) | ||
) | ||
) | ||
|
||
val response = superuserClient.get("/api/v1/runs/${ortRun.id}/packages") | ||
|
@@ -1008,11 +1020,26 @@ class RunsRouteIntegrationTest : AbstractIntegrationTest({ | |
|
||
with(packages.data) { | ||
shouldHaveSize(2) | ||
first().identifier.name shouldBe "example" | ||
first().authors shouldHaveSize 2 | ||
first().declaredLicenses shouldHaveSize 3 | ||
first().processedDeclaredLicense.mappedLicenses shouldHaveSize 2 | ||
first().processedDeclaredLicense.unmappedLicenses shouldHaveSize 4 | ||
|
||
with(first()) { | ||
identifier.name shouldBe "example" | ||
authors shouldHaveSize 2 | ||
declaredLicenses shouldHaveSize 3 | ||
processedDeclaredLicense.mappedLicenses shouldHaveSize 2 | ||
processedDeclaredLicense.unmappedLicenses shouldHaveSize 4 | ||
|
||
shortestDependencyPath shouldNotBeNull { | ||
projectIdentifier shouldBe project.identifier.mapToApi() | ||
scope shouldBe "compileClassPath" | ||
path shouldBe emptyList() | ||
} | ||
} | ||
|
||
last().shortestDependencyPath shouldNotBeNull { | ||
projectIdentifier shouldBe project.identifier.mapToApi() | ||
scope shouldBe "compileClassPath" | ||
path shouldBe listOf(identifier1.mapToApi()) | ||
} | ||
last().identifier.name shouldBe "example2" | ||
} | ||
} | ||
|
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
32 changes: 32 additions & 0 deletions
32
model/src/commonMain/kotlin/runs/PackageWithShortestDependencyPath.kt
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,32 @@ | ||
/* | ||
* Copyright (C) 2025 The ORT Server Authors (See <https://github.com/eclipse-apoapsis/ort-server/blob/main/NOTICE>) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* License-Filename: LICENSE | ||
*/ | ||
|
||
package org.eclipse.apoapsis.ortserver.model.runs | ||
|
||
/** | ||
* A data class representing a package, and the shortest dependency path that the package is found in (relative to a | ||
* project found in a run). | ||
*/ | ||
data class PackageWithShortestDependencyPath( | ||
/** A package. */ | ||
val pkg: Package, | ||
|
||
/** The shortest dependency path for the package. */ | ||
val shortestDependencyPath: ShortestDependencyPath? = null | ||
) |
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
Oops, something went wrong.