Skip to content

Commit bb0f5f6

Browse files
committed
Publish Develocity builds scans for PRs and local use
This PR enables Develocity build scans for all PRs and contributors w/o an Apache account. CI build scans in the `apache/polaris` repo against branches and tags and having access to the ASF's Develocity secret continue to publish to the ASF's Develocity instance (no behavioral change). All other build scans are published to Gradle's public Develocity instance: - Build scans from local developer (non-CI) runs are only published, if Gradle is invoked with the `--scan` option. - Build scans from or targeting another repository than `apache/polaris` do need be enabled explicity by accepting Gradle's terms of service, via a repository variable, because this is a decision of the owner of a repository. Advanced options to configure another Develocity server or project-ID are available (for non-`apache/polaris` repositories). Detailed instructions in the `README.md`.
1 parent 22c3193 commit bb0f5f6

File tree

8 files changed

+95
-16
lines changed

8 files changed

+95
-16
lines changed

.github/workflows/gradle.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ on:
3232
pull_request:
3333
branches: [ "main" ]
3434

35+
env:
36+
GRADLE_TOS_ACCEPTED: ${{ vars.GRADLE_TOS_ACCEPTED }}
37+
DEVELOCITY_SERVER: ${{ vars.DEVELOCITY_SERVER }}
38+
DEVELOCITY_PROJECT_ID: ${{ vars.DEVELOCITY_PROJECT_ID }}
39+
3540
jobs:
3641

3742
unit-tests:

.github/workflows/helm.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ on:
3030
pull_request:
3131
branches: [ "main" ]
3232

33+
env:
34+
GRADLE_TOS_ACCEPTED: ${{ vars.GRADLE_TOS_ACCEPTED }}
35+
DEVELOCITY_SERVER: ${{ vars.DEVELOCITY_SERVER }}
36+
DEVELOCITY_PROJECT_ID: ${{ vars.DEVELOCITY_PROJECT_ID }}
37+
3338
jobs:
3439

3540
helm-tests:

.github/workflows/nightly.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ permissions:
4040
security-events: read
4141
statuses: read
4242

43+
env:
44+
GRADLE_TOS_ACCEPTED: ${{ vars.GRADLE_TOS_ACCEPTED }}
45+
DEVELOCITY_SERVER: ${{ vars.DEVELOCITY_SERVER }}
46+
DEVELOCITY_PROJECT_ID: ${{ vars.DEVELOCITY_PROJECT_ID }}
47+
4348
jobs:
4449
nightly_build:
4550
runs-on: ubuntu-latest

.github/workflows/python-client.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ on:
3232
pull_request:
3333
branches: [ "main" ]
3434

35+
env:
36+
GRADLE_TOS_ACCEPTED: ${{ vars.GRADLE_TOS_ACCEPTED }}
37+
DEVELOCITY_SERVER: ${{ vars.DEVELOCITY_SERVER }}
38+
DEVELOCITY_PROJECT_ID: ${{ vars.DEVELOCITY_PROJECT_ID }}
39+
3540
jobs:
3641
build:
3742

.github/workflows/regtest.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ on:
2424
pull_request:
2525
branches: [ "main" ]
2626

27+
env:
28+
GRADLE_TOS_ACCEPTED: ${{ vars.GRADLE_TOS_ACCEPTED }}
29+
DEVELOCITY_SERVER: ${{ vars.DEVELOCITY_SERVER }}
30+
DEVELOCITY_PROJECT_ID: ${{ vars.DEVELOCITY_PROJECT_ID }}
31+
2732
jobs:
2833
regtest:
2934

.github/workflows/spark_client_regtests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ on:
2424
pull_request:
2525
branches: [ "main" ]
2626

27+
env:
28+
GRADLE_TOS_ACCEPTED: ${{ vars.GRADLE_TOS_ACCEPTED }}
29+
DEVELOCITY_SERVER: ${{ vars.DEVELOCITY_SERVER }}
30+
DEVELOCITY_PROJECT_ID: ${{ vars.DEVELOCITY_PROJECT_ID }}
31+
2732
jobs:
2833
spark-plugin-regtest:
2934

README.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,33 @@ Default configuration values can be found in `runtime/defaults/src/main/resource
138138

139139
#### Publishing Build Scans to develocity.apache.org
140140

141-
All authenticated builds of Apache Polaris will automatically publish build scans to the ASF Develocity instance at
142-
[develocity.apache.org](https://develocity.apache.org/scans?search.rootProjectNames=polaris).
143-
144-
CI builds originating from the `apache/polaris` repository will have access to the Apache organization-level secret
145-
`DEVELOCITY_ACCESS_KEY` and publish build scans using the secret. CI builds originating from pull requests from forks
146-
will not have access to the secret and will silently skip build scan publication.
147-
148-
Apache committers can publish build scans from their local machine by
149-
[provisioning an access key](https://docs.gradle.com/develocity/gradle-plugin/current/#automated_access_key_provisioning)
150-
using ASF LDAP credentials. Builds by anonymous, unauthenticated contributors will silently skip build scan publication.
141+
Build scans of CI builds from a branch or tag in the `apache/polaris` repository on GitHub publish build scans
142+
to the ASF Develocity instance at
143+
[develocity.apache.org](https://develocity.apache.org/scans?search.rootProjectNames=polaris), if the workflow runs have access to the Apache organization-level secret
144+
`DEVELOCITY_ACCESS_KEY`.
145+
146+
Build scans of local developer builds publish build scans only if the Gradle command line option `--scan` is used.
147+
Those build scans are published to Gradle's public Develocity instance (see advanced configuration options below).
148+
Note that build scans on Gradle's public Develocity instance are publicly accessible to anyone.
149+
You have to accept Gradle's terms of service to publish to the Gradle's public Develocity instance.
150+
151+
CI builds originating from pull requests against the `apache/polaris` GitHub repository are published to Gradle's
152+
_public_ Develocity instance.
153+
154+
Other CI build scans do only publish build scans to the Gradle's _public_ Develocity instance, if the environment
155+
variable `GRADLE_TOS_ACCEPTED` is set to `true`.
156+
By setting this variable you agree to the [Gradle's terms of service](https://gradle.com/terms-of-service), because
157+
accepting these ToS is your personal decision.
158+
You can configure this environment variable for your GitHub repository in the GitHub repository settings under
159+
`Secrets` > `Secrets and variables` > `Actions` > choose the `Variables` tab > `New repository variable`.
160+
161+
Advanced configuration options for publishing build scans (only local and non-`apache/polaris` repository CI):
162+
* The project ID published with the build scan can be specified using the environment variable `DEVELOCITY_PROJECT_ID`.
163+
The project ID defaults to the GitHub repository owner/name, for example `octocat/polaris`.
164+
* The Develocity server can be specified using the environment variable `DEVELOCITY_SERVER` if build scans should be
165+
published to another than Gradle's public Develocity instance.
166+
* If you have to publish build scans to your own Develocity instance, you can configure the access key using a
167+
GitHub secret named `DEVELOCITY_ACCESS_KEY`.
151168

152169
## License
153170

settings.gradle.kts

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,43 @@ gradle.beforeProject {
135135
val isCI = System.getenv("CI") != null
136136

137137
develocity {
138-
server = "https://develocity.apache.org"
139-
projectId = "polaris"
140-
buildScan {
141-
uploadInBackground = !isCI
142-
publishing.onlyIf { it.isAuthenticated }
143-
obfuscation { ipAddresses { addresses -> addresses.map { _ -> "0.0.0.0" } } }
138+
val isApachePolarisGitHub = "apache/polaris" == System.getenv("GITHUB_REPOSITORY")
139+
val gitHubRef: String? = System.getenv("GITHUB_REF")
140+
val isGitHubBranchOrTag =
141+
gitHubRef != null && (gitHubRef.startsWith("refs/heads/") || gitHubRef.startsWith("refs/tags/"))
142+
if (isApachePolarisGitHub && isGitHubBranchOrTag) {
143+
// Use the ASF's Develocity instance when running against the Apache Polaris repository against
144+
// a branch or tag.
145+
// This is for CI runs that have access to the secret for the ASF's Develocity instance.
146+
server = "https://develocity.apache.org"
147+
projectId = "polaris"
148+
buildScan {
149+
uploadInBackground = !isCI
150+
publishing.onlyIf { it.isAuthenticated }
151+
obfuscation { ipAddresses { addresses -> addresses.map { _ -> "0.0.0.0" } } }
152+
}
153+
} else {
154+
// In all other cases, especially PR CI runs, use Gradle's public Develocity instance.
155+
var cfgPrjId: String? = System.getenv("DEVELOCITY_PROJECT_ID")
156+
if (cfgPrjId == null || cfgPrjId.isEmpty()) {
157+
cfgPrjId = System.getenv("GITHUB_REPOSITORY")
158+
}
159+
projectId = if (cfgPrjId == null || cfgPrjId.isEmpty()) "polaris" else cfgPrjId
160+
buildScan {
161+
val isGradleTosAccepted = "true" == System.getenv("GRADLE_TOS_ACCEPTED")
162+
val isGitHubPullRequest = gitHubRef?.startsWith("refs/pull/") ?: false
163+
if (isGradleTosAccepted || (isCI && isGitHubPullRequest && isApachePolarisGitHub)) {
164+
// Leave TOS agreement to the user, if not running in CI.
165+
termsOfUseUrl = "https://gradle.com/terms-of-service"
166+
termsOfUseAgree = "yes"
167+
}
168+
var cfgServer = System.getenv("DEVELOCITY_SERVER")
169+
if (cfgServer != null && !cfgServer.isEmpty()) {
170+
server = cfgServer
171+
}
172+
uploadInBackground = !isCI
173+
publishing.onlyIf { isCI || gradle.startParameter.isBuildScan }
174+
obfuscation { ipAddresses { addresses -> addresses.map { _ -> "0.0.0.0" } } }
175+
}
144176
}
145177
}

0 commit comments

Comments
 (0)