Skip to content

Commit

Permalink
chore: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
wtto00 committed Sep 15, 2023
1 parent fd5ac22 commit 7414de2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ jobs:
shell: bash
run: |
AVDMANAGER_PATH=$(which avdmanager)
echo $AVDMANAGER_PATH
AVDMANAGER_DIR=$(dirname "$AVDMANAGER_PATH")
echo $AVDMANAGER_DIR
ls $AVDMANAGER_DIR
mkdir $ANDROID_HOME/cmdline-tools
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
35 changes: 16 additions & 19 deletions spec/constructor.test.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
import path from "path";
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 || "";
const android = new Android();
expect([android.adbBin, android.avdmanagerBin, android.sdkmanagerBin, android.emulatorBin]).toEqual([
path.resolve(androidHome, "platform-tools/adb"),
"avdmanager",
"sdkmanager",
path.resolve(androidHome, "cmdline-tools/latest/bin/avdmanager"),
path.resolve(androidHome, "cmdline-tools/latest/bin/sdkmanager"),
path.resolve(androidHome, "emulator/emulator"),
]);
});

test("constructor with adb error path", () => {
test("constructor with error path", () => {
const androidHome = process.env.ANDROID_HOME || "";
const android = new Android({ adb: "platform-tools/adb111", emulator: "emulator/emulator111" });
const android = new Android({
adb: "platform-tools/adb111",
avdmanager: "cmdline-tools/latest/bin/avdmanager11",
emulator: "emulator/emulator111",
});
expect([android.adbBin, android.avdmanagerBin, android.sdkmanagerBin, android.emulatorBin]).toEqual([
"adb",
"avdmanager",
"sdkmanager",
path.resolve(androidHome, "cmdline-tools/latest/bin/sdkmanager"),
process.env.GITHUB_CI ? path.resolve(androidHome, "emulator/emulator111") : "emulator",
]);
});
Expand All @@ -37,24 +32,26 @@ describe("constructor", () => {
const androidHome = process.env.ANDROID_HOME || "";
const android = new Android({
adb: "platform-tools/adb",
avdmanager: "cmdline-tools/latest/bin/avdmanager",
sdkmanager: "cmdline-tools/latest/bin/sdkmanager",
emulator: "emulator/emulator",
});
expect([android.adbBin, android.avdmanagerBin, android.sdkmanagerBin, android.emulatorBin]).toEqual([
path.resolve(androidHome, "platform-tools/adb"),
'avdmanager',
'sdkmanager',
path.resolve(androidHome, "cmdline-tools/latest/bin/avdmanager"),
path.resolve(androidHome, "cmdline-tools/latest/bin/sdkmanager"),
path.resolve(androidHome, "emulator/emulator"),
]);
});

test("constructor with custom executable file environment variable", () => {
const androidHome = process.env.ANDROID_HOME || "";
process.env.adbBin = path.resolve(androidHome, 'platform-tools/adb');
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"),
'avdmanager',
'sdkmanager',
path.resolve(androidHome, "cmdline-tools/latest/bin/avdmanager"),
path.resolve(androidHome, "cmdline-tools/latest/bin/sdkmanager"),
path.resolve(androidHome, "emulator/emulator"),
]);
});
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Android {
if (execPath) {
this.avdmanagerBin = path.resolve(process.env.ANDROID_HOME, execPath);
} else if (!this.avdmanagerBin) {
this.avdmanagerBin = path.resolve(process.env.ANDROID_HOME, "./cmdline-tools/bin/avdmanager");
this.avdmanagerBin = path.resolve(process.env.ANDROID_HOME, "./cmdline-tools/latest/bin/avdmanager");
}
}

Expand All @@ -154,7 +154,7 @@ class Android {
if (execPath) {
this.sdkmanagerBin = path.resolve(process.env.ANDROID_HOME, execPath);
} else if (!this.sdkmanagerBin) {
this.sdkmanagerBin = path.resolve(process.env.ANDROID_HOME, "./cmdline-tools/bin/sdkmanager");
this.sdkmanagerBin = path.resolve(process.env.ANDROID_HOME, "./cmdline-tools/latest/bin/sdkmanager");
}
}
const regex = /Usage:/;
Expand Down

0 comments on commit 7414de2

Please sign in to comment.