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 cfc1936 commit d4a7538
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [16, 18, 20]
node: [16]
env:
GITHUB_CI: true
steps:
Expand Down Expand Up @@ -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
20 changes: 12 additions & 8 deletions spec/constructor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || "";
Expand All @@ -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"),
]);
});
Expand Down

0 comments on commit d4a7538

Please sign in to comment.