diff --git a/.github/actions/android-setup-environment/action.yml b/.github/actions/android-setup-environment/action.yml index ad610947..787474ab 100644 --- a/.github/actions/android-setup-environment/action.yml +++ b/.github/actions/android-setup-environment/action.yml @@ -1,5 +1,5 @@ name: Set up Android environment -description: Sets up Java, Gradle and Ruby and other preconditions for CI runs at Futured Android workflows. +description: Sets up Java, Gradle, Ruby, optionally the Android SDK and Kotlin/Native dependency cache, and other preconditions for CI runs at Futured Android workflows. inputs: # Java @@ -32,6 +32,16 @@ inputs: gradle_cache_encryption_key: description: "Configuration cache encryption key. Leave empty if you don't need cache." required: false + # Android SDK + android_sdk_packages: + description: "sdkmanager packages to install, eg. 'platforms;android-36 build-tools;36.0.0 platform-tools'. Leave empty to skip the SDK setup (runner image already has the SDK)." + required: false + default: '' + # Kotlin/Native + kotlin_native_cache: + description: "Whether to cache ~/.konan/dependencies (LLVM, libffi) between runs. Useful for KMP projects on fresh macOS runners." + required: false + default: 'false' runs: using: "composite" @@ -47,8 +57,23 @@ runs: with: java-version: ${{ inputs.java_version }} distribution: ${{ inputs.java_distribution }} + - name: Setup Android SDK + if: ${{ inputs.android_sdk_packages != '' }} + uses: android-actions/setup-android@v3 + with: + packages: ${{ inputs.android_sdk_packages }} + accept-android-sdk-licenses: true + log-accepted-android-sdk-licenses: false - name: Setup Gradle if: ${{ inputs.gradle == 'true' }} uses: gradle/actions/setup-gradle@v5 with: cache-encryption-key: ${{ inputs.gradle_cache_encryption_key }} + - name: Cache Kotlin/Native dependencies + if: ${{ inputs.kotlin_native_cache == 'true' }} + uses: actions/cache@v4 + with: + path: ~/.konan/dependencies + key: konan-deps-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/libs.versions.toml') }} + restore-keys: | + konan-deps-${{ runner.os }}-${{ runner.arch }}- diff --git a/.github/workflows/android-cloud-check.yml b/.github/workflows/android-cloud-check.yml index 17a5341e..8a76e19a 100644 --- a/.github/workflows/android-cloud-check.yml +++ b/.github/workflows/android-cloud-check.yml @@ -39,6 +39,21 @@ on: required: false type: string default: "" + RUNS_ON: + description: "Runner label for the job, for example `ubuntu-latest` (default) or `self-hosted` to run the checks on the mac runners" + required: false + type: string + default: ubuntu-latest + ANDROID_SDK_PACKAGES: + description: "When set, installs the Android SDK in the job (android-actions/setup-android) with these sdkmanager packages, for runners whose image has no SDK, for example `platforms;android-36 build-tools;36.0.0 platform-tools`" + required: false + type: string + default: "" + KOTLIN_NATIVE_CACHE: + description: "Caches ~/.konan/dependencies (LLVM, libffi) between runs; for KMP projects checked on macOS, where the Kotlin/Native toolchain downloads them on every fresh runner" + required: false + type: boolean + default: false secrets: GRADLE_CACHE_ENCRYPTION_KEY: @@ -51,7 +66,7 @@ on: jobs: test: name: Lint & Tests - runs-on: ubuntu-latest + runs-on: ${{ inputs.RUNS_ON }} timeout-minutes: ${{ inputs.TIMEOUT_MINUTES }} env: GRADLE_OPTS: ${{ inputs.GRADLE_OPTS }} @@ -66,6 +81,8 @@ jobs: java_version: ${{ inputs.JAVA_VERSION }} java_distribution: ${{ inputs.JAVA_DISTRIBUTION }} gradle_cache_encryption_key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} + android_sdk_packages: ${{ inputs.ANDROID_SDK_PACKAGES }} + kotlin_native_cache: ${{ inputs.KOTLIN_NATIVE_CACHE }} - name: Run checks uses: futuredapp/.github/.github/actions/android-check@2.4.6 with: