Skip to content

Commit 63c4cf5

Browse files
committed
fix(ci): isolate candidate cache authority
1 parent 9b37e53 commit 63c4cf5

4 files changed

Lines changed: 660 additions & 127 deletions

File tree

‎.github/actions/setup-android-toolchain/action.yml‎

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,49 @@
11
name: Setup Android toolchain
22
description: Set up the pinned Java and Android SDK toolchain used by OpenClaw builds.
3+
inputs:
4+
cache-mode:
5+
description: Cache authority for this job (off, restore, or read-write).
6+
required: false
7+
default: "off"
8+
outputs:
9+
cache-mode:
10+
description: Validated cache authority for downstream save gates.
11+
value: ${{ inputs.cache-mode }}
312
runs:
413
using: composite
514
steps:
15+
- name: Validate cache mode
16+
shell: bash
17+
env:
18+
CACHE_MODE: ${{ inputs.cache-mode }}
19+
run: |
20+
case "$CACHE_MODE" in
21+
off|restore|read-write) ;;
22+
*)
23+
echo "::error::Invalid cache-mode input: '$CACHE_MODE' (expected off, restore, or read-write)"
24+
exit 2
25+
;;
26+
esac
27+
628
- name: Setup Java
729
uses: actions/setup-java@ad2b38190b15e4d6bdf0c97fb4fca8412226d287 # v5
830
with:
931
distribution: temurin
1032
# Keep sdkmanager on the stable JDK path for Linux CI runners.
1133
java-version: 17
12-
cache: gradle
13-
cache-dependency-path: |
14-
apps/android/**/*.gradle*
15-
apps/android/**/gradle-wrapper.properties
16-
apps/android/gradle/libs.versions.toml
17-
18-
- name: Cache Android SDK
19-
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
34+
35+
- name: Setup Gradle cache
36+
if: inputs.cache-mode != 'off'
37+
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
38+
with:
39+
cache-provider: basic
40+
cache-read-only: ${{ inputs.cache-mode != 'read-write' }}
41+
add-job-summary: never
42+
43+
- name: Restore Android SDK cache
44+
id: android-sdk-cache
45+
if: inputs.cache-mode != 'off'
46+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
2047
with:
2148
path: ~/.android-sdk
2249
key: ${{ runner.os }}-android-sdk-v1-cmdline-14742923-platform-37.0-build-tools-36.0.0
@@ -56,3 +83,10 @@ runs:
5683
"platform-tools" \
5784
"platforms;android-37.0" \
5885
"build-tools;36.0.0"
86+
87+
- name: Save Android SDK cache
88+
if: inputs.cache-mode == 'read-write' && steps.android-sdk-cache.outputs.cache-hit != 'true'
89+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
90+
with:
91+
path: ~/.android-sdk
92+
key: ${{ steps.android-sdk-cache.outputs.cache-primary-key }}

‎.github/workflows/android-release.yml‎

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

172172
- name: Setup Android toolchain
173173
uses: ./.github/actions/setup-android-toolchain
174+
with:
175+
cache-mode: read-write
174176

175177
- name: Create apps-signing read token
176178
if: ${{ steps.release_source.outputs.fallback_base_tag == '' }}

0 commit comments

Comments
 (0)