From 763cdb64eb5382718a55d1bb3144ea3039fa5f4f Mon Sep 17 00:00:00 2001 From: Alexey Venderov Date: Thu, 25 Apr 2024 17:25:52 +0200 Subject: [PATCH] Capture build scans on ge.apache.org to benefit from deep build insights (#1288) * Capture build scans on ge.apache.org to benefit from deep build insights (#1) * Add Develocity plugin and configure it to publish to Apache Develocity instance * Add Develocity access token to CI jobs * Use convention plugin to configure Develocity * Add opt-in property * Revert "Add opt-in property" This reverts commit ff556b9764fd6b980b24082a3195ba3fbd22faf6. * Improve variable name * Use upper case i in CI abbreviation --- .../workflows/binary-compatibility-checks.yml | 2 + .github/workflows/build-test-prValidation.yml | 4 ++ .github/workflows/generate-doc-check.yml | 2 + .github/workflows/headers.yml | 2 + .github/workflows/link-validator.yml | 2 + .github/workflows/nightly-1.0-builds.yml | 6 ++ .github/workflows/nightly-builds-aeron.yml | 2 + .github/workflows/nightly-builds.yml | 6 ++ .github/workflows/publish-1.0-docs.yml | 2 + .github/workflows/publish-1.0-nightly.yml | 2 + .github/workflows/publish-nightly.yml | 2 + .github/workflows/scala3-build.yml | 2 + .github/workflows/scala3-compile.yml | 2 + .github/workflows/timing-tests.yml | 2 + project/PekkoDevelocityPlugin.scala | 65 +++++++++++++++++++ project/plugins.sbt | 2 + 16 files changed, 105 insertions(+) create mode 100644 project/PekkoDevelocityPlugin.scala diff --git a/.github/workflows/binary-compatibility-checks.yml b/.github/workflows/binary-compatibility-checks.yml index ac0b2c8674a..e87c5afc34b 100644 --- a/.github/workflows/binary-compatibility-checks.yml +++ b/.github/workflows/binary-compatibility-checks.yml @@ -16,6 +16,8 @@ jobs: if: github.repository == 'apache/pekko' strategy: fail-fast: false + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/build-test-prValidation.yml b/.github/workflows/build-test-prValidation.yml index e055908a65b..122d56cf75c 100644 --- a/.github/workflows/build-test-prValidation.yml +++ b/.github/workflows/build-test-prValidation.yml @@ -14,6 +14,8 @@ jobs: check-code-style: name: Check / Code Style runs-on: ubuntu-22.04 + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} steps: - name: Checkout uses: actions/checkout@v4 @@ -41,6 +43,8 @@ jobs: pull-request-validation: name: Check / Tests runs-on: ubuntu-20.04 + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/generate-doc-check.yml b/.github/workflows/generate-doc-check.yml index 17d0b4986f0..ae19e32d275 100644 --- a/.github/workflows/generate-doc-check.yml +++ b/.github/workflows/generate-doc-check.yml @@ -49,4 +49,6 @@ jobs: sudo apt-get install graphviz - name: Compile testClass&docs for all Scala versions + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} run: sbt ";+TestJdk9 / compile ; +compile:doc" diff --git a/.github/workflows/headers.yml b/.github/workflows/headers.yml index c1c0e45eccd..6b51938c4ed 100644 --- a/.github/workflows/headers.yml +++ b/.github/workflows/headers.yml @@ -23,6 +23,8 @@ jobs: uses: coursier/cache-action@v6 - name: Check headers + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} run: |- sbt \ -Dsbt.override.build.repos=false \ diff --git a/.github/workflows/link-validator.yml b/.github/workflows/link-validator.yml index a9bfb927bd4..9f0e8637765 100644 --- a/.github/workflows/link-validator.yml +++ b/.github/workflows/link-validator.yml @@ -35,6 +35,8 @@ jobs: uses: coursier/setup-action@v1 - name: Create the Pekko site + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} run: |- cp .jvmopts-ci .jvmopts sbt -Dpekko.genjavadoc.enabled=true -Dpekko.genlicensereport.enabled=true "Javaunidoc/doc; Compile/unidoc; docs/paradox" diff --git a/.github/workflows/nightly-1.0-builds.yml b/.github/workflows/nightly-1.0-builds.yml index 282b4c45289..897fbd101fe 100644 --- a/.github/workflows/nightly-1.0-builds.yml +++ b/.github/workflows/nightly-1.0-builds.yml @@ -33,6 +33,8 @@ jobs: run: cp .jvmopts-ci .jvmopts - name: sbt cluster-metrics/test + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} run: |- sbt \ -Djava.security.egd=file:/dev/./urandom \ @@ -82,6 +84,8 @@ jobs: run: cp .jvmopts-ci .jvmopts - name: sbt ${{ matrix.command }} + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} # note that this is not running any multi-jvm tests because multi-in-test=false run: |- sbt \ @@ -127,6 +131,8 @@ jobs: run: cp .jvmopts-ci .jvmopts - name: Compile and Test + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} # note that this is not running any multi-jvm tests because multi-in-test=false run: |- sbt \ diff --git a/.github/workflows/nightly-builds-aeron.yml b/.github/workflows/nightly-builds-aeron.yml index 42094a4630b..aff21337a8c 100644 --- a/.github/workflows/nightly-builds-aeron.yml +++ b/.github/workflows/nightly-builds-aeron.yml @@ -40,6 +40,8 @@ jobs: run: cp .jvmopts-ci .jvmopts - name: sbt ${{ matrix.command }} + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} # note that this is not running any multi-jvm tests because multi-in-test=false run: |- sbt \ diff --git a/.github/workflows/nightly-builds.yml b/.github/workflows/nightly-builds.yml index dbc98b68203..2e7247de537 100644 --- a/.github/workflows/nightly-builds.yml +++ b/.github/workflows/nightly-builds.yml @@ -32,6 +32,8 @@ jobs: run: cp .jvmopts-ci .jvmopts - name: sbt cluster-metrics/test + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} run: |- sbt \ -Djava.security.egd=file:/dev/./urandom \ @@ -90,6 +92,8 @@ jobs: run: cp .jvmopts-ci .jvmopts - name: sbt ${{ matrix.command }} + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} # note that this is not running any multi-jvm tests because multi-in-test=false run: |- sbt \ @@ -114,6 +118,8 @@ jobs: # full version from it. scalaVersion: ["2.12", "2.13", "3.3"] javaVersion: [8, 11, 17, 21] + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/publish-1.0-docs.yml b/.github/workflows/publish-1.0-docs.yml index 4cb142af1be..329e346e8a3 100644 --- a/.github/workflows/publish-1.0-docs.yml +++ b/.github/workflows/publish-1.0-docs.yml @@ -54,6 +54,8 @@ jobs: # TODO come up with a better way to control the version, possibly based on git tags - name: Build Documentation + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} run: |- sbt -Dpekko.genjavadoc.enabled=true -Dpekko.genlicensereport.enabled=true "set ThisBuild / version := \"1.0.2\"; docs/paradox; unidoc" diff --git a/.github/workflows/publish-1.0-nightly.yml b/.github/workflows/publish-1.0-nightly.yml index c5d5afbabaa..58b7c8d182e 100644 --- a/.github/workflows/publish-1.0-nightly.yml +++ b/.github/workflows/publish-1.0-nightly.yml @@ -32,6 +32,8 @@ jobs: name: Publish 1.0 nightly runs-on: ubuntu-20.04 if: github.repository == 'apache/pekko' + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/publish-nightly.yml b/.github/workflows/publish-nightly.yml index ca7dd876c35..6a75d8c0a27 100644 --- a/.github/workflows/publish-nightly.yml +++ b/.github/workflows/publish-nightly.yml @@ -32,6 +32,8 @@ jobs: name: Publish nightly runs-on: ubuntu-20.04 if: github.repository == 'apache/pekko' + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/scala3-build.yml b/.github/workflows/scala3-build.yml index a4f74f83dce..93d4480602c 100644 --- a/.github/workflows/scala3-build.yml +++ b/.github/workflows/scala3-build.yml @@ -52,6 +52,8 @@ jobs: run: cp .jvmopts-ci .jvmopts - name: Compile and run tests on Scala 3 + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} # note that this is not running any multi-jvm tests (yet) because multi-in-test=false run: | sbt \ diff --git a/.github/workflows/scala3-compile.yml b/.github/workflows/scala3-compile.yml index dcb1c420bc4..85ba15748ff 100644 --- a/.github/workflows/scala3-compile.yml +++ b/.github/workflows/scala3-compile.yml @@ -50,6 +50,8 @@ jobs: run: cp .jvmopts-ci .jvmopts - name: Compile on Scala 3 + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} run: | sbt \ "+~ 3 ${{ matrix.command }}" diff --git a/.github/workflows/timing-tests.yml b/.github/workflows/timing-tests.yml index 3720d00e6fc..2a68524625e 100644 --- a/.github/workflows/timing-tests.yml +++ b/.github/workflows/timing-tests.yml @@ -34,6 +34,8 @@ jobs: run: cp .jvmopts-ci .jvmopts - name: sbt test + env: + DEVELOCITY_ACCESS_TOKEN: ${{ secrets.GE_ACCESS_TOKEN }} run: |- sbt \ -Djava.security.egd=file:/dev/./urandom \ diff --git a/project/PekkoDevelocityPlugin.scala b/project/PekkoDevelocityPlugin.scala new file mode 100644 index 00000000000..7fea1dd0bff --- /dev/null +++ b/project/PekkoDevelocityPlugin.scala @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.gradle.develocity.agent.sbt.DevelocityPlugin +import com.gradle.develocity.agent.sbt.DevelocityPlugin.autoImport.{ + develocityConfiguration, + FlakyTestPolicy, + ProjectId, + Publishing +} +import sbt.{ url, AutoPlugin, Def, PluginTrigger, Plugins, Setting } +import sbt.Keys.insideCI + +object PekkoDevelocityPlugin extends AutoPlugin { + + private val ApacheDevelocityUrl = url("https://ge.apache.org") + private val PekkoProjectId = ProjectId("pekko") + private val ObfuscatedIPv4Address = "0.0.0.0" + + override lazy val trigger: PluginTrigger = allRequirements + override lazy val requires: Plugins = DevelocityPlugin + + override lazy val buildSettings: Seq[Setting[_]] = Def.settings( + develocityConfiguration := { + val isInsideCI = insideCI.value + + val original = develocityConfiguration.value + val apacheDevelocityConfiguration = + original + .withProjectId(PekkoProjectId) + .withServer( + original.server + .withUrl(Some(ApacheDevelocityUrl)) + .withAllowUntrusted(false)) + .withBuildScan( + original.buildScan + .withPublishing(Publishing.onlyIf(_.authenticated)) + .withBackgroundUpload(!isInsideCI) + .withObfuscation( + original.buildScan.obfuscation + .withIpAddresses(_.map(_ => ObfuscatedIPv4Address)))) + if (isInsideCI) { + apacheDevelocityConfiguration + .withTestRetryConfiguration( + original.testRetryConfiguration + .withMaxRetries(1) + .withFlakyTestPolicy(FlakyTestPolicy.Fail) // preserve the original build outcome in case of flaky tests + ) + } else apacheDevelocityConfiguration + }) +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 569091360c4..b68bd217493 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -32,3 +32,5 @@ addSbtPlugin("com.github.sbt" % "sbt-license-report" % "1.6.1") addSbtPlugin("io.github.roiocam" % "sbt-depend-walker" % "0.1.1") addSbtPlugin("org.apache.pekko" % "pekko-sbt-paradox" % "1.0.1") + +addSbtPlugin("com.gradle" % "sbt-develocity" % "1.0.1")