You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by sn...@apache.org on 2025/11/21 10:13:40 UTC

(polaris-tools) branch main updated: Apprunner: Apply Develocity as in Polaris "main" repo (#53)

This is an automated email from the ASF dual-hosted git repository.

snazy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 91c91d5  Apprunner: Apply Develocity as in Polaris "main" repo (#53)
91c91d5 is described below

commit 91c91d5633629d965f63bacac265e97b5b197467
Author: Robert Stupp <sn...@snazy.de>
AuthorDate: Fri Nov 21 11:13:35 2025 +0100

    Apprunner: Apply Develocity as in Polaris "main" repo (#53)
    
    Works for PRs, but not yet on `main` to push to `develocity.apache.org` (secrets missing).
---
 apprunner/settings.gradle.kts | 60 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/apprunner/settings.gradle.kts b/apprunner/settings.gradle.kts
index c56d4f9..e9faef2 100644
--- a/apprunner/settings.gradle.kts
+++ b/apprunner/settings.gradle.kts
@@ -52,6 +52,11 @@ pluginManagement {
   }
 }
 
+plugins {
+  id("com.gradle.develocity") version "4.2.2"
+  id("com.gradle.common-custom-user-data-gradle-plugin") version "2.4.0"
+}
+
 dependencyResolutionManagement {
   repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
   repositories {
@@ -64,3 +69,58 @@ gradle.beforeProject {
   version = baseVersion
   group = "org.apache.polaris.tools.apprunner"
 }
+
+val isCI = System.getenv("CI") != null
+
+develocity {
+  val isApachePolarisGitHub = "apache/polaris-tools" == System.getenv("GITHUB_REPOSITORY")
+  val gitHubRef: String? = System.getenv("GITHUB_REF")
+  val isGitHubBranchOrTag =
+    gitHubRef != null && (gitHubRef.startsWith("refs/heads/") || gitHubRef.startsWith("refs/tags/"))
+  if (isApachePolarisGitHub && isGitHubBranchOrTag) {
+    // Use the ASF's Develocity instance when running against the Apache Polaris repository against
+    // a branch or tag.
+    // This is for CI runs that have access to the secret for the ASF's Develocity instance.
+    server = "https://develocity.apache.org"
+    projectId = "polaris"
+    buildScan {
+      uploadInBackground = !isCI
+      publishing.onlyIf {
+        // TODO temporarily disabled until the necessary secrets are present for the polaris-tools
+        // repo
+        // it.isAuthenticated
+        false
+      }
+      obfuscation { ipAddresses { addresses -> addresses.map { _ -> "0.0.0.0" } } }
+    }
+  } else {
+    // In all other cases, especially PR CI runs, use Gradle's public Develocity instance.
+    var cfgPrjId: String? = System.getenv("DEVELOCITY_PROJECT_ID")
+    projectId = if (cfgPrjId == null || cfgPrjId.isEmpty()) "polaris" else cfgPrjId
+    buildScan {
+      val isGradleTosAccepted = "true" == System.getenv("GRADLE_TOS_ACCEPTED")
+      val isGitHubPullRequest = gitHubRef?.startsWith("refs/pull/") ?: false
+      if (isGradleTosAccepted || (isCI && isGitHubPullRequest && isApachePolarisGitHub)) {
+        // Leave TOS agreement to the user, if not running in CI.
+        termsOfUseUrl = "https://gradle.com/terms-of-service"
+        termsOfUseAgree = "yes"
+      }
+      System.getenv("DEVELOCITY_SERVER")?.run {
+        if (isNotEmpty()) {
+          server = this
+        }
+      }
+      if (isGitHubPullRequest) {
+        System.getenv("GITHUB_SERVER_URL")?.run {
+          val ghUrl = this
+          val ghRepo = System.getenv("GITHUB_REPOSITORY")
+          val prNumber = gitHubRef!!.substringAfter("refs/pull/").substringBefore("/merge")
+          link("GitHub pull request", "$ghUrl/$ghRepo/pull/$prNumber")
+        }
+      }
+      uploadInBackground = !isCI
+      publishing.onlyIf { isCI || gradle.startParameter.isBuildScan }
+      obfuscation { ipAddresses { addresses -> addresses.map { _ -> "0.0.0.0" } } }
+    }
+  }
+}