Skip to content

Commit

Permalink
Update develocity config (#12835)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Dec 7, 2024
1 parent c2c5d80 commit 80ccda1
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 109 deletions.
4 changes: 0 additions & 4 deletions .github/repository-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ for [`dependabot/**/**`](https://github.com/open-telemetry/community/blob/main/d

- `GPG_PASSWORD` - stored in OpenTelemetry-Java 1Password
- `GPG_PRIVATE_KEY` - stored in OpenTelemetry-Java 1Password
- `GRADLE_ENTERPRISE_ACCESS_KEY` - owned by [@trask](https://github.com/trask)
- Generated at https://ge.opentelemetry.io > My settings > Access keys
- Format of env var is `ge.opentelemetry.io=<access key>`,
see [docs](https://docs.gradle.com/enterprise/gradle-plugin/#via_environment_variable)
- `GRADLE_PUBLISH_KEY`
- `GRADLE_PUBLISH_SECRET`
- `NVD_API_KEY` - stored in OpenTelemetry-Java 1Password
Expand Down
21 changes: 4 additions & 17 deletions .github/workflows/build-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ on:
no-build-cache:
type: boolean
required: false
max-test-retries:
type: string
required: false
skip-openj9-tests:
type: boolean
required: false
skip-windows-smoke-tests:
type: boolean
required: false
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY:
required: false

permissions:
contents: read
Expand Down Expand Up @@ -45,8 +45,6 @@ jobs:
gradle-home-cache-excludes: caches/build-cache-1

- name: Spotless
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
run: ./gradlew spotlessCheck ${{ inputs.no-build-cache && '--no-build-cache' || '' }}

gradle-wrapper-validation:
Expand Down Expand Up @@ -78,8 +76,6 @@ jobs:
gradle-home-cache-excludes: caches/build-cache-1

- name: Generate license report
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
run: ./gradlew generateLicenseReport ${{ inputs.no-build-cache && '--no-build-cache' || '' }}

- name: Check licenses
Expand Down Expand Up @@ -149,8 +145,6 @@ jobs:
gradle-home-cache-excludes: caches/build-cache-1

- name: Build
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
run: ./gradlew check spdxSbom -x javadoc -x spotlessCheck -PskipTests=true ${{ inputs.no-build-cache && '--no-build-cache' || '' }}

Expand Down Expand Up @@ -253,8 +247,6 @@ jobs:
gradle-home-cache-excludes: caches/build-cache-1

- name: List tests
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
# "check" is needed to activate all tests for listing purposes
# listTestsInPartition writes test tasks that apply to the given partition to a file named
# "test-tasks.txt" and then disables all tasks (including tests) after it runs
Expand All @@ -269,8 +261,6 @@ jobs:
echo "test-tasks=$(cat test-tasks.txt | xargs echo | sed 's/\n/ /g')" >> $GITHUB_ENV
- name: Test
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
# spotless is checked separately since it's a common source of failure
run: >
./gradlew
Expand All @@ -280,6 +270,7 @@ jobs:
-Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}
-Porg.gradle.java.installations.auto-download=false
${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
${{ inputs.max-test-retries && format(' -PmaxTestRetries={0}', inputs.max-test-retries) || '' }}
- name: Build scan
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
Expand Down Expand Up @@ -352,14 +343,10 @@ jobs:
gradle-home-cache-excludes: caches/build-cache-1

- name: Build
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
# running suite "none" compiles everything needed by smoke tests without executing any tests
run: ./gradlew :smoke-tests:test -PsmokeTestSuite=none --no-daemon ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}

- name: Test
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
run: ./gradlew :smoke-tests:test -PsmokeTestSuite=${{ matrix.smoke-test-suite }}${{ inputs.no-build-cache && ' --no-build-cache' || '' }}

- name: Upload jvm crash dump files if any
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/build-daily-no-build-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ jobs:
common:
uses: ./.github/workflows/build-common.yml
with:
max-test-retries: 0
no-build-cache: true
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}

test-latest-deps:
uses: ./.github/workflows/reusable-test-latest-deps.yml
with:
max-test-retries: 0
no-build-cache: true

test-indy:
uses: ./.github/workflows/reusable-test-indy.yml
with:
max-test-retries: 0
no-build-cache: true
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}

# muzzle is not included here because it doesn't use gradle cache anyway and so is already covered
# by the normal daily build
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/build-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ on:
jobs:
common:
uses: ./.github/workflows/build-common.yml
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
with:
max-test-retries: 0

test-latest-deps:
uses: ./.github/workflows/reusable-test-latest-deps.yml
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
with:
max-test-retries: 0

test-indy:
uses: ./.github/workflows/reusable-test-indy.yml
with:
max-test-retries: 0

muzzle:
uses: ./.github/workflows/reusable-muzzle.yml
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ on:
jobs:
common:
uses: ./.github/workflows/build-common.yml
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}

test-latest-deps:
# release branches are excluded
# because any time a new library version is released to maven central it can fail
# which requires unnecessary release branch maintenance, especially for patches
if: "!startsWith(github.ref_name, 'release/')"
uses: ./.github/workflows/reusable-test-latest-deps.yml
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}

muzzle:
# release branches are excluded
Expand Down Expand Up @@ -80,7 +76,6 @@ jobs:

- name: Build and publish artifact snapshots
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
Expand All @@ -89,7 +84,6 @@ jobs:

- name: Build and publish gradle plugin snapshots
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/reusable-test-indy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
no-build-cache:
type: boolean
required: false
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY:
max-test-retries:
type: string
required: false

permissions:
Expand Down Expand Up @@ -65,8 +65,6 @@ jobs:
gradle-home-cache-excludes: caches/build-cache-1

- name: List tests
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
run: >
./gradlew
check -x spotlessCheck
Expand All @@ -78,13 +76,12 @@ jobs:
echo "test-tasks=$(cat test-tasks.txt | xargs echo | sed 's/\n/ /g')" >> $GITHUB_ENV
- name: Test
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
run: >
./gradlew
${{ env.test-tasks }}
-PtestIndy=true
${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
${{ inputs.max-test-retries && format(' -PmaxTestRetries={0}', inputs.max-test-retries) || '' }}
- name: Build scan
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/reusable-test-latest-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
no-build-cache:
type: boolean
required: false
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY:
max-test-retries:
type: string
required: false

permissions:
Expand Down Expand Up @@ -62,8 +62,6 @@ jobs:
gradle-home-cache-excludes: caches/build-cache-1

- name: List tests
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
run: >
./gradlew
check -x spotlessCheck
Expand All @@ -76,13 +74,12 @@ jobs:
echo "test-tasks=$(cat test-tasks.txt | xargs echo | sed 's/\n/ /g')" >> $GITHUB_ENV
- name: Test
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
run: >
./gradlew
${{ env.test-tasks }}
-PtestLatestDeps=true
${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
${{ inputs.max-test-retries && format(' -PmaxTestRetries={0}', inputs.max-test-retries) || '' }}
- name: Build scan
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
Expand Down
7 changes: 4 additions & 3 deletions conventions/src/main/kotlin/otel.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,12 @@ tasks.withType<Test>().configureEach {
// This value is quite big because with lower values (3 mins) we were experiencing large number of false positives
timeout.set(Duration.ofMinutes(15))

val defaultMaxRetries = if (System.getenv().containsKey("CI")) 5 else 0
val maxTestRetries = gradle.startParameter.projectProperties["maxTestRetries"]?.toInt() ?: defaultMaxRetries

develocity.testRetry {
// You can see tests that were retried by this mechanism in the collected test reports and build scans.
if (System.getenv().containsKey("CI") || rootProject.hasProperty("retryTests")) {
maxRetries.set(5)
}
maxRetries.set(maxTestRetries);
}

reports {
Expand Down
65 changes: 6 additions & 59 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pluginManagement {
}

plugins {
id("com.gradle.develocity") version "3.18.2"
id("com.gradle.common-custom-user-data-gradle-plugin") version "2.0.2"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
// this can't live in pluginManagement currently due to
Expand All @@ -22,6 +21,7 @@ plugins {
// ./gradlew :smoke-tests:images:servlet:buildLinuxTestImages pushMatrix -PsmokeTestServer=jetty
// ./gradlew :smoke-tests:images:servlet:buildWindowsTestImages pushMatrix -PsmokeTestServer=jetty
id("com.bmuschko.docker-remote-api") version "9.4.0" apply false
id("com.gradle.develocity") version "3.18.2"
}

dependencyResolutionManagement {
Expand All @@ -48,64 +48,11 @@ dependencyResolutionManagement {
}
}

val gradleEnterpriseServer = "https://ge.opentelemetry.io"
val isCI = System.getenv("CI") != null
val geAccessKey = System.getenv("GRADLE_ENTERPRISE_ACCESS_KEY") ?: ""

// if GE access key is not given and we are in CI, then we publish to scans.gradle.com
val useScansGradleCom = isCI && geAccessKey.isEmpty()

if (useScansGradleCom) {
develocity {
buildScan {
termsOfUseUrl = "https://gradle.com/help/legal-terms-of-use"
termsOfUseAgree = "yes"
uploadInBackground = !isCI

capture {
fileFingerprints = true
}

if (!gradle.startParameter.taskNames.contains("listTestsInPartition")) {
buildScanPublished {
File("build-scan.txt").printWriter().use { writer ->
writer.println(buildScanUri)
}
}
}
}
}
} else {
develocity {
server = gradleEnterpriseServer
buildScan {
uploadInBackground = !isCI
publishing.onlyIf { it.isAuthenticated }

capture {
fileFingerprints = true
}

gradle.startParameter.projectProperties["testJavaVersion"]?.let { tag(it) }
gradle.startParameter.projectProperties["testJavaVM"]?.let { tag(it) }
gradle.startParameter.projectProperties["smokeTestSuite"]?.let {
value("Smoke test suite", it)
}

if (!gradle.startParameter.taskNames.contains("listTestsInPartition")) {
buildScanPublished {
File("build-scan.txt").printWriter().use { writer ->
writer.println(buildScanUri)
}
}
}
}
}

buildCache {
remote(develocity.buildCache) {
isPush = isCI && geAccessKey.isNotEmpty()
}
develocity {
buildScan {
publishing.onlyIf { System.getenv("CI") != null }
termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use")
termsOfUseAgree.set("yes")
}
}

Expand Down

0 comments on commit 80ccda1

Please sign in to comment.