Skip to content

Commit 328973b

Browse files
cortinicofacebook-github-bot
authored andcommitted
Enable Gradle Configuration Caching on CI (facebook#49514)
Summary: This attemps to enable Config Caching on CI. I'm curious to see how much time this is going to save. There might be some problems with nigthlies so I want to make sure this is running for some days before the branch cut. Changelog: [Internal] [Changed] - Differential Revision: D69846848
1 parent e5f08c7 commit 328973b

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

.github/actions/build-android/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ inputs:
77
run-e2e-tests:
88
default: 'false'
99
description: If we need to build to run E2E tests. If yes, we need to build also x86.
10+
gradle-cache-encryption-key:
11+
description: "The encryption key needed to store the Gradle Configuration cache"
1012
runs:
1113
using: composite
1214
steps:
@@ -24,6 +26,7 @@ runs:
2426
uses: ./.github/actions/setup-gradle
2527
with:
2628
cache-read-only: "false"
29+
cache-encryption-key: ${{ inputs.gradle-cache-encryption-key }}
2730
- name: Restore Android ccache
2831
uses: actions/cache/restore@v4
2932
with:
@@ -54,7 +57,7 @@ runs:
5457
# release: we want to build all archs (default)
5558
TASKS="publishAllToMavenTempLocal publishAndroidToSonatype build"
5659
fi
57-
./gradlew $TASKS -PenableWarningsAsErrors=true
60+
./gradlew $TASKS -PenableWarningsAsErrors=true --configuration-cache
5861
- name: Save Android ccache
5962
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }}
6063
uses: actions/cache/save@v4

.github/actions/build-npm-package/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ inputs:
1111
required: false
1212
description: The GHA npm token, required only to publish to npm
1313
default: ''
14+
gradle-cache-encryption-key:
15+
description: The encryption key needed to store the Gradle Configuration cache
16+
1417
runs:
1518
using: composite
1619
steps:
@@ -102,6 +105,8 @@ runs:
102105
uses: ./.github/actions/setup-node
103106
- name: Setup gradle
104107
uses: ./.github/actions/setup-gradle
108+
with:
109+
cache-encryption-key: ${{ inputs.gradle-cache-encryption-key }}
105110
- name: Install dependencies
106111
uses: ./.github/actions/yarn-install
107112
- name: Build packages

.github/actions/setup-gradle/action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ inputs:
44
cache-read-only:
55
description: "Whether the Gradle Cache should be in read-only mode so this job won't be allowed to write to it"
66
default: "true"
7+
cache-encryption-key:
8+
description: "The encryption key needed to store the Gradle Configuration cache"
79
runs:
810
using: "composite"
911
steps:
@@ -15,6 +17,7 @@ runs:
1517
cache-read-only: ${{ (github.ref != 'refs/heads/main' && !contains(github.ref, '-stable')) || inputs.cache-read-only == 'true' }}
1618
# Similarly, for those jobs we want to start with a clean cache so it doesn't grow without limits (this is the negation of the previous condition).
1719
cache-write-only: ${{ (github.ref == 'refs/heads/main' || contains(github.ref, '-stable')) && inputs.cache-read-only != 'true' }}
18-
# Temporarily disabling to try resolve a cache cleanup failure
19-
# gradle-home-cache-cleanup: true
2020
add-job-summary-as-pr-comment: on-failure
21+
# Encryption key for the Gradle Configuration Cache.
22+
# See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:secrets:configuring_encryption_key
23+
cache-encryption-key: ${{ inputs.cache-encryption-key }}

.github/workflows/nightly.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ jobs:
153153
uses: ./.github/actions/build-android
154154
with:
155155
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
156+
gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
156157

157158
build_npm_package:
158159
runs-on: 8-core-ubuntu
@@ -188,3 +189,4 @@ jobs:
188189
hermes-ws-dir: ${{ env.HERMES_WS_DIR }}
189190
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
190191
gha-npm-token: ${{ env.GHA_NPM_TOKEN }}
192+
gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}

.github/workflows/publish-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ jobs:
150150
uses: ./.github/actions/build-android
151151
with:
152152
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
153+
gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
153154

154155
build_npm_package:
155156
runs-on: 8-core-ubuntu
@@ -189,6 +190,7 @@ jobs:
189190
hermes-ws-dir: ${{ env.HERMES_WS_DIR }}
190191
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
191192
gha-npm-token: ${{ env.GHA_NPM_TOKEN }}
193+
gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
192194
- name: Publish @react-native-community/template
193195
id: publish-template-to-npm
194196
uses: actions/github-script@v6

.github/workflows/test-all.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ jobs:
444444
with:
445445
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
446446
run-e2e-tests: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests }}
447+
gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
447448

448449
test_e2e_android_rntester:
449450
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests }}
@@ -504,6 +505,7 @@ jobs:
504505
with:
505506
hermes-ws-dir: ${{ env.HERMES_WS_DIR }}
506507
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
508+
gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
507509

508510
test_android_helloworld:
509511
runs-on: 4-core-ubuntu
@@ -542,6 +544,8 @@ jobs:
542544
path: /tmp/maven-local
543545
- name: Setup gradle
544546
uses: ./.github/actions/setup-gradle
547+
with:
548+
cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
545549
- name: Run yarn install
546550
uses: ./.github/actions/yarn-install
547551
- name: Prepare the Helloworld application

0 commit comments

Comments
 (0)