diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4720b23..2e509c7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [16, 18, 20] + node: [16] env: GITHUB_CI: true steps: @@ -47,12 +47,14 @@ jobs: distribution: temurin - name: Setup Android SDK uses: amyu/setup-android@v3 - - name: Set ANDROID_SDK_ROOT + - name: Copy cmdline-tools shell: bash run: | - echo "ANDROID_SDK_ROOT=$(echo $ANDROID_HOME)" >> $GITHUB_ENV - echo $GITHUB_ENV - echo $PATH + AVDMANAGER_PATH=$(which avdmanager) + AVDMANAGER_DIR="${AVDMANAGER_PATH%/../*}" + mkdir $ANDROID_HOME/cmdline-tools/latest/ + cp -r $AVDMANAGER_DIR $ANDROID_HOME/cmdline-tools/latest/ + ls $ANDROID_HOME/cmdline-tools/latest/ - name: Run tests 👩🏽‍💻 run: npm run test diff --git a/spec/constructor.test.ts b/spec/constructor.test.ts index f7bfbf8..49fdfb1 100644 --- a/spec/constructor.test.ts +++ b/spec/constructor.test.ts @@ -3,6 +3,13 @@ import Android from "../src/index.js"; const cmdLinePath = process.env.GITHUB_CI ? "cmdline-tools" : "cmdline-tools/latest"; +/** + * in Github Action + * avdmanager,adb,sdkmanager has been in PATH + * avdmanager,sdkmanager are not in ANDROID_HOME + * adb,emulator are in ANDROID_HOME + */ + describe("constructor", () => { test("constructor", () => { const androidHome = process.env.ANDROID_HOME || ""; @@ -29,28 +36,25 @@ describe("constructor", () => { test("constructor with custom path", () => { const androidHome = process.env.ANDROID_HOME || ""; const android = new Android({ - avdmanager: `${cmdLinePath}/bin/avdmanager`, - sdkmanager: `${cmdLinePath}/bin/sdkmanager`, adb: "platform-tools/adb", emulator: "emulator/emulator", }); expect([android.adbBin, android.avdmanagerBin, android.sdkmanagerBin, android.emulatorBin]).toEqual([ path.resolve(androidHome, "platform-tools/adb"), - path.resolve(androidHome, `${cmdLinePath}/bin/avdmanager`), - path.resolve(androidHome, `${cmdLinePath}/bin/sdkmanager`), + 'avdmanager', + 'sdkmanager', path.resolve(androidHome, "emulator/emulator"), ]); }); test("constructor with custom executable file environment variable", () => { const androidHome = process.env.ANDROID_HOME || ""; - process.env.avdmanagerBin = path.resolve(androidHome, `${cmdLinePath}/bin/avdmanager`); - process.env.sdkmanagerBin = path.resolve(androidHome, `${cmdLinePath}/bin/sdkmanager`); + process.env.adbBin = path.resolve(androidHome, 'platform-tools/adb'); const android = new Android(); expect([android.adbBin, android.avdmanagerBin, android.sdkmanagerBin, android.emulatorBin]).toEqual([ path.resolve(androidHome, "platform-tools/adb"), - path.resolve(androidHome, `${cmdLinePath}/bin/avdmanager`), - path.resolve(androidHome, `${cmdLinePath}/bin/sdkmanager`), + 'avdmanager', + 'sdkmanager', path.resolve(androidHome, "emulator/emulator"), ]); });