From 378ccd506361d3f78108750ac80aecfbc586e1e5 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 20 Nov 2025 13:16:04 -0800 Subject: [PATCH] Fix flaky opampProtoDownload --- .github/workflows/build-common.yml | 2 ++ .github/workflows/build.yml | 1 + .github/workflows/codeql.yml | 1 + .github/workflows/copilot-setup-steps.yml | 1 + .github/workflows/release.yml | 2 ++ opamp-client/build.gradle.kts | 9 ++++++++- 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-common.yml b/.github/workflows/build-common.yml index a64065106..8aed917e4 100644 --- a/.github/workflows/build-common.yml +++ b/.github/workflows/build-common.yml @@ -59,6 +59,7 @@ jobs: run: ./gradlew build -x spotlessCheck -x test ${{ inputs.no-build-cache && '--no-build-cache' || '' }} env: DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + GITHUB_TOKEN: ${{ github.token }} - name: Check for jApiCmp diffs # The jApiCmp diff compares current to latest, which isn't appropriate for release branches @@ -123,6 +124,7 @@ jobs: ${{ inputs.no-build-cache && '--no-build-cache' || '' }} env: DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + GITHUB_TOKEN: ${{ github.token }} - name: Build scan if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 355f4731a..424455b97 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,3 +46,4 @@ jobs: GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7b08da616..626df2b98 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -65,6 +65,7 @@ jobs: run: ./gradlew assemble --no-build-cache --no-daemon env: DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + GITHUB_TOKEN: ${{ github.token }} - name: Perform CodeQL analysis uses: github/codeql-action/analyze@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3 diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 000e992cf..c5f643fb1 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -34,3 +34,4 @@ jobs: run: ./gradlew build -x test env: DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 751ef279a..711154584 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -100,6 +100,7 @@ jobs: GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + GITHUB_TOKEN: ${{ github.token }} - name: Download artifacts from Maven Central (when already published) if: ${{ inputs.already-published }} @@ -244,6 +245,7 @@ jobs: VERSION: ${{ needs.release.outputs.version }} PRIOR_VERSION: ${{ needs.release.outputs.prior-version }} DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + GITHUB_TOKEN: ${{ github.token }} run: | ./gradlew japicmp -PapiBaseVersion=$PRIOR_VERSION -PapiNewVersion=$VERSION ./gradlew --refresh-dependencies japicmp diff --git a/opamp-client/build.gradle.kts b/opamp-client/build.gradle.kts index 92f77f782..bf38cdcbb 100644 --- a/opamp-client/build.gradle.kts +++ b/opamp-client/build.gradle.kts @@ -67,7 +67,14 @@ abstract class DownloadAndExtractOpampProtos @Inject constructor( val url = URI.create(zipUrl.get()).toURL() downloadedZipFile.get().asFile.parentFile.mkdirs() - url.openStream().use { input: InputStream -> + val connection = url.openConnection() + // Use GitHub token if available to avoid rate limiting + val githubToken = System.getenv("GITHUB_TOKEN") + if (githubToken != null && githubToken.isNotEmpty()) { + connection.setRequestProperty("Authorization", "Bearer $githubToken") + } + + connection.getInputStream().use { input: InputStream -> downloadedZipFile.get().asFile.outputStream().use { output: FileOutputStream -> input.copyTo(output) }