diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 79b7921a2..3f369c3af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,10 +17,10 @@ jobs: timeout-minutes: 15 strategy: matrix: - os: [macos-latest, ubuntu-latest] - api-level: [16, 23, 29] - target: [default, google_apis] - arch: [x86] + os: [ macos-latest, ubuntu-latest ] + api-level: [ 16, 23, 29 ] + target: [ default, google_apis ] + arch: [ x86 ] exclude: - os: ubuntu-latest api-level: 23 @@ -47,73 +47,86 @@ jobs: arch: x86_64 steps: - - name: checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 - - name: validate gradle wrapper - uses: gradle/wrapper-validation-action@v1 + - name: Validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 - - name: build, test and lint - run: | - npm install - npm run build - npm run lint - npm test + - name: Cache Node + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- - - name: Java 15 - uses: actions/setup-java@v1 - with: - java-version: 15 - - uses: actions/cache@v2 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/adb* - ~/.android/debug.keystore - key: avd-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }} + - name: Npm build, test and lint + run: | + npm install + npm run build + npm run lint + npm test - - name: assemble tests - uses: gradle/gradle-build-action@v2 - with: - build-root-directory: test-fixture - arguments: assembleAndroidTest + - name: Java 15 + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 15 - - name: run emulator to generate snapshot for caching - if: steps.avd-cache.outputs.cache-hit != 'true' - uses: ./ - with: - api-level: ${{ matrix.api-level }} - target: ${{ matrix.target }} - arch: ${{ matrix.arch }} - profile: Galaxy Nexus - cores: 2 - sdcard-path-or-size: 100M - avd-name: test - force-avd-creation: false - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: false - working-directory: ./test-fixture/ - channel: canary - script: echo "Generated AVD snapshot for caching." + - name: Gradle cache + uses: gradle/gradle-build-action@v2 - - name: run action - uses: ./ - with: - api-level: ${{ matrix.api-level }} - target: ${{ matrix.target }} - arch: ${{ matrix.arch }} - profile: Galaxy Nexus - cores: 2 - ram-size: 2048M - sdcard-path-or-size: 100M - avd-name: test - force-avd-creation: false - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: true - working-directory: ./test-fixture/ - channel: canary - script: | - echo $GITHUB_REPOSITORY - adb devices - ./gradlew connectedDebugAndroidTest + - name: AVD cache + uses: actions/cache@v3 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + ~/.android/debug.keystore + key: avd-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }} + + - name: Assemble tests + run: | + cd ./test-fixture/ + ./gradlew assembleAndroidTest + + - name: Create AVD and generate snapshot for caching + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: ./ + with: + api-level: ${{ matrix.api-level }} + target: ${{ matrix.target }} + arch: ${{ matrix.arch }} + profile: Galaxy Nexus + cores: 2 + sdcard-path-or-size: 100M + avd-name: test + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: false + working-directory: ./test-fixture/ + channel: canary + script: echo "Generated AVD snapshot for caching." + + - name: Run tests + uses: ./ + with: + api-level: ${{ matrix.api-level }} + target: ${{ matrix.target }} + arch: ${{ matrix.arch }} + profile: Galaxy Nexus + cores: 2 + ram-size: 2048M + sdcard-path-or-size: 100M + avd-name: test + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true + working-directory: ./test-fixture/ + channel: canary + script: | + echo $GITHUB_REPOSITORY + adb devices + ./gradlew connectedDebugAndroidTest diff --git a/.github/workflows/manually.yml b/.github/workflows/manually.yml index 3f7da86be..5bd6150f8 100644 --- a/.github/workflows/manually.yml +++ b/.github/workflows/manually.yml @@ -16,14 +16,18 @@ on: default: 'default' arch: description: 'CPU architecture of the system image - x86, x86_64 or arm64-v8a' + required: false default: 'x86' emulator-options: description: 'command-line options used when launching the emulator' + required: false default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim' emulator-build: + required: false description: 'build number of a specific version of the emulator binary to use' channel: description: 'Channel to download the SDK components from - `stable`, `beta`, `dev`, `canary`' + required: false default: 'stable' script: description: 'custom script to run - e.g. `./gradlew connectedCheck`' @@ -38,39 +42,45 @@ jobs: timeout-minutes: 15 steps: - - name: checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 - - name: validate gradle wrapper - uses: gradle/wrapper-validation-action@v1 + - name: Validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 - - name: build, test and lint - run: | - npm install - npm run build - npm run lint - npm test + - name: Cache Node + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- - - name: Java 15 - uses: actions/setup-java@v1 - with: - java-version: 15 - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} + - name: Npm build, test and lint + run: | + npm install + npm run build + npm run lint + npm test - - name: run action - uses: ./ - with: - api-level: ${{ github.event.inputs.api-level }} - target: ${{ github.event.inputs.target }} - arch: ${{ github.event.inputs.arch }} - profile: Galaxy Nexus - emulator-options: ${{ github.event.inputs.emulator-options }} - emulator-build: ${{ github.event.inputs.emulator-build }} - channel: ${{ github.event.inputs.channel }} - working-directory: ./test-fixture/ - script: ${{ github.event.inputs.script }} + - name: Java 15 + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 15 + + - name: Gradle cache + uses: gradle/gradle-build-action@v2 + + - name: Run tests + uses: ./ + with: + api-level: ${{ github.event.inputs.api-level }} + target: ${{ github.event.inputs.target }} + arch: ${{ github.event.inputs.arch }} + profile: Galaxy Nexus + emulator-options: ${{ github.event.inputs.emulator-options }} + emulator-build: ${{ github.event.inputs.emulator-build }} + channel: ${{ github.event.inputs.channel }} + working-directory: ./test-fixture/ + script: ${{ github.event.inputs.script }} diff --git a/.gitignore b/.gitignore index 214c07925..54269e46b 100644 --- a/.gitignore +++ b/.gitignore @@ -101,3 +101,6 @@ typings/ # IntelliJ IDEA .idea *.iml +local.properties +build +.gradle diff --git a/README.md b/README.md index e7a4ece9b..97d61f287 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,10 @@ jobs: test: runs-on: macos-latest steps: - - name: checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 - - name: run tests + - name: Run tests uses: reactivecircus/android-emulator-runner@v2 with: api-level: 29 @@ -52,10 +52,10 @@ jobs: api-level: [21, 23, 29] target: [default, google_apis] steps: - - name: checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 - - name: run tests + - name: Run tests uses: reactivecircus/android-emulator-runner@v2 with: api-level: ${{ matrix.api-level }} @@ -72,10 +72,10 @@ jobs: test: runs-on: macos-latest steps: - - name: checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 - - name: run tests + - name: Run tests uses: reactivecircus/android-emulator-runner@v2 with: api-level: 29 @@ -87,7 +87,7 @@ jobs: We can significantly reduce emulator startup time by setting up AVD snapshot caching: 1. add a `gradle/gradle-build-action@v2` step for caching Gradle, more details see [#229](https://github.com/ReactiveCircus/android-emulator-runner/issues/229) -2. add an `actions/cache@v2` step for caching the `avd` +2. add an `actions/cache@v3` step for caching the `avd` 3. add a `reactivecircus/android-emulator-runner@v2` step to generate a clean snapshot - specify `emulator-options` without `no-snapshot` 4. add another `reactivecircus/android-emulator-runner@v2` step to run your tests using existing AVD / snapshot - specify `emulator-options` with `no-snapshot-save` @@ -99,14 +99,14 @@ jobs: matrix: api-level: [21, 23, 29] steps: - - name: checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 - name: Gradle cache uses: gradle/gradle-build-action@v2 - name: AVD cache - uses: actions/cache@v2 + uses: actions/cache@v3 id: avd-cache with: path: | @@ -114,7 +114,7 @@ jobs: ~/.android/adb* key: avd-${{ matrix.api-level }} - - name: create AVD and generate snapshot for caching + - name: Create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@v2 with: @@ -124,7 +124,7 @@ jobs: disable-animations: false script: echo "Generated AVD snapshot for caching." - - name: run tests + - name: Run tests uses: reactivecircus/android-emulator-runner@v2 with: api-level: ${{ matrix.api-level }} diff --git a/test-fixture/app/.gitignore b/test-fixture/app/.gitignore deleted file mode 100644 index 796b96d1c..000000000 --- a/test-fixture/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/test-fixture/local.properties b/test-fixture/local.properties deleted file mode 100644 index 6a0cfbebb..000000000 --- a/test-fixture/local.properties +++ /dev/null @@ -1,10 +0,0 @@ -## This file is automatically generated by Android Studio. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file should *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. -# -# Location of the SDK. This is only used by Gradle. -# For customization when using a Version Control System, please read the -# header note. -sdk.dir=/Users/Yang/Library/Android/sdk \ No newline at end of file