Skip to content

Commit fd324d6

Browse files
authored
ci: onboard to the OSS Community Develocity instance (#28)
* ci: publish Build Scans and cache to the OSS Community Develocity instance Replaces the self-hosted HttpBuildCache with Develocity's remote cache at community.develocity.cloud under project `meshtastic`, matching the Meshtastic-Android onboarding (meshtastic/Meshtastic-Android#6531) and the kzstd pilot (meshtastic/kzstd#36). Scans publish only from authenticated builds, so fork PRs and developers who have not provisioned a key are unaffected; only authenticated CI runs write to the cache. The GRADLE_CACHE_URL / _USERNAME / _PASSWORD secrets are no longer read, but are deliberately left in place as the rollback path. * ci: restrict Develocity cache writes to trusted events Same-repository pull requests DO receive repository secrets, so gating cache writes on the presence of DEVELOCITY_ACCESS_KEY alone let a PR build write entries into the shared cache. The self-hosted HttpBuildCache this replaced gated on GITHUB_EVENT_NAME and excluded pull_request; that protection was lost in the port and is restored here. Verified against a real CI-shaped environment: CI=true GITHUB_EVENT_NAME=pull_request -> pull-only CI=true GITHUB_EVENT_NAME=push -> writes enabled CI=true GITHUB_EVENT_NAME=merge_group -> writes enabled Local builds are still excluded by isCI, and fork PRs have no key at all.
1 parent 02e96de commit fd324d6

8 files changed

Lines changed: 70 additions & 68 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
1515
cancel-in-progress: true
1616

17-
env:
18-
GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }}
19-
GRADLE_CACHE_USERNAME: ${{ secrets.GRADLE_CACHE_USERNAME }}
20-
GRADLE_CACHE_PASSWORD: ${{ secrets.GRADLE_CACHE_PASSWORD }}
21-
2217
jobs:
2318
test:
2419
name: Test (Gradle ${{ matrix.gradle }})
@@ -37,6 +32,7 @@ jobs:
3732
- uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
3833
with:
3934
gradle-version: ${{ matrix.gradle }}
35+
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
4036

4137
- name: Build & Test
4238
run: ./gradlew :plugin:build :plugin:functionalTest --stacktrace

.github/workflows/docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ jobs:
4040

4141
- name: Set up Gradle
4242
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
43+
with:
44+
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
4345

4446
- name: Configure Pages
4547
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0

.github/workflows/publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
java-version: '17'
2020

2121
- uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
22+
with:
23+
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
2224

2325
- name: Build & Test
2426
run: ./gradlew :plugin:build :plugin:functionalTest --stacktrace

.github/workflows/snapshot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
java-version: '17'
2020

2121
- uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
22+
with:
23+
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
2224

2325
- name: Build & Test
2426
run: ./gradlew :plugin:build :plugin:functionalTest --stacktrace

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![Gradle Plugin Portal](https://img.shields.io/gradle-plugin-portal/v/org.meshtastic.flatpak.sources.settings)](https://plugins.gradle.org/plugin/org.meshtastic.flatpak.sources.settings)
66
[![License: GPL-3.0-or-later](https://img.shields.io/badge/License-GPL--3.0--or--later-blue.svg)](COPYING)
77
[![CLA assistant](https://cla-assistant.io/readme/badge/meshtastic/gradle-flatpak-sources)](https://cla-assistant.io/meshtastic/gradle-flatpak-sources)
8+
[![Revved up by Develocity](https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A)](https://community.develocity.cloud/scans?search.rootProjectNames=gradle-flatpak-sources)
89

910
A Gradle plugin that generates [Flathub-compliant](https://docs.flathub.org/docs/for-app-authors/requirements#no-network-access) offline dependency manifests (`flatpak-sources.json`) for Flatpak builds.
1011

gradle/build-cache.settings.gradle

Lines changed: 0 additions & 62 deletions
This file was deleted.

gradle/develocity.settings.gradle

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Develocity — Build Scans and remote Build Cache on the OSS Community instance
3+
* (https://community.develocity.cloud), project `meshtastic`.
4+
*
5+
* Replaces the former self-hosted HttpBuildCache: GRADLE_CACHE_URL / _USERNAME /
6+
* _PASSWORD are no longer read anywhere in this repo.
7+
*/
8+
9+
def isCI = System.getenv("CI") != null
10+
11+
develocity {
12+
server = "https://community.develocity.cloud"
13+
projectId = "meshtastic"
14+
buildScan {
15+
uploadInBackground = !isCI
16+
// Unauthenticated builds (fork PRs, developers who never provisioned a key)
17+
// publish nothing rather than failing.
18+
publishing.onlyIf { it.authenticated }
19+
// Fingerprints power cache-miss comparison (CI debugging); skip the payload locally.
20+
capture { fileFingerprints = isCI }
21+
// Public instance: no machine identity. Constants on purpose — scans already
22+
// record OS/CPU and CCUD adds CI metadata. Keep the `if` OUTSIDE the closures:
23+
// capture-free closures are what the configuration cache can serialize.
24+
obfuscation {
25+
ipAddresses { addresses -> addresses.collect { "0.0.0.0" } }
26+
externalProcessName { "external-process" }
27+
if (isCI) {
28+
username { "ci" }
29+
hostname { "ci-runner" }
30+
} else {
31+
username { "local-dev" }
32+
hostname { "local-machine" }
33+
}
34+
}
35+
}
36+
}
37+
38+
// Resolved outside the buildCache block: inside it the closure delegate is
39+
// BuildCacheConfiguration, which has no `develocity` property.
40+
def develocityBuildCache = develocity.buildCache
41+
def accessKey = System.getenv("DEVELOCITY_ACCESS_KEY")?.trim()
42+
43+
buildCache {
44+
// Off on CI: runners are ephemeral and every hit comes from the remote anyway.
45+
local {
46+
enabled = !isCI
47+
}
48+
remote(develocityBuildCache) {
49+
enabled = true
50+
// Write only from trusted events. Local dev is excluded by isCI, and
51+
// pull_request runs are excluded here: a same-repository PR DOES receive
52+
// repository secrets, so gating on the access key alone would let
53+
// unmerged code write entries into the shared cache. Fork PRs have no
54+
// key and are excluded twice over.
55+
def eventName = System.getenv("GITHUB_EVENT_NAME")
56+
def trustedForPush = eventName == "push" || eventName == "merge_group"
57+
push = isCI && trustedForPush && accessKey != null && !accessKey.isEmpty()
58+
}
59+
}

settings.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ dependencyResolutionManagement {
1313

1414
plugins {
1515
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
16+
id("com.gradle.develocity") version "4.5.0"
17+
id("com.gradle.common-custom-user-data-gradle-plugin") version "2.8.0"
1618
}
1719

18-
apply(from = "gradle/build-cache.settings.gradle")
20+
apply(from = "gradle/develocity.settings.gradle")
1921

2022
rootProject.name = "gradle-flatpak-sources"
2123
include(":plugin")

0 commit comments

Comments
 (0)