mirror of
https://github.com/LSPosed/LSPlant.git
synced 2025-05-04 20:42:02 +08:00
Use AGP to do some unit tests and add ccache (#25)
This commit is contained in:
parent
0864159fc4
commit
cf9b95f6d6
121
.github/workflows/build.yml
vendored
121
.github/workflows/build.yml
vendored
@ -32,10 +32,19 @@ jobs:
|
|||||||
~/.gradle/caches
|
~/.gradle/caches
|
||||||
~/.gradle/wrapper
|
~/.gradle/wrapper
|
||||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
|
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
|
||||||
|
- name: ccache
|
||||||
|
uses: hendrikmuhs/ccache-action@v1.2
|
||||||
|
with:
|
||||||
|
key: ${{ runner.os }}-${{ github.sha }}
|
||||||
|
restore-keys: ${{ runner.os }}
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: |
|
run: |
|
||||||
|
ccache -o cache_dir=${{ github.workspace }}/.ccache
|
||||||
|
ccache -o hash_dir=false
|
||||||
|
ccache -o compiler_check='%compiler% -dumpmachine; %compiler% -dumpversion'
|
||||||
|
ccache -p
|
||||||
echo 'android.native.buildOutput=verbose' >> gradle.properties
|
echo 'android.native.buildOutput=verbose' >> gradle.properties
|
||||||
./gradlew :lsplant:publishToMavenLocal
|
./gradlew :lsplant:publishToMavenLocal :lsplant:prefabDebugPackage
|
||||||
env:
|
env:
|
||||||
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.maven_pgp_signingKey }}
|
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.maven_pgp_signingKey }}
|
||||||
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.maven_pgp_signingPassword }}
|
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.maven_pgp_signingPassword }}
|
||||||
@ -45,6 +54,51 @@ jobs:
|
|||||||
name: ${{ matrix.os }}-library
|
name: ${{ matrix.os }}-library
|
||||||
path: ~/.m2
|
path: ~/.m2
|
||||||
|
|
||||||
|
agp-test:
|
||||||
|
needs: build
|
||||||
|
name: Test using AGP
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
- name: Gradle cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
|
||||||
|
restore-keys: gradle-${{ runner.os }}-
|
||||||
|
- name: ccache
|
||||||
|
uses: hendrikmuhs/ccache-action@v1.2
|
||||||
|
with:
|
||||||
|
key: ${{ runner.os }}-${{ github.sha }}
|
||||||
|
restore-keys: ${{ runner.os }}
|
||||||
|
save: false
|
||||||
|
- name: Test with Gradle
|
||||||
|
run: |
|
||||||
|
ccache -o cache_dir=${{ github.workspace }}/.ccache
|
||||||
|
ccache -o hash_dir=false
|
||||||
|
ccache -o compiler_check='%compiler% -dumpmachine; %compiler% -dumpversion'
|
||||||
|
echo -e "84831b9409646a918e30573bab4c9c91346d8abd" > $ANDROID_SDK_ROOT/licenses/android-sdk-preview-license
|
||||||
|
echo 'android.testoptions.manageddevices.emulator.gpu=swiftshader_indirect' >> gradle.properties
|
||||||
|
echo 'android.native.buildOutput=verbose' >> gradle.properties
|
||||||
|
echo 'android.sdk.channel=3' >> gradle.properties
|
||||||
|
./gradlew :test:allDevicesDebugAndroidTest
|
||||||
|
rm -v test/build/outputs/androidTest-results/managedDevice/*/testlog/adb.additional_test_output*
|
||||||
|
- name: Upload outputs
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: test-outputs
|
||||||
|
path: test/build/outputs
|
||||||
|
|
||||||
test:
|
test:
|
||||||
needs: build
|
needs: build
|
||||||
name: Test on API ${{ matrix.api-level }} ${{ matrix.arch }}
|
name: Test on API ${{ matrix.api-level }} ${{ matrix.arch }}
|
||||||
@ -89,42 +143,9 @@ jobs:
|
|||||||
- api-level: 26
|
- api-level: 26
|
||||||
target: default
|
target: default
|
||||||
arch: x86
|
arch: x86
|
||||||
- api-level: 27
|
|
||||||
target: default
|
|
||||||
arch: x86_64
|
|
||||||
- api-level: 27
|
|
||||||
target: default
|
|
||||||
arch: x86
|
|
||||||
- api-level: 28
|
|
||||||
target: default
|
|
||||||
arch: x86_64
|
|
||||||
- api-level: 28
|
|
||||||
target: default
|
|
||||||
arch: x86
|
|
||||||
- api-level: 29
|
|
||||||
target: default
|
|
||||||
arch: x86_64
|
|
||||||
- api-level: 29
|
|
||||||
target: default
|
|
||||||
arch: x86
|
|
||||||
- api-level: 30
|
|
||||||
target: default
|
|
||||||
arch: x86_64
|
|
||||||
- api-level: 30
|
|
||||||
target: google_apis
|
|
||||||
arch: x86
|
|
||||||
- api-level: 31
|
|
||||||
target: default
|
|
||||||
arch: x86_64
|
|
||||||
- api-level: 31
|
- api-level: 31
|
||||||
target: android-tv
|
target: android-tv
|
||||||
arch: x86
|
arch: x86
|
||||||
- api-level: 32
|
|
||||||
target: google_apis
|
|
||||||
arch: x86_64
|
|
||||||
- api-level: 33
|
|
||||||
target: google_apis
|
|
||||||
arch: x86_64
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
@ -134,14 +155,6 @@ jobs:
|
|||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
- name: AVD cache
|
|
||||||
uses: actions/cache@v2
|
|
||||||
id: avd-cache
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.android/avd/*
|
|
||||||
~/.android/adb*
|
|
||||||
key: avd-${{ matrix.api-level }}-${{ matrix.arch }}-${{ matrix.target }}
|
|
||||||
- name: Gradle cache
|
- name: Gradle cache
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
@ -150,26 +163,24 @@ jobs:
|
|||||||
~/.gradle/wrapper
|
~/.gradle/wrapper
|
||||||
key: gradle-${{ runner.os }}-${{ matrix.api-level }}-${{ matrix.arch }}-${{ matrix.target }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
|
key: gradle-${{ runner.os }}-${{ matrix.api-level }}-${{ matrix.arch }}-${{ matrix.target }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
|
||||||
restore-keys: gradle-${{ runner.os }}-
|
restore-keys: gradle-${{ runner.os }}-
|
||||||
- name: create AVD and generate snapshot for caching
|
- name: ccache
|
||||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
uses: hendrikmuhs/ccache-action@v1.2
|
||||||
uses: reactivecircus/android-emulator-runner@release/v2
|
|
||||||
with:
|
with:
|
||||||
api-level: ${{ matrix.api-level }}
|
key: ${{ runner.os }}-${{ github.sha }}
|
||||||
arch: ${{ matrix.arch }}
|
restore-keys: ${{ runner.os }}
|
||||||
target: ${{ matrix.target }}
|
save: false
|
||||||
script: echo "Generated AVD snapshot for caching."
|
|
||||||
force-avd-creation: false
|
|
||||||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
|
||||||
disable-animations: false
|
|
||||||
avd-name: ${{ matrix.api-level }}_${{ matrix.arch }}
|
|
||||||
- name: run tests
|
- name: run tests
|
||||||
uses: reactivecircus/android-emulator-runner@v2
|
uses: reactivecircus/android-emulator-runner@v2
|
||||||
with:
|
with:
|
||||||
api-level: ${{ matrix.api-level }}
|
api-level: ${{ matrix.api-level }}
|
||||||
arch: ${{ matrix.arch }}
|
arch: ${{ matrix.arch }}
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
script: ./gradlew :lsplant:prefabDebugConfigurePackage; ./gradlew :test:connectedCheck
|
script: |
|
||||||
force-avd-creation: false
|
ccache -o cache_dir=${{ github.workspace }}/.ccache
|
||||||
|
ccache -o hash_dir=false
|
||||||
|
ccache -o compiler_check='%compiler% -dumpmachine; %compiler% -dumpversion'
|
||||||
|
echo 'android.native.buildOutput=verbose' >> gradle.properties
|
||||||
|
./gradlew :test:connectedCheck
|
||||||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||||
disable-animations: true
|
disable-animations: true
|
||||||
avd-name: ${{ matrix.api-level }}_${{ matrix.arch }}
|
avd-name: ${{ matrix.api-level }}_${{ matrix.arch }}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import java.nio.file.Paths
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
id("com.android.library")
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
@ -11,6 +13,16 @@ val androidCompileSdkVersion: Int by rootProject.extra
|
|||||||
val androidNdkVersion: String by rootProject.extra
|
val androidNdkVersion: String by rootProject.extra
|
||||||
val androidCmakeVersion: String by rootProject.extra
|
val androidCmakeVersion: String by rootProject.extra
|
||||||
|
|
||||||
|
fun findInPath(executable: String): String? {
|
||||||
|
val pathEnv = System.getenv("PATH")
|
||||||
|
return pathEnv.split(File.pathSeparator).map { folder ->
|
||||||
|
Paths.get("${folder}${File.separator}${executable}${if (org.gradle.internal.os.OperatingSystem.current().isWindows) ".exe" else ""}")
|
||||||
|
.toFile()
|
||||||
|
}.firstOrNull { path ->
|
||||||
|
path.exists()
|
||||||
|
}?.absolutePath
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk = androidCompileSdkVersion
|
compileSdk = androidCompileSdkVersion
|
||||||
ndkVersion = androidNdkVersion
|
ndkVersion = androidNdkVersion
|
||||||
@ -74,6 +86,10 @@ android {
|
|||||||
"-DCMAKE_C_FLAGS_RELEASE=$configFlags",
|
"-DCMAKE_C_FLAGS_RELEASE=$configFlags",
|
||||||
"-DDEBUG_SYMBOLS_PATH=${project.buildDir.absolutePath}/symbols/$name",
|
"-DDEBUG_SYMBOLS_PATH=${project.buildDir.absolutePath}/symbols/$name",
|
||||||
)
|
)
|
||||||
|
findInPath("ccache")?.let {
|
||||||
|
println("Using ccache $it")
|
||||||
|
arguments += "-DANDROID_CCACHE=$it"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import com.android.build.api.dsl.ManagedVirtualDevice
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
}
|
}
|
||||||
@ -10,6 +12,7 @@ val androidNdkVersion: String by rootProject.extra
|
|||||||
val androidCmakeVersion: String by rootProject.extra
|
val androidCmakeVersion: String by rootProject.extra
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
namespace = "org.lsposed.lsplant.test"
|
||||||
compileSdk = androidCompileSdkVersion
|
compileSdk = androidCompileSdkVersion
|
||||||
ndkVersion = androidNdkVersion
|
ndkVersion = androidNdkVersion
|
||||||
buildToolsVersion = androidBuildToolsVersion
|
buildToolsVersion = androidBuildToolsVersion
|
||||||
@ -44,7 +47,44 @@ android {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
}
|
}
|
||||||
namespace = "org.lsposed.lsplant"
|
|
||||||
|
testOptions {
|
||||||
|
managedDevices {
|
||||||
|
devices {
|
||||||
|
fun createDevice(api: Int, is64: Boolean, target: String = "default") = create<ManagedVirtualDevice>("""avd-$api-${if(is64) "x86_64" else "x86"}-$target""") {
|
||||||
|
device = "Pixel 2"
|
||||||
|
apiLevel = api
|
||||||
|
systemImageSource = target
|
||||||
|
require64Bit = is64
|
||||||
|
}
|
||||||
|
|
||||||
|
// createDevice(21, false)
|
||||||
|
// createDevice(21, true)
|
||||||
|
// createDevice(22, false)
|
||||||
|
// createDevice(22, true)
|
||||||
|
// createDevice(23, false)
|
||||||
|
// createDevice(23, true)
|
||||||
|
// createDevice(24, false)
|
||||||
|
// createDevice(24, true)
|
||||||
|
// createDevice(25, false)
|
||||||
|
// createDevice(25, true)
|
||||||
|
// createDevice(26, false)
|
||||||
|
// createDevice(26, true)
|
||||||
|
createDevice(27, false)
|
||||||
|
createDevice(27, true)
|
||||||
|
createDevice(28, false)
|
||||||
|
createDevice(28, true)
|
||||||
|
createDevice(29, false)
|
||||||
|
createDevice(29, true)
|
||||||
|
createDevice(30, false, "aosp_atd")
|
||||||
|
createDevice(30, true)
|
||||||
|
// createDevice(31, false, "android-tv")
|
||||||
|
createDevice(31, true, "aosp_atd")
|
||||||
|
createDevice(32, true, "google_apis")
|
||||||
|
createDevice(33, true, "google_apis")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user