diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index a0805f1eb..dd6c56ed2 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -3,13 +3,15 @@ on: pull_request: push: branches: - - master + - main paths-ignore: - '**.md' jobs: test: runs-on: ${{ matrix.os }} + env: + JAVA_TOOL_OPTIONS: -Xmx4g timeout-minutes: 15 strategy: matrix: @@ -49,9 +51,6 @@ jobs: uses: actions/setup-java@v1 with: java-version: 14 - - name: Clean cache - if: matrix.os == 'macos-latest' - run: mv ~/.gradle/caches ~/.gradle/.invalid_caches - uses: actions/cache@v1 with: path: ~/.gradle/caches diff --git a/CHANGELOG.md b/CHANGELOG.md index 3751d72c2..86652def1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## v2.11.0 + +* Support running multiple instances of the action sequentially in a single job - [#73](https://github.com/ReactiveCircus/android-emulator-runner/issues/73). + ## v2.10.0 * Support Android 11 (API 30) system images. diff --git a/README.md b/README.md index b16058a2b..c3cdd9c3e 100644 --- a/README.md +++ b/README.md @@ -116,15 +116,16 @@ These are some of the open-source projects using (or used) **Android Emulator Ru - [coil-kt/coil](https://github.com/coil-kt/coil/blob/master/.github/workflows/) - [cashapp/sqldelight](https://github.com/cashapp/sqldelight/blob/master/.github/workflows/) -- [square/workflow](https://github.com/square/workflow/blob/master/.github/workflows/) +- [square/workflow](https://github.com/square/workflow/blob/main/.github/workflows/) - [square/retrofit](https://github.com/square/retrofit/blob/master/.github/workflows/) - [natario1/CameraView](https://github.com/natario1/CameraView/tree/master/.github/workflows) - [natario1/Transcoder](https://github.com/natario1/Transcoder/tree/master/.github/workflows) -- [chrisbanes/insetter](https://github.com/chrisbanes/insetter/tree/master/.github/workflows) -- [slackhq/keeper](https://github.com/slackhq/keeper/tree/master/.github/workflows) +- [chrisbanes/insetter](https://github.com/chrisbanes/insetter/tree/main/.github/workflows) +- [slackhq/keeper](https://github.com/slackhq/keeper/tree/main/.github/workflows) - [android/compose-samples](https://github.com/android/compose-samples/blob/master/.github/workflows/ci.yaml) -- [ReactiveCircus/streamlined](https://github.com/ReactiveCircus/streamlined/tree/master/.github/workflows) +- [ReactiveCircus/streamlined](https://github.com/ReactiveCircus/streamlined/tree/main/.github/workflows) - [ReactiveCircus/FlowBinding](https://github.com/ReactiveCircus/FlowBinding) +- [JakeWharton/RxBinding](https://github.com/JakeWharton/RxBinding/tree/master/.github/workflows) - [vinaygaba/Learn-Jetpack-Compose-By-Example](https://github.com/vinaygaba/Learn-Jetpack-Compose-By-Example/) - [ashishb/adb-enhanced](https://github.com/ashishb/adb-enhanced/tree/master/.github/workflows) - [vgaidarji/ci-matters](https://github.com/vgaidarji/ci-matters/blob/master/.github/workflows/main.yaml) diff --git a/RELEASING.md b/RELEASING.md index a7bcaeff8..8bc80e27b 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -4,7 +4,7 @@ Refer to the [recommendeations for versioning and releasing actions](https://git ## New major release -- From `master` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date. +- From `main` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date. - Update `CHANGELOG.md`, push change with "Prepare for release X.Y.Z." (where X.Y.Z is the new version). - Create a new branch e.g. `release/v1`, comment out `node_modules/` in `.gitignore`, commit the change (do not commit yet `node_modules`). - Run `npm prune --production`. @@ -17,9 +17,9 @@ Refer to the [recommendeations for versioning and releasing actions](https://git ## New minor / patch release -- From `master` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date. +- From `main` branch, run `npm run build && npm test --clean && npm run lint` to make sure `lib/*.js` are up-to-date. - Update `CHANGELOG.md`, push change with "Prepare for release X.Y.Z." (where X.Y.Z is the new version). -- Merge from `master` into the release branch e.g. `release/v1`. +- Merge from `main` into the release branch e.g. `release/v1`. - Run `npm prune --production`. - Commit merged changes (and the pruned `node_modules`). - Push to remote. diff --git a/lib/sdk-installer.js b/lib/sdk-installer.js index 6b1cf2361..e178a2f8c 100644 --- a/lib/sdk-installer.js +++ b/lib/sdk-installer.js @@ -17,6 +17,8 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); const exec = __importStar(require("@actions/exec")); +const io = __importStar(require("@actions/io")); +const fs = __importStar(require("fs")); const BUILD_TOOLS_VERSION = '30.0.0'; const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-6514223_latest.zip'; const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-6514223_latest.zip'; @@ -27,31 +29,38 @@ const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/comman function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion) { return __awaiter(this, void 0, void 0, function* () { const isOnMac = process.platform === 'darwin'; - console.log('Installing new cmdline-tools.'); - const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX; - yield exec.exec(`sudo mkdir ${process.env.ANDROID_HOME}/cmdline-tools`); - yield exec.exec(`curl -fo commandlinetools.zip ${sdkUrl}`); - yield exec.exec(`sudo unzip -q commandlinetools.zip -d ${process.env.ANDROID_HOME}/cmdline-tools`); - yield exec.exec(`sudo rm -f commandlinetools.zip`); - // add paths for commandline-tools and platform-tools - core.addPath(`${process.env.ANDROID_HOME}/cmdline-tools/tools:${process.env.ANDROID_HOME}/cmdline-tools/tools/bin:${process.env.ANDROID_HOME}/platform-tools`); - // additional permission and license requirements for Linux if (!isOnMac) { yield exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`); - yield exec.exec(`sh -c \\"echo -e '\n84831b9409646a918e30573bab4c9c91346d8abd' > ${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license"`); + } + const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`; + if (!fs.existsSync(cmdlineToolsPath)) { + console.log('Installing new cmdline-tools.'); + const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX; + yield io.mkdirP(`${process.env.ANDROID_HOME}/cmdline-tools`); + yield exec.exec(`curl -fo commandlinetools.zip ${sdkUrl}`); + yield exec.exec(`unzip -q commandlinetools.zip -d ${cmdlineToolsPath}`); + yield io.rmRF('commandlinetools.zip'); + // add paths for commandline-tools and platform-tools + core.addPath(`${cmdlineToolsPath}/tools:${cmdlineToolsPath}/tools/bin:${process.env.ANDROID_HOME}/platform-tools`); + } + // additional permission and license requirements for Linux + const sdkPreviewLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license`; + if (!isOnMac && !fs.existsSync(sdkPreviewLicensePath)) { + yield exec.exec(`sh -c \\"echo -e '\n84831b9409646a918e30573bab4c9c91346d8abd' > ${sdkPreviewLicensePath}"`); } // license required for API 30 system images - if (apiLevel == 30) { - yield exec.exec(`sh -c \\"echo -e '\n859f317696f67ef3d7f30a50a5560e7834b43903' > ${process.env.ANDROID_HOME}/licenses/android-sdk-arm-dbt-license"`); + const sdkArmDbtLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-arm-dbt-license`; + if (apiLevel == 30 && !fs.existsSync(sdkArmDbtLicensePath)) { + yield exec.exec(`sh -c \\"echo -e '\n859f317696f67ef3d7f30a50a5560e7834b43903' > ${sdkArmDbtLicensePath}"`); } console.log('Installing latest build tools, platform tools, and platform.'); yield exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`); if (emulatorBuild) { console.log(`Installing emulator build ${emulatorBuild}.`); yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`); - yield exec.exec(`sudo rm -rf ${process.env.ANDROID_HOME}/emulator`); - yield exec.exec(`sudo unzip -q emulator.zip -d ${process.env.ANDROID_HOME}`); - yield exec.exec(`sudo rm -f emulator.zip`); + yield io.rmRF(`${process.env.ANDROID_HOME}/emulator`); + yield exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_HOME}`); + yield io.rmRF('emulator.zip'); } else { console.log('Installing latest emulator.'); diff --git a/src/sdk-installer.ts b/src/sdk-installer.ts index 19744c014..4ec7dfe22 100644 --- a/src/sdk-installer.ts +++ b/src/sdk-installer.ts @@ -1,5 +1,7 @@ import * as core from '@actions/core'; import * as exec from '@actions/exec'; +import * as io from '@actions/io'; +import * as fs from 'fs'; const BUILD_TOOLS_VERSION = '30.0.0'; const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-6514223_latest.zip'; @@ -11,24 +13,34 @@ const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/comman */ export async function installAndroidSdk(apiLevel: number, target: string, arch: string, emulatorBuild?: string, ndkVersion?: string, cmakeVersion?: string): Promise { const isOnMac = process.platform === 'darwin'; - console.log('Installing new cmdline-tools.'); - const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX; - await exec.exec(`sudo mkdir ${process.env.ANDROID_HOME}/cmdline-tools`); - await exec.exec(`curl -fo commandlinetools.zip ${sdkUrl}`); - await exec.exec(`sudo unzip -q commandlinetools.zip -d ${process.env.ANDROID_HOME}/cmdline-tools`); - await exec.exec(`sudo rm -f commandlinetools.zip`); - // add paths for commandline-tools and platform-tools - core.addPath(`${process.env.ANDROID_HOME}/cmdline-tools/tools:${process.env.ANDROID_HOME}/cmdline-tools/tools/bin:${process.env.ANDROID_HOME}/platform-tools`); - - // additional permission and license requirements for Linux if (!isOnMac) { await exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`); - await exec.exec(`sh -c \\"echo -e '\n84831b9409646a918e30573bab4c9c91346d8abd' > ${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license"`); } + + const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`; + if (!fs.existsSync(cmdlineToolsPath)) { + console.log('Installing new cmdline-tools.'); + const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX; + await io.mkdirP(`${process.env.ANDROID_HOME}/cmdline-tools`); + await exec.exec(`curl -fo commandlinetools.zip ${sdkUrl}`); + await exec.exec(`unzip -q commandlinetools.zip -d ${cmdlineToolsPath}`); + await io.rmRF('commandlinetools.zip'); + + // add paths for commandline-tools and platform-tools + core.addPath(`${cmdlineToolsPath}/tools:${cmdlineToolsPath}/tools/bin:${process.env.ANDROID_HOME}/platform-tools`); + } + + // additional permission and license requirements for Linux + const sdkPreviewLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-preview-license`; + if (!isOnMac && !fs.existsSync(sdkPreviewLicensePath)) { + await exec.exec(`sh -c \\"echo -e '\n84831b9409646a918e30573bab4c9c91346d8abd' > ${sdkPreviewLicensePath}"`); + } + // license required for API 30 system images - if (apiLevel == 30) { - await exec.exec(`sh -c \\"echo -e '\n859f317696f67ef3d7f30a50a5560e7834b43903' > ${process.env.ANDROID_HOME}/licenses/android-sdk-arm-dbt-license"`); + const sdkArmDbtLicensePath = `${process.env.ANDROID_HOME}/licenses/android-sdk-arm-dbt-license`; + if (apiLevel == 30 && !fs.existsSync(sdkArmDbtLicensePath)) { + await exec.exec(`sh -c \\"echo -e '\n859f317696f67ef3d7f30a50a5560e7834b43903' > ${sdkArmDbtLicensePath}"`); } console.log('Installing latest build tools, platform tools, and platform.'); @@ -37,9 +49,9 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch: if (emulatorBuild) { console.log(`Installing emulator build ${emulatorBuild}.`); await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`); - await exec.exec(`sudo rm -rf ${process.env.ANDROID_HOME}/emulator`); - await exec.exec(`sudo unzip -q emulator.zip -d ${process.env.ANDROID_HOME}`); - await exec.exec(`sudo rm -f emulator.zip`); + await io.rmRF(`${process.env.ANDROID_HOME}/emulator`); + await exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_HOME}`); + await io.rmRF('emulator.zip'); } else { console.log('Installing latest emulator.'); await exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`);