From d84c91c0c67eae25997f530c3722dc9f2e36241c Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 21 Oct 2025 12:26:33 -0700 Subject: [PATCH] Enable Develocity build scans --- .github/workflows/build.yml | 4 ++++ .github/workflows/codeql.yml | 2 ++ settings.gradle.kts | 41 +++++++++++++++++++++++++++++++++--- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e0217f98..d1c289921 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,8 @@ jobs: - name: Build run: ./gradlew clean check shadowJar + env: + DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} - run: java -cp sdk-usage/build/libs/opentelemetry-examples-sdk-usage-0.1.0-SNAPSHOT-all.jar io.opentelemetry.sdk.example.ConfigureSpanProcessorExample @@ -63,6 +65,8 @@ jobs: run: | export OTEL_EXPERIMENTAL_CONFIG_FILE=$(pwd)/otel-sdk-config.yaml ../gradlew run + env: + DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} # this is not a required check to avoid blocking pull requests if external links break link-check: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 854dc20dd..b2c68c8f1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -55,6 +55,8 @@ jobs: # --no-daemon is required for codeql to observe the compilation # (see https://docs.github.com/en/code-security/codeql-cli/getting-started-with-the-codeql-cli/preparing-your-code-for-codeql-analysis#specifying-build-commands) run: ./gradlew assemble --no-build-cache --no-daemon + env: + DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} - name: Perform CodeQL analysis uses: github/codeql-action/analyze@16140ae1a102900babc80a33c44059580f687047 # v4.30.9 diff --git a/settings.gradle.kts b/settings.gradle.kts index 790da7535..66bde9bbe 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -14,11 +14,46 @@ plugins { id("com.gradle.develocity") } +val develocityServer = "https://develocity.opentelemetry.io" +val isCI = System.getenv("CI") != null +val develocityAccessKey = System.getenv("DEVELOCITY_ACCESS_KEY") ?: "" + +// if develocity access key is not given and we are in CI, then we publish to scans.gradle.com +val useScansGradleCom = isCI && develocityAccessKey.isEmpty() + develocity { + if (useScansGradleCom) { + buildScan { + termsOfUseUrl = "https://gradle.com/help/legal-terms-of-use" + termsOfUseAgree = "yes" + } + } else { + server = develocityServer + buildScan { + publishing.onlyIf { it.isAuthenticated } + } + } + buildScan { - publishing.onlyIf { System.getenv("CI") != null } - termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use") - termsOfUseAgree.set("yes") + uploadInBackground = !isCI + + capture { + fileFingerprints = true + } + + buildScanPublished { + java.io.File("build-scan.txt").printWriter().use { writer -> + writer.println(buildScanUri) + } + } + } +} + +if (!useScansGradleCom) { + buildCache { + remote(develocity.buildCache) { + isPush = isCI && develocityAccessKey.isNotEmpty() + } } }