-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reporter): Add id of current ORT run as label to ORT results
Add the id of the current ORT run as label to the ORT result in order to have it available during report and notification generation. Signed-off-by: Wolfgang Klenk <[email protected]>
- Loading branch information
Showing
5 changed files
with
83 additions
and
38 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
workers/common/src/main/kotlin/common/OrtBaseResultGenerator.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,63 @@ | ||
/* | ||
* Copyright (C) 2024 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.workers.common | ||
|
||
import org.eclipse.apoapsis.ortserver.model.OrtRun | ||
|
||
import org.ossreviewtoolkit.model.OrtResult | ||
|
||
/** | ||
* An internally used helper class to generate an [OrtResult] from the current [OrtRun]. | ||
* | ||
* This class loads the results of the previous worker steps and generates an [OrtResult] from them. In addition, it | ||
* adds a number of common labels that can be evaluated by different types of workers to obtain further information | ||
* about the run. | ||
* | ||
* The following labels are added: | ||
* - runId: The id of the [OrtRun]. | ||
*/ | ||
object OrtBaseResultGenerator { | ||
private const val RUN_ID_LABEL: String = "runId" | ||
|
||
fun generate(ortRunService: OrtRunService, ortRun: OrtRun, failIfRepoInfoMissing: Boolean = true): OrtResult { | ||
val repository = ortRunService.getOrtRepositoryInformation(ortRun, failIfMissing = failIfRepoInfoMissing) | ||
val resolvedConfiguration = ortRunService.getResolvedConfiguration(ortRun) | ||
val analyzerRun = ortRunService.getAnalyzerRunForOrtRun(ortRun.id) | ||
val advisorRun = ortRunService.getAdvisorRunForOrtRun(ortRun.id) | ||
val scannerRun = ortRunService.getScannerRunForOrtRun(ortRun.id) | ||
val evaluatorRun = ortRunService.getEvaluatorRunForOrtRun(ortRun.id) | ||
|
||
val baseResult = ortRun.mapToOrt( | ||
repository = repository, | ||
analyzerRun = analyzerRun?.mapToOrt(), | ||
advisorRun = advisorRun?.mapToOrt(), | ||
scannerRun = scannerRun?.mapToOrt(), | ||
evaluatorRun = evaluatorRun?.mapToOrt(), | ||
resolvedConfiguration = resolvedConfiguration.mapToOrt() | ||
) | ||
|
||
return baseResult.copy( | ||
// Add common labels for all types of workers | ||
labels = baseResult.labels + mapOf( | ||
RUN_ID_LABEL to ortRun.id.toString() | ||
) | ||
) | ||
} | ||
} |
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
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