diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index fc3c83579..d6e60d563 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -54,9 +54,7 @@ jobs: with: api_levels: '[35]' # Run only on API 35 for PRs test_flavors: 'google' # Run only Google flavor for PRs (faster) - secrets: - GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }} - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + secrets: inherit # This job handles the case when no code changes are detected (docs-only PRs) skip-notice: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 39e1afea6..bd9a6d3be 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,6 +34,8 @@ on: required: true GRADLE_ENCRYPTION_KEY: required: true + GRADLE_CACHE_URL: + required: false concurrency: group: ${{ github.workflow }}-${{ inputs.tag_name }} @@ -144,6 +146,7 @@ jobs: env: VERSION_NAME: ${{ needs.prepare-build-info.outputs.APP_VERSION_NAME }} VERSION_CODE: ${{ needs.prepare-build-info.outputs.APP_VERSION_CODE }} + GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }} run: bundle exec fastlane internal - name: Upload Google AAB artifact @@ -213,6 +216,7 @@ jobs: env: VERSION_NAME: ${{ needs.prepare-build-info.outputs.APP_VERSION_NAME }} VERSION_CODE: ${{ needs.prepare-build-info.outputs.APP_VERSION_CODE }} + GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }} run: bundle exec fastlane fdroid_build - name: Upload F-Droid APK artifact diff --git a/.github/workflows/reusable-android-build.yml b/.github/workflows/reusable-android-build.yml index fd7f34064..4e20a93b5 100644 --- a/.github/workflows/reusable-android-build.yml +++ b/.github/workflows/reusable-android-build.yml @@ -11,6 +11,8 @@ on: required: false CODECOV_TOKEN: required: false + GRADLE_CACHE_URL: + required: false inputs: upload_artifacts: description: 'Whether to upload build and Detekt artifacts' @@ -30,6 +32,7 @@ jobs: DATADOG_APPLICATION_ID: ${{ secrets.DATADOG_APPLICATION_ID }} DATADOG_CLIENT_TOKEN: ${{ secrets.DATADOG_CLIENT_TOKEN }} MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }} + GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }} steps: diff --git a/.github/workflows/reusable-android-test.yml b/.github/workflows/reusable-android-test.yml index f89459fbf..68acb317a 100644 --- a/.github/workflows/reusable-android-test.yml +++ b/.github/workflows/reusable-android-test.yml @@ -23,11 +23,15 @@ on: required: false CODECOV_TOKEN: required: true + GRADLE_CACHE_URL: + required: false jobs: androidTest: runs-on: ubuntu-latest timeout-minutes: 45 + env: + GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }} strategy: matrix: api-level: ${{ fromJson(inputs.api_levels) }} # Use the input to define the matrix diff --git a/settings.gradle.kts b/settings.gradle.kts index aca967979..f30b55b09 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -70,6 +70,26 @@ plugins { id("com.gradle.common-custom-user-data-gradle-plugin") version "2.4.0" } +fun Settings.getMeshProperty(key: String): String? { + val env = System.getenv(key) + if (!env.isNullOrBlank()) return env + + val localFile = file("local.properties") + if (localFile.exists()) { + val props = java.util.Properties() + localFile.inputStream().use { props.load(it) } + if (props.containsKey(key)) return props.getProperty(key) + } + + val configFile = file("config.properties") + if (configFile.exists()) { + val props = java.util.Properties() + configFile.inputStream().use { props.load(it) } + if (props.containsKey(key)) return props.getProperty(key) + } + return null +} + develocity { buildScan { capture { @@ -82,14 +102,17 @@ develocity { isEnabled = true } remote(HttpBuildCache::class.java) { - isAllowInsecureProtocol = true - // Replace with your selfhosted instance address - // see: https://docs.gradle.org/current/userguide/build_cache.html#sec:build_cache_setup_http_backend - url = uri("http://192.168.1.3:5071/cache/") - - // Allow this machine to upload results to the cache - isPush = true - + val cacheUrl = getMeshProperty("GRADLE_CACHE_URL")?.trim() + if (!cacheUrl.isNullOrBlank()) { + println("Meshtastic Build: Remote cache URL found. Using remote build cache.") + url = uri(cacheUrl) + isAllowInsecureProtocol = true + isPush = true + isEnabled = true + } else { + println("Meshtastic Build: Remote cache URL not found. Disabling remote cache write.") + isEnabled = false + } } } }