Skip to content

Commit 5f0e35b

Browse files
committed
ci: stop rebuilding the test app during packaging, single-ABI emulator tests, ccache, CMake 3.31
The CI Build job spent ~23 minutes on the npm package because every :runtime:assembleRelease pass (one per AAR flavor) dragged a full test-app build - both variants, including 8 CMake configure+builds - through finalizedBy(":app:buildMetadata") hooks on nearly every runtime task, plus reverse hooks in app/build.gradle attaching metadata tasks onto library tasks. The app already reaches buildMetadata through its merge*Assets dependency, so packaging now builds only the three AARs (12 native builds instead of 24 plus three app builds). Metadata wiring changes: - runtime/build.gradle: drop the finalizedBy(":app:buildMetadata") hooks - app/build.gradle: drop the reverse hooks onto subprojects' library tasks; instead order library classes.jar producers (bundleLibCompileToJar<Variant>) before cleanupAllJars, which consumes them as declared inputs - app/build.gradle: buildMetadata only depends on the selected build type's variant tasks; the generator only reads that variant's classes, and depending on both variants forced a release app build into assembleDebug Test job: forward -Pabis through the runtests Exec layers and pass -Pabis=x86_64 in CI so the emulator run compiles one ABI instead of eight ABI/variant combinations. Toolchain/caching: - pin CMake 3.31.6 (CI previously installed the vestigial 3.6 fork while AGP auto-installed and used 3.22.1) - re-enable the ccache CMake argument (the -DUSE_CCACHE wiring was commented out, so -PuseCCache never reached CMake), drop -PnoCCache in CI, and persist ~/.ccache via actions/cache - enable org.gradle.parallel/org.gradle.caching in CI only (runner-level gradle.properties), and cancel superseded PR runs via concurrency Verified locally: full package build from scratch (three AARs with all four ABIs, classes.jar and prefab intact), :runtime:assembleRelease and :runtime:testDebugUnitTest schedule zero :app tasks, assembleDebug builds only the debug variant and one ABI with metadata present in the APK, and the full on-device suite passes (879 tests, 0 failures).
1 parent 7e1fdab commit 5f0e35b

6 files changed

Lines changed: 112 additions & 94 deletions

File tree

.github/workflows/npm_release.yml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
NPM_TAG: "next"
1717
EMULATOR_NAME: "runtime-emu"
1818
NDK_VERSION: r29
19+
CMAKE_VERSION: "3.31.6"
1920
ANDROID_API: 33
2021
ANDROID_ABI: x86_64
2122
NDK_ARCH: linux
@@ -53,7 +54,7 @@ jobs:
5354
uses: android-actions/setup-android@651bceb6f9ca583f16b8d75b62c36ded2ae6fc9c # v4.0.0
5455
- name: Setup NDK
5556
run: |
56-
echo "y" | sdkmanager "cmake;3.6.4111459"
57+
echo "y" | sdkmanager "cmake;$CMAKE_VERSION"
5758
wget -q https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip
5859
chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip
5960
unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip
@@ -62,6 +63,20 @@ jobs:
6263
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV
6364
echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV
6465
echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH
66+
- name: Setup ccache
67+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
68+
with:
69+
path: ~/.ccache
70+
key: ccache-build-${{ github.sha }}
71+
restore-keys: ccache-build-
72+
- name: Configure build caches
73+
run: |
74+
command -v ccache || sudo apt-get install -y ccache
75+
ccache --version
76+
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
77+
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
78+
mkdir -p ~/.gradle
79+
printf 'org.gradle.parallel=true\norg.gradle.caching=true\n' >> ~/.gradle/gradle.properties
6580
- name: Install Dependencies
6681
run: |
6782
npm install
@@ -96,7 +111,9 @@ jobs:
96111
- name: Fetch prebuilt V8
97112
run: ./download_v8.sh
98113
- name: Build npm package
99-
run: ./gradlew -PgitCommitVersion=${{ github.sha }} -PnoCCache --stacktrace
114+
run: ./gradlew -PgitCommitVersion=${{ github.sha }} --stacktrace
115+
- name: ccache stats
116+
run: ccache -s
100117
- name: Upload npm package artifact
101118
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
102119
with:
@@ -133,7 +150,7 @@ jobs:
133150
uses: android-actions/setup-android@651bceb6f9ca583f16b8d75b62c36ded2ae6fc9c # v4.0.0
134151
- name: Setup NDK
135152
run: |
136-
echo "y" | sdkmanager "cmake;3.6.4111459"
153+
echo "y" | sdkmanager "cmake;$CMAKE_VERSION"
137154
wget -q https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip
138155
chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip
139156
unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip
@@ -142,6 +159,20 @@ jobs:
142159
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV
143160
echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV
144161
echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH
162+
- name: Setup ccache
163+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
164+
with:
165+
path: ~/.ccache
166+
key: ccache-test-${{ github.sha }}
167+
restore-keys: ccache-test-
168+
- name: Configure build caches
169+
run: |
170+
command -v ccache || sudo apt-get install -y ccache
171+
ccache --version
172+
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
173+
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
174+
mkdir -p ~/.gradle
175+
printf 'org.gradle.parallel=true\norg.gradle.caching=true\n' >> ~/.gradle/gradle.properties
145176
- name: Install Dependencies
146177
run: |
147178
npm install
@@ -162,7 +193,8 @@ jobs:
162193
# this is needed on API 30+
163194
#target: google_apis
164195
arch: ${{env.ANDROID_ABI}}
165-
script: ./gradlew runtestsAndVerifyResults --stacktrace
196+
# only build native code for the ABI the emulator actually runs
197+
script: ./gradlew runtestsAndVerifyResults -Pabis=${{env.ANDROID_ABI}} --stacktrace
166198
- name: Upload Test Results
167199
if: ${{ !cancelled() }} # run this step even if previous step failed
168200
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

.github/workflows/pull_request.yml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ env:
66
NPM_TAG: "pr"
77
EMULATOR_NAME: "runtime-emu"
88
NDK_VERSION: r29
9+
CMAKE_VERSION: "3.31.6"
910
ANDROID_API: 33
1011
ANDROID_ABI: x86_64
1112
NDK_ARCH: linux
1213

1314
permissions:
1415
contents: read
1516

17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
1621
jobs:
1722
build:
1823
name: Build
@@ -38,7 +43,7 @@ jobs:
3843
uses: android-actions/setup-android@651bceb6f9ca583f16b8d75b62c36ded2ae6fc9c # v4.0.0
3944
- name: Setup NDK
4045
run: |
41-
echo "y" | sdkmanager "cmake;3.6.4111459"
46+
echo "y" | sdkmanager "cmake;$CMAKE_VERSION"
4247
wget -q https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip
4348
chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip
4449
unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip
@@ -47,6 +52,20 @@ jobs:
4752
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV
4853
echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV
4954
echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH
55+
- name: Setup ccache
56+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
57+
with:
58+
path: ~/.ccache
59+
key: ccache-build-${{ github.sha }}
60+
restore-keys: ccache-build-
61+
- name: Configure build caches
62+
run: |
63+
command -v ccache || sudo apt-get install -y ccache
64+
ccache --version
65+
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
66+
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
67+
mkdir -p ~/.gradle
68+
printf 'org.gradle.parallel=true\norg.gradle.caching=true\n' >> ~/.gradle/gradle.properties
5069
- name: Install Dependencies
5170
run: |
5271
npm install
@@ -70,7 +89,9 @@ jobs:
7089
- name: Fetch prebuilt V8
7190
run: ./download_v8.sh
7291
- name: Build npm package
73-
run: ./gradlew -PgitCommitVersion=${{ github.sha }} -PnoCCache --stacktrace
92+
run: ./gradlew -PgitCommitVersion=${{ github.sha }} --stacktrace
93+
- name: ccache stats
94+
run: ccache -s
7495
- name: Upload npm package artifact
7596
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
7697
with:
@@ -110,6 +131,20 @@ jobs:
110131
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV
111132
echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV
112133
echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH
134+
- name: Setup ccache
135+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
136+
with:
137+
path: ~/.ccache
138+
key: ccache-test-${{ github.sha }}
139+
restore-keys: ccache-test-
140+
- name: Configure build caches
141+
run: |
142+
command -v ccache || sudo apt-get install -y ccache
143+
ccache --version
144+
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
145+
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
146+
mkdir -p ~/.gradle
147+
printf 'org.gradle.parallel=true\norg.gradle.caching=true\n' >> ~/.gradle/gradle.properties
113148
- name: Install Dependencies
114149
run: |
115150
npm install
@@ -130,7 +165,8 @@ jobs:
130165
# this is needed on API 30+
131166
#target: google_apis
132167
arch: ${{env.ANDROID_ABI}}
133-
script: ./gradlew runtestsAndVerifyResults --stacktrace
168+
# only build native code for the ABI the emulator actually runs
169+
script: ./gradlew runtestsAndVerifyResults -Pabis=${{env.ANDROID_ABI}} --stacktrace
134170
- name: Upload Test Results
135171
if: ${{ !cancelled() }} # run this step even if previous step failed
136172
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import groovy.json.JsonOutput
1717
def onlyX86 = project.hasProperty("onlyX86")
1818
def useCCache = !project.hasProperty("noCCache")
1919
def hasNdkVersion = project.hasProperty("ndkVersion")
20+
def selectedAbis = project.hasProperty("abis") ? project.property("abis") : null
2021

2122
if (hasNdkVersion) {
2223
println "Using NDK version " + ndkVersion
@@ -464,6 +465,9 @@ def getRunTestsBuildArguments = { taskName ->
464465
if (useCCache) {
465466
arguments.add("-PuseCCache")
466467
}
468+
if (selectedAbis != null) {
469+
arguments.add("-Pabis=${selectedAbis}")
470+
}
467471
arguments += ["--warning-mode", "all"]
468472
return arguments
469473
}

test-app/app/build.gradle

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,13 @@ task buildMetadata(type: BuildToolTask) {
747747

748748

749749
android.applicationVariants.all { variant ->
750+
// The generator only reads the selected build type's classes (see doFirst),
751+
// so depending on the other variant's tasks would just force a second full
752+
// app build without affecting the produced metadata.
753+
if (variant.buildType.name != project.ext.selectedBuildType) {
754+
return
755+
}
756+
750757
def buildTypeName = variant.buildType.name.capitalize()
751758
def mergeShadersTaskName = "merge${buildTypeName}Shaders"
752759
def mergeShadersTask = tasks.findByName(mergeShadersTaskName)
@@ -1303,18 +1310,19 @@ tasks.configureEach({ DefaultTask currentTask ->
13031310

13041311
})
13051312

1306-
rootProject.subprojects.forEach {
1307-
it.tasks.configureEach({ DefaultTask currentTask ->
1308-
if (currentTask =~ /.+bundleLibCompileToJar.*/) {
1309-
currentTask.finalizedBy(cleanupAllJars)
1310-
}
1311-
1312-
if (currentTask =~ /bundleLibRuntimeToDir.*/) {
1313-
currentTask.finalizedBy(buildMetadata)
1314-
}
1315-
1316-
if (currentTask =~ /compile.*LibraryResources/) {
1317-
currentTask.finalizedBy(buildMetadata)
1313+
// Do not attach app metadata tasks onto other projects' library tasks: any build
1314+
// that actually packages this app reaches buildMetadata through merge*Assets, and
1315+
// hooking library tasks forces a full app build into library-only invocations
1316+
// (e.g. :runtime:assembleRelease).
1317+
//
1318+
// Library subprojects' classes.jar is an input of the jar-extraction pipeline
1319+
// (see processJar), so its producer must be ordered before cleanupAllJars —
1320+
// only for the selected build type; depending on the whole compile classpath
1321+
// instead creates a cycle through this app's own compile tasks.
1322+
rootProject.subprojects.forEach { sub ->
1323+
if (sub.path != project.path) {
1324+
sub.tasks.matching { it.name == "bundleLibCompileToJar${project.selectedBuildType.capitalize()}" }.all { producer ->
1325+
cleanupAllJars.dependsOn(producer)
13181326
}
1319-
})
1327+
}
13201328
}

test-app/runtests.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ def runOnDeviceOrEmulator = runOnDevice ? "-d" : "-e"
44

55
def onlyX86 = project.hasProperty("onlyX86")
66
def useCCache = project.hasProperty("useCCache")
7+
def selectedAbis = project.hasProperty("abis") ? project.property("abis") : null
78

89
// task deleteDist(type: Delete) {
910
// doFirst {
@@ -37,6 +38,9 @@ def getBuildArguments = { ->
3738
if (useCCache) {
3839
arguments.add("-PuseCCache")
3940
}
41+
if (selectedAbis != null) {
42+
arguments.add("-Pabis=${selectedAbis}")
43+
}
4044

4145
arguments.add("-PuseKotlin=true")
4246

test-app/runtime/build.gradle

Lines changed: 8 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,10 @@ android {
115115
if (optimizedWithInspector) {
116116
arguments.add("-DOPTIMIZED_WITH_INSPECTOR_BUILD=true")
117117
}
118-
//
119-
// if (useCCache) {
120-
// arguments.add("-DUSE_CCACHE=true")
121-
// }
122-
//
123-
// arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}"
118+
119+
if (useCCache) {
120+
arguments.add("-DUSE_CCACHE=true")
121+
}
124122

125123
cppFlags "-std=c++20"
126124
arguments "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
@@ -154,7 +152,7 @@ android {
154152
}
155153
externalNativeBuild {
156154
cmake {
157-
// version "3.18.1"
155+
version "3.31.6"
158156
path "CMakeLists.txt"
159157
}
160158
}
@@ -247,73 +245,9 @@ tasks.configureEach { task ->
247245
task.finalizedBy createPackageConfigFileTask(taskName)
248246
}
249247

250-
if (task =~ /configureCMake.*/) {
251-
task.finalizedBy(":app:buildMetadata")
252-
}
253-
254-
if (task =~ /buildCMake.*/) {
255-
task.finalizedBy(":app:buildMetadata")
256-
}
257-
258-
if (taskName.contains("syncReleaseLibJars") || taskName.contains("syncDebugLibJars")) {
259-
task.finalizedBy(":app:buildMetadata")
260-
}
261-
262-
if (taskName.contains("mergeReleaseJniLibFolders") || taskName.contains("mergeDebugJniLibFolders")) {
263-
task.finalizedBy(":app:buildMetadata")
264-
}
265-
266-
if (taskName.contains("mergeReleaseShaders") || taskName.contains("mergeDebugShaders")) {
267-
task.finalizedBy(":app:buildMetadata")
268-
}
269-
270-
if (taskName.contains("packageReleaseAssets") || taskName.contains("packageDebugAssets")) {
271-
task.finalizedBy(":app:buildMetadata")
272-
}
273-
274-
if (taskName.contains("copyReleaseJniLibsProjectOnly") || taskName.contains("copyDebugJniLibsProjectOnly")) {
275-
task.finalizedBy(":app:buildMetadata")
276-
}
277-
278-
if (taskName.contains("copyReleaseJniLibsProjectAndLocalJars") || taskName.contains("copyDebugJniLibsProjectAndLocalJars")) {
279-
task.finalizedBy(":app:buildMetadata")
280-
}
281-
282-
if (taskName.contains("generateReleaseLintVitalModel") || taskName.contains("generateDebugLintVitalModel")) {
283-
task.finalizedBy(":app:buildMetadata")
284-
}
285-
286-
if (taskName.contains("lintVitalAnalyzeRelease") || taskName.contains("lintVitalAnalyzeDebug")) {
287-
task.finalizedBy(":app:buildMetadata")
288-
}
289-
290-
if (task =~ /lintAnalyze.+AndroidTest/) {
291-
task.finalizedBy(":app:buildMetadata")
292-
}
293-
294-
if (task =~ /compile.+UnitTestJavaWithJavac/) {
295-
task.finalizedBy(":app:buildMetadata")
296-
}
297-
298-
if (task =~ /generate.+LintModel/) {
299-
task.finalizedBy(":app:buildMetadata")
300-
}
301-
302-
if (task =~ /process.+Manifest/) {
303-
task.finalizedBy(":app:buildMetadata")
304-
}
305-
306-
if (task =~ /merge.+Resources/) {
307-
task.finalizedBy(":app:buildMetadata")
308-
}
309-
310-
if (task =~ /verify.+Resources/) {
311-
task.finalizedBy(":app:buildMetadata")
312-
}
313-
314-
if (task =~ /test.+UnitTest/) {
315-
task.finalizedBy(":app:buildMetadata")
316-
}
248+
// Do not wire :app:buildMetadata onto runtime tasks: the app declares its own
249+
// dependency on it (merge*Assets), and forcing it here drags a full :app build
250+
// (both variants) into every standalone :runtime:assembleRelease.
317251
}
318252

319253
task 'setPackageVersion' {

0 commit comments

Comments
 (0)