From e8528c767927d036fd0224b4b44db848d85ed1f9 Mon Sep 17 00:00:00 2001 From: "Dmitriy.Panov" Date: Fri, 9 Nov 2018 20:04:12 +0300 Subject: [PATCH] IJI-9 sync icons in tmp branch and create review: also for dev repos: do not create review if investigation is already assigned --- .../intellij/build/images/sync/reportUtils.kt | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/reportUtils.kt b/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/reportUtils.kt index f2fb24c406b8..4b6dc1acf786 100644 --- a/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/reportUtils.kt +++ b/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/reportUtils.kt @@ -7,6 +7,20 @@ import java.util.stream.Stream import kotlin.streams.toList internal fun report(context: Context, root: File, devIcons: Int, icons: Int, skipped: Int, consistent: Collection) { + if (isUnderTeamCity()) { + val isInvestigationAssigned = isInvestigationAssigned() + if (isInvestigationAssigned) { + log("Skipping review creation since investigation is assigned") + } + else { + createReviews(root, context) + } + val investigator = if (!context.isSuccess() && context.assignInvestigation && !isInvestigationAssigned) { + assignInvestigation(root, context) + } + else null + if (context.notifySlack) sendNotification(investigator, context) + } log("Skipped $skipped dirs") fun Collection.logIcons(description: String) = "$size $description${if (size < 100) ": ${joinToString()}" else ""}" val report = """ @@ -19,17 +33,11 @@ internal fun report(context: Context, root: File, devIcons: Int, icons: Int, ski | ${context.removedByDesigners.logIcons("removed")} | ${context.modifiedByDesigners.logIcons("modified")} |${consistent.size} consistent icons in both repos + |${if (context.createdReviews.isNotEmpty()) "Created reviews: ${context.createdReviews.map(Review::url)}" else ""} """.trimMargin() log(report) - if (isUnderTeamCity()) { - createReviews(root, context) - val investigator = if (!context.isSuccess() && context.assignInvestigation && !isInvestigationAssigned()) { - assignInvestigation(root, context) - } - else null - if (context.notifySlack) sendNotification(investigator, context) - if (!context.isSuccess()) context.errorHandler.accept(report) - } + val success = context.isSuccess() || context.doSyncIconsAndCreateReview && context.createdReviews.isNotEmpty() + if (isUnderTeamCity() && !success) context.errorHandler.accept(report) } private val UPSOURCE_ICONS_PROJECT_ID = System.getProperty("intellij.icons.upsource.project.id") @@ -45,25 +53,33 @@ private fun createReviewForDev(root: File, context: Context, user: String, email if (changes.isNotEmpty()) { val commits = findInvestigator(context.iconsRepo, changes.asSequence()).commits if (commits.isNotEmpty()) { + val verificationPassed = try { + context.devIconsVerifier?.run() + true + } + catch (e: Exception) { + e.printStackTrace() + false + } val review = pushAndCreateReview(UPSOURCE_DEV_PROJECT_ID, user, email, commits.commitMessage(), changes.asSequence() .map { File(root, it).absolutePath } .map { findGitRepoRoot(it, silent = true) } .distinct() .toList()) addReviewer(UPSOURCE_DEV_PROJECT_ID, review, triggeredBy() ?: DEFAULT_INVESTIGATOR) - try { - context.devIconsVerifier?.run() - } - catch (e: Exception) { - e.printStackTrace() - postComment(UPSOURCE_DEV_PROJECT_ID, review, "Some checks were failed, see build log ${thisBuildReportableLink()}") - } + postVerificationResultToReview(verificationPassed, review) return review } } return null } +private fun postVerificationResultToReview(success: Boolean, review: Review) { + val runConfigurations = System.getProperty("sync.dev.icons.checks").splitNotBlank(";") + val comment = if (success) "Following checks were successful:" else "Some of the following checks failed:" + postComment(UPSOURCE_DEV_PROJECT_ID, review, "$comment ${runConfigurations.joinToString()}, see build log ${thisBuildReportableLink()}") +} + private fun createReviewForIcons(root: File, context: Context, user: String, email: String): Review? { if (!context.doSyncIconsAndCreateReview) return null val changes = context.addedByDev + context.removedByDev + context.modifiedByDev