Move to Artifactory usage (#3513)
This commit is contained in:
+4
-4
@@ -153,15 +153,15 @@ and then a final native binary is produced from this klibrary using the -Xinclud
|
|||||||
Output can be redirected to file with flag `--output/-o`.
|
Output can be redirected to file with flag `--output/-o`.
|
||||||
To get detailed information about supported options, please use `--help/-h`.
|
To get detailed information about supported options, please use `--help/-h`.
|
||||||
|
|
||||||
Analyzer tool can compare both local files and files placed on Bintray/TeamCity.
|
Analyzer tool can compare both local files and files placed on Artifactory/TeamCity.
|
||||||
|
|
||||||
File description stored on Bintray
|
File description stored on Artifactory
|
||||||
|
|
||||||
bintray:<build number>:<target (Linux|Windows10|MacOSX)>:<filename>
|
artifactory:<build number>:<target (Linux|Windows10|MacOSX)>:<filename>
|
||||||
|
|
||||||
Example
|
Example
|
||||||
|
|
||||||
bintray:1.2-dev-7942:Windows10:nativeReport.json
|
artifactory:1.2-dev-7942:Windows10:nativeReport.json
|
||||||
|
|
||||||
File description stored on TeamCity
|
File description stored on TeamCity
|
||||||
|
|
||||||
|
|||||||
@@ -89,11 +89,10 @@ open class BuildRegister : DefaultTask() {
|
|||||||
val buildProperties = Properties()
|
val buildProperties = Properties()
|
||||||
buildProperties.load(FileInputStream(teamcityConfig))
|
buildProperties.load(FileInputStream(teamcityConfig))
|
||||||
val buildId = buildProperties.getProperty("teamcity.build.id")
|
val buildId = buildProperties.getProperty("teamcity.build.id")
|
||||||
val bintrayUser = buildProperties.getProperty("bintray.user")
|
|
||||||
val bintrayApiKey = buildProperties.getProperty("bintray.apikey")
|
|
||||||
val teamCityUser = buildProperties.getProperty("teamcity.auth.userId")
|
val teamCityUser = buildProperties.getProperty("teamcity.auth.userId")
|
||||||
val teamCityPassword = buildProperties.getProperty("teamcity.auth.password")
|
val teamCityPassword = buildProperties.getProperty("teamcity.auth.password")
|
||||||
val buildNumber = buildProperties.getProperty("build.number")
|
val buildNumber = buildProperties.getProperty("build.number")
|
||||||
|
val apiKey = buildProperties.getProperty("artifactory.apikey")
|
||||||
|
|
||||||
// Get branch.
|
// Get branch.
|
||||||
val currentBuild = getBuild("id:$buildId", teamCityUser, teamCityPassword)
|
val currentBuild = getBuild("id:$buildId", teamCityUser, teamCityPassword)
|
||||||
@@ -104,8 +103,8 @@ open class BuildRegister : DefaultTask() {
|
|||||||
// Get summary information.
|
// Get summary information.
|
||||||
val output = arrayOf("$analyzer", "summary", "--exec-samples", "all", "--compile", "samples",
|
val output = arrayOf("$analyzer", "summary", "--exec-samples", "all", "--compile", "samples",
|
||||||
"--compile-samples", "HelloWorld,Videoplayer", "--codesize-samples", "all",
|
"--compile-samples", "HelloWorld,Videoplayer", "--codesize-samples", "all",
|
||||||
"--exec-normalize", "bintray:goldenResults.csv",
|
"--exec-normalize", "artifactory:builds/goldenResults.csv",
|
||||||
"--codesize-normalize", "bintray:goldenResults.csv", "$currentBenchmarksReportFile")
|
"--codesize-normalize", "artifactory:builds/goldenResults.csv", "$currentBenchmarksReportFile")
|
||||||
.runCommand()
|
.runCommand()
|
||||||
|
|
||||||
// Postprocess information.
|
// Postprocess information.
|
||||||
@@ -131,7 +130,7 @@ open class BuildRegister : DefaultTask() {
|
|||||||
|
|
||||||
val frameworkOutput = arrayOf("$analyzer", "summary", "--compile", "samples",
|
val frameworkOutput = arrayOf("$analyzer", "summary", "--compile", "samples",
|
||||||
"--compile-samples", "FrameworkBenchmarksAnalyzer", "--codesize-samples", "FrameworkBenchmarksAnalyzer",
|
"--compile-samples", "FrameworkBenchmarksAnalyzer", "--codesize-samples", "FrameworkBenchmarksAnalyzer",
|
||||||
"--codesize-normalize", "bintray:goldenResults.csv", "$currentBenchmarksReportFile")
|
"--codesize-normalize", "artifactory:builds/goldenResults.csv", "$currentBenchmarksReportFile")
|
||||||
.runCommand()
|
.runCommand()
|
||||||
|
|
||||||
val buildInfoPartsFramework = frameworkOutput.split(',')
|
val buildInfoPartsFramework = frameworkOutput.split(',')
|
||||||
@@ -154,8 +153,7 @@ open class BuildRegister : DefaultTask() {
|
|||||||
append("{\"buildId\":\"$buildId\",")
|
append("{\"buildId\":\"$buildId\",")
|
||||||
append("\"teamCityUser\":\"$teamCityUser\",")
|
append("\"teamCityUser\":\"$teamCityUser\",")
|
||||||
append("\"teamCityPassword\":\"$teamCityPassword\",")
|
append("\"teamCityPassword\":\"$teamCityPassword\",")
|
||||||
append("\"bintrayUser\": \"$bintrayUser\", ")
|
append("\"artifactoryApiKey\":\"$apiKey\",")
|
||||||
append("\"bintrayPassword\":\"$bintrayApiKey\", ")
|
|
||||||
append("\"target\": \"$target\",")
|
append("\"target\": \"$target\",")
|
||||||
append("\"buildType\": \"$buildType\",")
|
append("\"buildType\": \"$buildType\",")
|
||||||
append("\"failuresNumber\": $failures,")
|
append("\"failuresNumber\": $failures,")
|
||||||
|
|||||||
@@ -141,13 +141,14 @@ fun getCompileOnlyBenchmarksOpts(project: Project, defaultCompilerOpts: List<Str
|
|||||||
fun findFile(fileName: String, directory: String): String? =
|
fun findFile(fileName: String, directory: String): String? =
|
||||||
File(directory).walkBottomUp().find { it.name == fileName }?.getAbsolutePath()
|
File(directory).walkBottomUp().find { it.name == fileName }?.getAbsolutePath()
|
||||||
|
|
||||||
fun uploadFileToBintray(url: String, project: String, version: String, packageName: String, bintrayFilePath: String,
|
fun uploadFileToArtifactory(url: String, project: String, artifactoryFilePath: String,
|
||||||
filePath: String, username: String? = null, password: String? = null) {
|
filePath: String, password: String) {
|
||||||
val uploadUrl = "$url/$project/$packageName/$version/$bintrayFilePath?publish=1"
|
val uploadUrl = "$url/$project/$artifactoryFilePath"
|
||||||
sendUploadRequest(uploadUrl, filePath, username, password)
|
sendUploadRequest(uploadUrl, filePath, extraHeaders = listOf(Pair("X-JFrog-Art-Api", password)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendUploadRequest(url: String, fileName: String, username: String? = null, password: String? = null) {
|
fun sendUploadRequest(url: String, fileName: String, username: String? = null, password: String? = null,
|
||||||
|
extraHeaders: List<Pair<String, String>> = emptyList()) {
|
||||||
val uploadingFile = File(fileName)
|
val uploadingFile = File(fileName)
|
||||||
val connection = URL(url).openConnection() as HttpURLConnection
|
val connection = URL(url).openConnection() as HttpURLConnection
|
||||||
connection.doOutput = true
|
connection.doOutput = true
|
||||||
@@ -158,7 +159,9 @@ fun sendUploadRequest(url: String, fileName: String, username: String? = null, p
|
|||||||
val auth = Base64.getEncoder().encode((username + ":" + password).toByteArray()).toString(Charsets.UTF_8)
|
val auth = Base64.getEncoder().encode((username + ":" + password).toByteArray()).toString(Charsets.UTF_8)
|
||||||
connection.addRequestProperty("Authorization", "Basic $auth")
|
connection.addRequestProperty("Authorization", "Basic $auth")
|
||||||
}
|
}
|
||||||
|
extraHeaders.forEach {
|
||||||
|
connection.addRequestProperty(it.first, it.second)
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
connection.connect()
|
connection.connect()
|
||||||
BufferedOutputStream(connection.outputStream).use { output ->
|
BufferedOutputStream(connection.outputStream).use { output ->
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ open class RegressionsReporter : DefaultTask() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// File name on bintray is the same as current.
|
// File name on Artifactory is the same as current.
|
||||||
val bintrayFileName = currentBenchmarksReportFile.substringAfterLast("/")
|
val artifactoryFileName = currentBenchmarksReportFile.substringAfterLast("/")
|
||||||
|
|
||||||
// Get compare to build.
|
// Get compare to build.
|
||||||
val compareToBuild = getBuild(previousBuildLocator(buildTypeId, defaultBranch), user, password)
|
val compareToBuild = getBuild(previousBuildLocator(buildTypeId, defaultBranch), user, password)
|
||||||
@@ -135,21 +135,21 @@ open class RegressionsReporter : DefaultTask() {
|
|||||||
val target = System.getProperty("os.name").replace("\\s".toRegex(), "")
|
val target = System.getProperty("os.name").replace("\\s".toRegex(), "")
|
||||||
|
|
||||||
// Generate comparison report.
|
// Generate comparison report.
|
||||||
val output = arrayOf("$analyzer", "-r", "html", "$currentBenchmarksReportFile", "bintray:$compareToBuildNumber:$target:$bintrayFileName", "-o", "$htmlReport")
|
val output = arrayOf("$analyzer", "-r", "html", "$currentBenchmarksReportFile", "artifactory:$compareToBuildNumber:$target:$artifactoryFileName", "-o", "$htmlReport")
|
||||||
.runCommand()
|
.runCommand()
|
||||||
|
|
||||||
if (output.contains("Uncaught exception")) {
|
if (output.contains("Uncaught exception")) {
|
||||||
error("Error during comparasion of $currentBenchmarksReportFile and " +
|
error("Error during comparasion of $currentBenchmarksReportFile and " +
|
||||||
"bintray:$compareToBuildNumber:$target:$bintrayFileName with $analyzer! " +
|
"artifactory:$compareToBuildNumber:$target:$artifactoryFileName with $analyzer! " +
|
||||||
"Please check files existance and their correctness.")
|
"Please check files existance and their correctness.")
|
||||||
}
|
}
|
||||||
arrayOf("$analyzer", "-r", "statistics", "$currentBenchmarksReportFile", "bintray:$compareToBuildNumber:$target:$bintrayFileName", "-o", "$summaryFile")
|
arrayOf("$analyzer", "-r", "statistics", "$currentBenchmarksReportFile", "artifactory:$compareToBuildNumber:$target:$artifactoryFileName", "-o", "$summaryFile")
|
||||||
.runCommand()
|
.runCommand()
|
||||||
|
|
||||||
val reportLink = "https://kotlin-native-perf-summary.labs.jb.gg/?target=$target&build=$buildNumber"
|
val reportLink = "https://kotlin-native-perf-summary.labs.jb.gg/?target=$target&build=$buildNumber"
|
||||||
val detailedReportLink = "https://kotlin-native-performance.labs.jb.gg/?" +
|
val detailedReportLink = "https://kotlin-native-performance.labs.jb.gg/?" +
|
||||||
"report=bintray:$buildNumber:$target:$bintrayFileName&" +
|
"report=artifactory:$buildNumber:$target:$artifactoryFileName&" +
|
||||||
"compareTo=bintray:$compareToBuildNumber:$target:$bintrayFileName"
|
"compareTo=artifactory:$compareToBuildNumber:$target:$artifactoryFileName"
|
||||||
|
|
||||||
val title = "\n*Performance report for target $target (build $buildNumber)* - $reportLink\n" +
|
val title = "\n*Performance report for target $target (build $buildNumber)* - $reportLink\n" +
|
||||||
"*Detailed info - * $detailedReportLink"
|
"*Detailed info - * $detailedReportLink"
|
||||||
|
|||||||
@@ -35,14 +35,14 @@ defaultTasks 'konanRun'
|
|||||||
task mergeNativeReports {
|
task mergeNativeReports {
|
||||||
doLast {
|
doLast {
|
||||||
mergeReports(nativeJson)
|
mergeReports(nativeJson)
|
||||||
uploadBenchmarkResultToBintray(nativeJson)
|
uploadBenchmarkResultToArtifactory(nativeJson)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task mergeJvmReports {
|
task mergeJvmReports {
|
||||||
doLast {
|
doLast {
|
||||||
mergeReports(jvmJson)
|
mergeReports(jvmJson)
|
||||||
uploadBenchmarkResultToBintray(jvmJson)
|
uploadBenchmarkResultToArtifactory(jvmJson)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,18 +64,16 @@ task slackSummary(type: RegressionsSummaryReporter) {
|
|||||||
'Windows': "${rootBuildDirectory}/targetsResults/Windows 10.txt".toString()]
|
'Windows': "${rootBuildDirectory}/targetsResults/Windows 10.txt".toString()]
|
||||||
}
|
}
|
||||||
|
|
||||||
private def uploadBenchmarkResultToBintray(String fileName) {
|
private def uploadBenchmarkResultToArtifactory(String fileName) {
|
||||||
def teamcityConfig = System.getenv("TEAMCITY_BUILD_PROPERTIES_FILE")
|
def teamcityConfig = System.getenv("TEAMCITY_BUILD_PROPERTIES_FILE")
|
||||||
if (teamcityConfig) {
|
if (teamcityConfig) {
|
||||||
def buildProperties = new Properties()
|
def buildProperties = new Properties()
|
||||||
buildProperties.load(new FileInputStream(teamcityConfig))
|
buildProperties.load(new FileInputStream(teamcityConfig))
|
||||||
def user = buildProperties.getProperty("bintray.user")
|
def password = buildProperties.getProperty("artifactory.apikey")
|
||||||
def password = buildProperties.getProperty("bintray.apikey")
|
|
||||||
def buildNumber = buildProperties.getProperty("build.number")
|
def buildNumber = buildProperties.getProperty("build.number")
|
||||||
def target = System.getProperty("os.name").replaceAll("\\s", "")
|
def target = System.getProperty("os.name").replaceAll("\\s", "")
|
||||||
MPPTools.uploadFileToBintray("${bintrayUrl}", "${bintrayRepo}",
|
MPPTools.uploadFileToArtifactory("${artifactoryUrl}", "${artifactoryRepo}",
|
||||||
buildNumber, "${bintrayPackage}", "${target}/${buildNumber}/${fileName}",
|
"${target}/${buildNumber}/${fileName}", "${buildDir.absolutePath}/${fileName}", password)
|
||||||
"${buildDir.absolutePath}/${fileName}", user, password)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +124,7 @@ task registerExternalBenchmarks {
|
|||||||
if (!merged.isEmpty()) {
|
if (!merged.isEmpty()) {
|
||||||
mkdir buildDir.absolutePath
|
mkdir buildDir.absolutePath
|
||||||
new File(buildDir, externalBenchmarksReport).write(merged)
|
new File(buildDir, externalBenchmarksReport).write(merged)
|
||||||
uploadBenchmarkResultToBintray(externalBenchmarksReport)
|
uploadBenchmarkResultToArtifactory(externalBenchmarksReport)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,14 +162,14 @@ def mergeReports(String fileName) {
|
|||||||
task mergeNativeReports {
|
task mergeNativeReports {
|
||||||
doLast {
|
doLast {
|
||||||
mergeReports(nativeJson)
|
mergeReports(nativeJson)
|
||||||
uploadBenchmarkResultToBintray(nativeJson)
|
uploadBenchmarkResultToArtifactory(nativeJson)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task mergeJvmReports {
|
task mergeJvmReports {
|
||||||
doLast {
|
doLast {
|
||||||
mergeReports(jvmJson)
|
mergeReports(jvmJson)
|
||||||
uploadBenchmarkResultToBintray(jvmJson)
|
uploadBenchmarkResultToArtifactory(jvmJson)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ jvmJson = jvmReport.json
|
|||||||
analyzerTool = benchmarksAnalyzer
|
analyzerTool = benchmarksAnalyzer
|
||||||
analyzerToolDirectory = tools/benchmarksAnalyzer/build/bin
|
analyzerToolDirectory = tools/benchmarksAnalyzer/build/bin
|
||||||
outputReport = ../report/report.html
|
outputReport = ../report/report.html
|
||||||
bintrayUrl = https://api.bintray.com/content/lepilkinaelena
|
artifactoryUrl = https://repo.labs.intellij.net
|
||||||
bintrayRepo = KotlinNativePerformance
|
artifactoryRepo = kotlin-native-benchmarks
|
||||||
bintrayPackage = jsonReports
|
|
||||||
externalReports = coroutinesReport.txt
|
externalReports = coroutinesReport.txt
|
||||||
externalBenchmarksReport = externalReport.json
|
externalBenchmarksReport = externalReport.json
|
||||||
|
|||||||
@@ -31,27 +31,27 @@ abstract class Connector {
|
|||||||
abstract fun getFileContent(fileLocation: String, user: String? = null): String
|
abstract fun getFileContent(fileLocation: String, user: String? = null): String
|
||||||
}
|
}
|
||||||
|
|
||||||
object BintrayConnector : Connector() {
|
object ArtifactoryConnector : Connector() {
|
||||||
override val connectorPrefix = "bintray:"
|
override val connectorPrefix = "artifactory:"
|
||||||
val bintrayUrl = "https://dl.bintray.com/content/lepilkinaelena/KotlinNativePerformance"
|
val artifactoryUrl = "https://repo.labs.intellij.net/kotlin-native-benchmarks"
|
||||||
|
|
||||||
override fun getFileContent(fileLocation: String, user: String?): String {
|
override fun getFileContent(fileLocation: String, user: String?): String {
|
||||||
val fileParametersSize = 3
|
val fileParametersSize = 3
|
||||||
val fileDescription = fileLocation.substringAfter(connectorPrefix)
|
val fileDescription = fileLocation.substringAfter(connectorPrefix)
|
||||||
val fileParameters = fileDescription.split(':', limit = fileParametersSize)
|
val fileParameters = fileDescription.split(':', limit = fileParametersSize)
|
||||||
|
|
||||||
// Right link to bintray file.
|
// Right link to Artifactory file.
|
||||||
if (fileParameters.size == 1) {
|
if (fileParameters.size == 1) {
|
||||||
val accessFileUrl = "$bintrayUrl/${fileParameters[0]}"
|
val accessFileUrl = "$artifactoryUrl/${fileParameters[0]}"
|
||||||
return sendGetRequest(accessFileUrl, followLocation = true)
|
return sendGetRequest(accessFileUrl, followLocation = true)
|
||||||
}
|
}
|
||||||
// Used builds description format.
|
// Used builds description format.
|
||||||
if (fileParameters.size != fileParametersSize) {
|
if (fileParameters.size != fileParametersSize) {
|
||||||
error("To get file from bintray, please, specify, build number from TeamCity and target" +
|
error("To get file from Artifactory, please, specify, build number from TeamCity and target" +
|
||||||
" in format bintray:build_number:target:filename")
|
" in format artifactory:build_number:target:filename")
|
||||||
}
|
}
|
||||||
val (buildNumber, target, fileName) = fileParameters
|
val (buildNumber, target, fileName) = fileParameters
|
||||||
val accessFileUrl = "$bintrayUrl/$target/$buildNumber/$fileName"
|
val accessFileUrl = "$artifactoryUrl/$target/$buildNumber/$fileName"
|
||||||
return sendGetRequest(accessFileUrl, followLocation = true)
|
return sendGetRequest(accessFileUrl, followLocation = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ object TeamCityConnector: Connector() {
|
|||||||
|
|
||||||
fun getFileContent(fileName: String, user: String? = null): String {
|
fun getFileContent(fileName: String, user: String? = null): String {
|
||||||
return when {
|
return when {
|
||||||
BintrayConnector.isCompatible(fileName) -> BintrayConnector.getFileContent(fileName, user)
|
ArtifactoryConnector.isCompatible(fileName) -> ArtifactoryConnector.getFileContent(fileName, user)
|
||||||
TeamCityConnector.isCompatible(fileName) -> TeamCityConnector.getFileContent(fileName, user)
|
TeamCityConnector.isCompatible(fileName) -> TeamCityConnector.getFileContent(fileName, user)
|
||||||
else -> readFile(fileName)
|
else -> readFile(fileName)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,16 +21,17 @@ import org.jetbrains.report.json.*
|
|||||||
import org.jetbrains.build.Build
|
import org.jetbrains.build.Build
|
||||||
|
|
||||||
const val teamCityUrl = "https://buildserver.labs.intellij.net/app/rest"
|
const val teamCityUrl = "https://buildserver.labs.intellij.net/app/rest"
|
||||||
const val downloadBintrayUrl = "https://dl.bintray.com/content/lepilkinaelena/KotlinNativePerformance"
|
const val artifactoryUrl = "https://repo.labs.intellij.net/kotlin-native-benchmarks"
|
||||||
const val uploadBintrayUrl = "https://api.bintray.com/content/lepilkinaelena/KotlinNativePerformance"
|
|
||||||
const val buildsFileName = "buildsSummary.csv"
|
const val buildsFileName = "buildsSummary.csv"
|
||||||
const val goldenResultsFileName = "goldenResults.csv"
|
const val goldenResultsFileName = "goldenResults.csv"
|
||||||
const val bintrayPackage = "builds"
|
const val artifactoryBuildsDirectory = "builds"
|
||||||
const val buildsInfoPartsNumber = 11
|
const val buildsInfoPartsNumber = 11
|
||||||
|
|
||||||
operator fun <K, V> Map<K, V>?.get(key: K) = this?.get(key)
|
operator fun <K, V> Map<K, V>?.get(key: K) = this?.get(key)
|
||||||
|
|
||||||
// Local cache for saving information about builds got from Bintray.
|
fun getArtifactoryHeader(artifactoryApiKey: String) = Pair("X-JFrog-Art-Api", artifactoryApiKey)
|
||||||
|
|
||||||
|
// Local cache for saving information about builds got from Artifactory.
|
||||||
object LocalCache {
|
object LocalCache {
|
||||||
private val knownTargets = listOf("Linux", "MacOSX", "Windows10")
|
private val knownTargets = listOf("Linux", "MacOSX", "Windows10")
|
||||||
private val buildsInfo = mutableMapOf<String, MutableMap<String, String>>()
|
private val buildsInfo = mutableMapOf<String, MutableMap<String, String>>()
|
||||||
@@ -43,7 +44,7 @@ object LocalCache {
|
|||||||
|
|
||||||
fun fill(onlyTarget: String? = null) {
|
fun fill(onlyTarget: String? = null) {
|
||||||
onlyTarget?.let {
|
onlyTarget?.let {
|
||||||
val buildsDescription = getBuildsInfoFromBintray(onlyTarget).lines().drop(1)
|
val buildsDescription = getBuildsInfoFromArtifactory(onlyTarget).lines().drop(1)
|
||||||
buildsInfo[onlyTarget] = mutableMapOf<String, String>()
|
buildsInfo[onlyTarget] = mutableMapOf<String, String>()
|
||||||
buildsDescription.forEach {
|
buildsDescription.forEach {
|
||||||
if (!it.isEmpty()) {
|
if (!it.isEmpty()) {
|
||||||
@@ -65,19 +66,19 @@ object LocalCache {
|
|||||||
fun buildExists(target: String, buildNumber: String) =
|
fun buildExists(target: String, buildNumber: String) =
|
||||||
buildsInfo[target][buildNumber]?.let { true } ?: false
|
buildsInfo[target][buildNumber]?.let { true } ?: false
|
||||||
|
|
||||||
fun delete(target: String, builds: Iterable<String>, bintrayUser: String, bintrayPassword: String): Boolean {
|
fun delete(target: String, builds: Iterable<String>, apiKey: String): Boolean {
|
||||||
// Delete from bintray.
|
// Delete from Artifactory.
|
||||||
val buildsDescription = getBuildsInfoFromBintray(target).lines()
|
val buildsDescription = getBuildsInfoFromArtifactory(target).lines()
|
||||||
|
|
||||||
val newBuildsDescription = buildsDescription.filter {
|
val newBuildsDescription = buildsDescription.filter {
|
||||||
val buildNumber = it.substringBefore(',')
|
val buildNumber = it.substringBefore(',')
|
||||||
buildNumber !in builds
|
buildNumber !in builds
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newBuildsDescription.size < buildsDescription.size) {
|
if (newBuildsDescription.size < buildsDescription.size) {
|
||||||
// Upload new version of file.
|
// Upload new version of file.
|
||||||
val uploadUrl = "$uploadBintrayUrl/$bintrayPackage/latest/$target/$buildsFileName?publish=1&override=1"
|
val uploadUrl = "$artifactoryUrl/$artifactoryBuildsDirectory/$target/$buildsFileName"
|
||||||
sendUploadRequest(uploadUrl, newBuildsDescription.joinToString("\n"), bintrayUser, bintrayPassword)
|
sendUploadRequest(uploadUrl, newBuildsDescription.joinToString("\n"),
|
||||||
|
extraHeaders = listOf(getArtifactoryHeader(apiKey)))
|
||||||
|
|
||||||
// Reload values.
|
// Reload values.
|
||||||
clean(target)
|
clean(target)
|
||||||
@@ -111,15 +112,14 @@ object LocalCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data class GoldenResult(val benchmarkName: String, val metric: String, val value: Double)
|
data class GoldenResult(val benchmarkName: String, val metric: String, val value: Double)
|
||||||
data class GoldenResultsInfo(val bintrayUser: String, val bintrayPassword: String, val goldenResults: Array<GoldenResult>)
|
data class GoldenResultsInfo(val apiKey: String, val goldenResults: Array<GoldenResult>)
|
||||||
|
|
||||||
// Build information provided from request.
|
// Build information provided from request.
|
||||||
data class BuildInfo(val buildNumber: String, val branch: String, val startTime: String,
|
data class BuildInfo(val buildNumber: String, val branch: String, val startTime: String,
|
||||||
val finishTime: String)
|
val finishTime: String)
|
||||||
|
|
||||||
data class BuildRegister(val buildId: String, val teamCityUser: String, val teamCityPassword: String,
|
data class BuildRegister(val buildId: String, val teamCityUser: String, val teamCityPassword: String,
|
||||||
val bintrayUser: String, val bintrayPassword: String,
|
val artifactoryApiKey: String, val target: String, val buildType: String, val failuresNumber: Int,
|
||||||
val target: String, val buildType: String, val failuresNumber: Int,
|
|
||||||
val executionTime: String, val compileTime: String, val codeSize: String,
|
val executionTime: String, val compileTime: String, val codeSize: String,
|
||||||
val bundleSize: String?) {
|
val bundleSize: String?) {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -127,8 +127,8 @@ data class BuildRegister(val buildId: String, val teamCityUser: String, val team
|
|||||||
val requestDetails = JSON.parse<BuildRegister>(json)
|
val requestDetails = JSON.parse<BuildRegister>(json)
|
||||||
// Parse method doesn't create real instance with all methods. So create it by hands.
|
// Parse method doesn't create real instance with all methods. So create it by hands.
|
||||||
return BuildRegister(requestDetails.buildId, requestDetails.teamCityUser, requestDetails.teamCityPassword,
|
return BuildRegister(requestDetails.buildId, requestDetails.teamCityUser, requestDetails.teamCityPassword,
|
||||||
requestDetails.bintrayUser, requestDetails.bintrayPassword, requestDetails.target,
|
requestDetails.artifactoryApiKey, requestDetails.target, requestDetails.buildType,
|
||||||
requestDetails.buildType, requestDetails.failuresNumber, requestDetails.executionTime, requestDetails.compileTime,
|
requestDetails.failuresNumber, requestDetails.executionTime, requestDetails.compileTime,
|
||||||
requestDetails.codeSize, requestDetails.bundleSize)
|
requestDetails.codeSize, requestDetails.bundleSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,8 +189,8 @@ class CommitsList(data: JsonElement): ConvertedFromJson {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBuildsInfoFromBintray(target: String) =
|
fun getBuildsInfoFromArtifactory(target: String) =
|
||||||
sendGetRequest("$downloadBintrayUrl/$target/$buildsFileName")
|
sendGetRequest("$artifactoryUrl/$artifactoryBuildsDirectory/$target/$buildsFileName")
|
||||||
|
|
||||||
fun checkBuildType(currentType: String, targetType: String): Boolean {
|
fun checkBuildType(currentType: String, targetType: String): Boolean {
|
||||||
val releasesBuildTypes = listOf("release", "eap", "rc1", "rc2")
|
val releasesBuildTypes = listOf("release", "eap", "rc1", "rc2")
|
||||||
@@ -226,7 +226,7 @@ fun router() {
|
|||||||
val express = require("express")
|
val express = require("express")
|
||||||
val router = express.Router()
|
val router = express.Router()
|
||||||
|
|
||||||
// Register build on Bintray.
|
// Register build on Artifactory.
|
||||||
router.post("/register", { request, response ->
|
router.post("/register", { request, response ->
|
||||||
val maxCommitsNumber = 5
|
val maxCommitsNumber = 5
|
||||||
val register = BuildRegister.create(JSON.stringify(request.body))
|
val register = BuildRegister.create(JSON.stringify(request.body))
|
||||||
@@ -251,8 +251,8 @@ fun router() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get summary file from Bintray.
|
// Get summary file from Artifactory.
|
||||||
var buildsDescription = getBuildsInfoFromBintray(register.target)
|
var buildsDescription = getBuildsInfoFromArtifactory(register.target)
|
||||||
// Add information about new build.
|
// Add information about new build.
|
||||||
//var buildsDescription = "build, start time, finish time, branch, commits, type, failuresNumber, execution time, compile time, code size, bundle size\n"
|
//var buildsDescription = "build, start time, finish time, branch, commits, type, failuresNumber, execution time, compile time, code size, bundle size\n"
|
||||||
buildsDescription += "${buildInfo.buildNumber}, ${buildInfo.startTime}, ${buildInfo.finishTime}, " +
|
buildsDescription += "${buildInfo.buildNumber}, ${buildInfo.startTime}, ${buildInfo.finishTime}, " +
|
||||||
@@ -261,8 +261,8 @@ fun router() {
|
|||||||
"${register.bundleSize ?: "-"}\n"
|
"${register.bundleSize ?: "-"}\n"
|
||||||
|
|
||||||
// Upload new version of file.
|
// Upload new version of file.
|
||||||
val uploadUrl = "$uploadBintrayUrl/$bintrayPackage/latest/${register.target}/${buildsFileName}?publish=1&override=1"
|
val uploadUrl = "$artifactoryUrl/$artifactoryBuildsDirectory/${register.target}/${buildsFileName}"
|
||||||
sendUploadRequest(uploadUrl, buildsDescription, register.bintrayUser, register.bintrayPassword)
|
sendUploadRequest(uploadUrl, buildsDescription, extraHeaders = listOf(getArtifactoryHeader(register.artifactoryApiKey)))
|
||||||
|
|
||||||
LocalCache.clean(register.target)
|
LocalCache.clean(register.target)
|
||||||
LocalCache.fill(register.target)
|
LocalCache.fill(register.target)
|
||||||
@@ -271,16 +271,17 @@ fun router() {
|
|||||||
response.sendStatus(200)
|
response.sendStatus(200)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Register golden results to normalize on Bintray.
|
// Register golden results to normalize on Artifactory.
|
||||||
router.post("/registerGolden", { request, response ->
|
router.post("/registerGolden", { request, response ->
|
||||||
val goldenResultsInfo = JSON.parse<GoldenResultsInfo>(JSON.stringify(request.body))
|
val goldenResultsInfo = JSON.parse<GoldenResultsInfo>(JSON.stringify(request.body))
|
||||||
val buildsDescription = StringBuilder(sendGetRequest("$downloadBintrayUrl/$goldenResultsFileName"))
|
val buildsDescription = StringBuilder(sendGetRequest("$artifactoryUrl/$artifactoryBuildsDirectory/$goldenResultsFileName"))
|
||||||
goldenResultsInfo.goldenResults.forEach {
|
goldenResultsInfo.goldenResults.forEach {
|
||||||
buildsDescription.append("${it.benchmarkName}, ${it.metric}, ${it.value}\n")
|
buildsDescription.append("${it.benchmarkName}, ${it.metric}, ${it.value}\n")
|
||||||
}
|
}
|
||||||
// Upload new version of file.
|
// Upload new version of file.
|
||||||
val uploadUrl = "$uploadBintrayUrl/$bintrayPackage/latest/$goldenResultsFileName?publish=1&override=1"
|
val uploadUrl = "$artifactoryUrl/$artifactoryBuildsDirectory/$goldenResultsFileName"
|
||||||
sendUploadRequest(uploadUrl, buildsDescription.toString(), goldenResultsInfo.bintrayUser, goldenResultsInfo.bintrayPassword)
|
sendUploadRequest(uploadUrl, buildsDescription.toString(),
|
||||||
|
extraHeaders = listOf(getArtifactoryHeader(goldenResultsInfo.apiKey)))
|
||||||
// Send response.
|
// Send response.
|
||||||
response.sendStatus(200)
|
response.sendStatus(200)
|
||||||
})
|
})
|
||||||
@@ -318,7 +319,7 @@ fun router() {
|
|||||||
|
|
||||||
router.get("/delete/:target", { request, response ->
|
router.get("/delete/:target", { request, response ->
|
||||||
val buildsToDelete: List<String> = request.query.builds.toString().split(",").map { it.trim() }
|
val buildsToDelete: List<String> = request.query.builds.toString().split(",").map { it.trim() }
|
||||||
val result = LocalCache.delete(request.params.target, buildsToDelete, request.query.user, request.query.key)
|
val result = LocalCache.delete(request.params.target, buildsToDelete, request.query.key)
|
||||||
if (result) {
|
if (result) {
|
||||||
response.sendStatus(200)
|
response.sendStatus(200)
|
||||||
} else {
|
} else {
|
||||||
@@ -362,12 +363,16 @@ fun sendGetRequest(url: String, user: String? = null, password: String? = null,
|
|||||||
return response.getBody().toString()
|
return response.getBody().toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendUploadRequest(url: String, fileContent: String, user: String? = null, password: String? = null) {
|
fun sendUploadRequest(url: String, fileContent: String, user: String? = null, password: String? = null,
|
||||||
|
extraHeaders: List<Pair<String, String>> = emptyList()) {
|
||||||
val request = require("sync-request")
|
val request = require("sync-request")
|
||||||
val headers = mutableListOf<Pair<String, String>>("Content-type" to "text/plain")
|
val headers = mutableListOf<Pair<String, String>>("Content-type" to "text/plain")
|
||||||
if (user != null && password != null) {
|
if (user != null && password != null) {
|
||||||
headers.add("Authorization" to getAuth(user, password))
|
headers.add("Authorization" to getAuth(user, password))
|
||||||
}
|
}
|
||||||
|
extraHeaders.forEach {
|
||||||
|
headers.add(it.first to it.second)
|
||||||
|
}
|
||||||
val response = request("PUT", url,
|
val response = request("PUT", url,
|
||||||
json(
|
json(
|
||||||
"headers" to json(*(headers.toTypedArray())),
|
"headers" to json(*(headers.toTypedArray())),
|
||||||
|
|||||||
@@ -182,10 +182,10 @@ fun customizeChart(chart: dynamic, chartContainer: String, jquerySelector: dynam
|
|||||||
element = data.element.replace(rectangle)
|
element = data.element.replace(rectangle)
|
||||||
}
|
}
|
||||||
// Add tooltips.
|
// Add tooltips.
|
||||||
val linkToDetailedInfo = "https://kotlin-native-performance.labs.jb.gg/?report=bintray:" +
|
val linkToDetailedInfo = "https://kotlin-native-performance.labs.jb.gg/?report=artifactory:" +
|
||||||
"${currentBuild.buildNumber}:${parameters["target"]}:nativeReport.json" +
|
"${currentBuild.buildNumber}:${parameters["target"]}:nativeReport.json" +
|
||||||
"${if (data.index - 1 >= 0)
|
"${if (data.index - 1 >= 0)
|
||||||
"&compareTo=bintray:${buildsGroup.get(data.index - 1).buildNumber}:${parameters["target"]}:nativeReport.json"
|
"&compareTo=artifactory:${buildsGroup.get(data.index - 1).buildNumber}:${parameters["target"]}:nativeReport.json"
|
||||||
else ""}"
|
else ""}"
|
||||||
val information = buildString {
|
val information = buildString {
|
||||||
append("<a href=\"$linkToDetailedInfo\">${currentBuild.buildNumber}</a><br>")
|
append("<a href=\"$linkToDetailedInfo\">${currentBuild.buildNumber}</a><br>")
|
||||||
|
|||||||
Reference in New Issue
Block a user