|
1 | 1 | name: "Setup Android Replay Host" |
2 | 2 | description: "Prepare the Android CI host for replay tests and expose the agent-device home path" |
3 | 3 |
|
| 4 | +inputs: |
| 5 | + package-helpers: |
| 6 | + description: "Restore or package the npm-bundled Android snapshot and IME helpers" |
| 7 | + required: false |
| 8 | + default: "false" |
| 9 | + |
4 | 10 | outputs: |
5 | 11 | agent-home-dir: |
6 | 12 | description: "Resolved agent-device home directory" |
7 | 13 | value: ${{ steps.agent-home.outputs.dir }} |
| 14 | + helpers-cache-hit: |
| 15 | + description: "Whether packaged Android helpers were restored from cache" |
| 16 | + value: ${{ steps.android-helpers-cache.outputs.cache-hit }} |
8 | 17 |
|
9 | 18 | runs: |
10 | 19 | using: "composite" |
|
20 | 29 | sudo udevadm control --reload-rules |
21 | 30 | sudo udevadm trigger --name-match=kvm |
22 | 31 | shell: bash |
| 32 | + |
| 33 | + - name: Resolve Android helper source hash |
| 34 | + if: inputs.package-helpers == 'true' |
| 35 | + id: android-helper-source |
| 36 | + run: | |
| 37 | + VERSION="$(node -p 'require("./package.json").version')" |
| 38 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 39 | + echo "value=${{ hashFiles('android/snapshot-helper/AndroidManifest.xml', 'android/snapshot-helper/debug.keystore', 'android/snapshot-helper/src/**', 'android/ime-helper/AndroidManifest.xml', 'android/ime-helper/res/**', 'android/ime-helper/src/**', 'scripts/build-android-snapshot-helper.sh', 'scripts/package-android-snapshot-helper.sh', 'scripts/build-android-ime-helper.sh', 'scripts/package-android-ime-helper.sh', '.github/actions/setup-android-replay-host/action.yml') }}" >> "$GITHUB_OUTPUT" |
| 40 | + shell: bash |
| 41 | + |
| 42 | + - name: Restore packaged Android helpers |
| 43 | + if: inputs.package-helpers == 'true' |
| 44 | + id: android-helpers-cache |
| 45 | + uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3 |
| 46 | + with: |
| 47 | + path: | |
| 48 | + android/snapshot-helper/dist |
| 49 | + android/ime-helper/dist |
| 50 | + key: android-helpers-${{ runner.os }}-${{ runner.arch }}-api36-v${{ steps.android-helper-source.outputs.version }}-${{ steps.android-helper-source.outputs.value }} |
| 51 | + |
| 52 | + - name: Install Android helper SDK packages |
| 53 | + if: inputs.package-helpers == 'true' && steps.android-helpers-cache.outputs.cache-hit != 'true' |
| 54 | + run: | |
| 55 | + SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}" |
| 56 | + SDKMANAGER="$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" |
| 57 | + if [ ! -x "$SDKMANAGER" ]; then |
| 58 | + SDKMANAGER="$SDK_ROOT/cmdline-tools/bin/sdkmanager" |
| 59 | + fi |
| 60 | + if [ ! -x "$SDKMANAGER" ]; then |
| 61 | + echo "sdkmanager not found under $SDK_ROOT" >&2 |
| 62 | + exit 1 |
| 63 | + fi |
| 64 | + yes | "$SDKMANAGER" --licenses >/dev/null || true |
| 65 | + "$SDKMANAGER" "platforms;android-36" "build-tools;36.0.0" |
| 66 | + shell: bash |
| 67 | + |
| 68 | + - name: Package npm-bundled Android helpers |
| 69 | + if: inputs.package-helpers == 'true' && steps.android-helpers-cache.outputs.cache-hit != 'true' |
| 70 | + run: | |
| 71 | + VERSION="${{ steps.android-helper-source.outputs.version }}" |
| 72 | + rm -rf android/snapshot-helper/dist android/ime-helper/dist |
| 73 | + sh ./scripts/package-android-snapshot-helper.sh "$VERSION" "v$VERSION" android/snapshot-helper/dist |
| 74 | + sh ./scripts/package-android-ime-helper.sh "$VERSION" android/ime-helper/dist |
| 75 | + shell: bash |
| 76 | + |
| 77 | + - name: Verify packaged Android helpers |
| 78 | + if: inputs.package-helpers == 'true' |
| 79 | + run: | |
| 80 | + VERSION="$(node -p 'require("./package.json").version')" |
| 81 | + test -f "android/snapshot-helper/dist/agent-device-android-snapshot-helper-$VERSION.manifest.json" |
| 82 | + test -f "android/ime-helper/dist/agent-device-android-ime-helper-$VERSION.manifest.json" |
| 83 | + shell: bash |
| 84 | + |
| 85 | + - name: Save packaged Android helpers |
| 86 | + if: inputs.package-helpers == 'true' && steps.android-helpers-cache.outputs.cache-hit != 'true' |
| 87 | + uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3 |
| 88 | + with: |
| 89 | + path: | |
| 90 | + android/snapshot-helper/dist |
| 91 | + android/ime-helper/dist |
| 92 | + key: android-helpers-${{ runner.os }}-${{ runner.arch }}-api36-v${{ steps.android-helper-source.outputs.version }}-${{ steps.android-helper-source.outputs.value }} |
0 commit comments