mirror of
https://github.com/LSPosed/LSPlant.git
synced 2025-05-04 20:42:02 +08:00
add cuttlefish test (#133)
This commit is contained in:
parent
08b65e436f
commit
90d8d433d4
94
.github/cuttlefish.sh
vendored
Executable file
94
.github/cuttlefish.sh
vendored
Executable file
@ -0,0 +1,94 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
export PATH="$PATH:$ANDROID_HOME/platform-tools"
|
||||||
|
sdk="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
|
||||||
|
cvd_args="-daemon -enable_sandbox=false -memory_mb=8192 -report_anonymous_usage_stats=n"
|
||||||
|
|
||||||
|
print_title() {
|
||||||
|
echo -e "\n\033[44;39m${1}\033[0m\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_error() {
|
||||||
|
echo -e "\n\033[41;39m${1}\033[0m\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
print_error "! An error occurred"
|
||||||
|
run_cvd_bin stop_cvd || true
|
||||||
|
}
|
||||||
|
|
||||||
|
run_cvd_bin() {
|
||||||
|
local exe=$1
|
||||||
|
shift
|
||||||
|
HOME=$CF_HOME $CF_HOME/bin/$exe "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_env() {
|
||||||
|
curl -LO https://github.com/user-attachments/files/18728876/cuttlefish-base_1.2.0_amd64.zip
|
||||||
|
sudo dpkg -i ./cuttlefish-base_*_*64.zip || sudo apt-get install -f
|
||||||
|
rm cuttlefish-base_*_*64.zip
|
||||||
|
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
||||||
|
sudo udevadm control --reload-rules
|
||||||
|
sudo udevadm trigger
|
||||||
|
sudo usermod -aG kvm,cvdnetwork,render $USER
|
||||||
|
yes | "$sdk" --licenses > /dev/null
|
||||||
|
"$sdk" --channel=3 platform-tools
|
||||||
|
}
|
||||||
|
|
||||||
|
download_cf() {
|
||||||
|
local branch=$1
|
||||||
|
local device=$2
|
||||||
|
|
||||||
|
if [ -z $branch ]; then
|
||||||
|
branch='aosp-main'
|
||||||
|
fi
|
||||||
|
if [ -z $device ]; then
|
||||||
|
device='aosp_cf_x86_64_phone'
|
||||||
|
fi
|
||||||
|
local target="${device}-trunk_staging-userdebug"
|
||||||
|
|
||||||
|
local build_id=$(curl -sL https://ci.android.com/builds/branches/${branch}/status.json | \
|
||||||
|
jq -r ".targets[] | select(.name == \"$target\") | .last_known_good_build")
|
||||||
|
local sys_img_url="https://ci.android.com/builds/submitted/${build_id}/${target}/latest/raw/${device}-img-${build_id}.zip"
|
||||||
|
local host_pkg_url="https://ci.android.com/builds/submitted/${build_id}/${target}/latest/raw/cvd-host_package.tar.gz"
|
||||||
|
|
||||||
|
curl -L $sys_img_url -o aosp_cf_phone-img.zip
|
||||||
|
curl -LO $host_pkg_url
|
||||||
|
rm -rf $CF_HOME
|
||||||
|
mkdir -p $CF_HOME
|
||||||
|
tar xvf cvd-host_package.tar.gz -C $CF_HOME
|
||||||
|
unzip aosp_cf_phone-img.zip -d $CF_HOME
|
||||||
|
rm -f cvd-host_package.tar.gz aosp_cf_phone-img.zip
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
test_main() {
|
||||||
|
run_cvd_bin launch_cvd $cvd_args
|
||||||
|
adb wait-for-device
|
||||||
|
./gradlew connectedCheck
|
||||||
|
run_cvd_bin stop_cvd || true
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z $CF_HOME ]; then
|
||||||
|
print_error "! Environment variable CF_HOME is required"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
setup )
|
||||||
|
setup_env
|
||||||
|
;;
|
||||||
|
download )
|
||||||
|
download_cf $2 $3
|
||||||
|
;;
|
||||||
|
test )
|
||||||
|
trap cleanup EXIT
|
||||||
|
export -f run_cvd_bin
|
||||||
|
test_main
|
||||||
|
trap - EXIT
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
66
.github/workflows/build.yml
vendored
66
.github/workflows/build.yml
vendored
@ -24,15 +24,15 @@ jobs:
|
|||||||
submodules: 'recursive'
|
submodules: 'recursive'
|
||||||
ssh-key: ${{ secrets.SSH_KEY }}
|
ssh-key: ${{ secrets.SSH_KEY }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 21
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: '17'
|
java-version: '21'
|
||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
- uses: seanmiddleditch/gha-setup-ninja@master
|
- uses: seanmiddleditch/gha-setup-ninja@master
|
||||||
with:
|
with:
|
||||||
version: 1.12.0
|
version: 1.12.1
|
||||||
- name: ccache
|
- name: ccache
|
||||||
uses: hendrikmuhs/ccache-action@v1
|
uses: hendrikmuhs/ccache-action@v1
|
||||||
with:
|
with:
|
||||||
@ -58,6 +58,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: ${{ matrix.os }}-library
|
name: ${{ matrix.os }}-library
|
||||||
path: ~/.m2
|
path: ~/.m2
|
||||||
|
include-hidden-files: true
|
||||||
|
|
||||||
test:
|
test:
|
||||||
needs: build
|
needs: build
|
||||||
@ -157,15 +158,15 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
submodules: 'recursive'
|
submodules: 'recursive'
|
||||||
ssh-key: ${{ secrets.SSH_KEY }}
|
ssh-key: ${{ secrets.SSH_KEY }}
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 21
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: '17'
|
java-version: '21'
|
||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
- uses: seanmiddleditch/gha-setup-ninja@master
|
- uses: seanmiddleditch/gha-setup-ninja@master
|
||||||
with:
|
with:
|
||||||
version: 1.12.0
|
version: 1.12.1
|
||||||
- name: ccache
|
- name: ccache
|
||||||
uses: hendrikmuhs/ccache-action@v1
|
uses: hendrikmuhs/ccache-action@v1
|
||||||
with:
|
with:
|
||||||
@ -200,3 +201,56 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
test/build/outputs
|
test/build/outputs
|
||||||
!test/build/outputs/apk
|
!test/build/outputs/apk
|
||||||
|
|
||||||
|
cf-test:
|
||||||
|
name: Test ${{ matrix.device }}
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
env:
|
||||||
|
CF_HOME: /home/runner/aosp_cf_phone
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- branch: "aosp-main"
|
||||||
|
device: "aosp_cf_x86_64_phone"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
ssh-key: ${{ secrets.SSH_KEY }}
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: '21'
|
||||||
|
cache: 'gradle'
|
||||||
|
- name: ccache
|
||||||
|
uses: hendrikmuhs/ccache-action@v1
|
||||||
|
with:
|
||||||
|
key: ${{ runner.os }}-${{ github.sha }}
|
||||||
|
restore-keys: ${{ runner.os }}
|
||||||
|
save: false
|
||||||
|
- name: Setup Cuttlefish environment
|
||||||
|
run: |
|
||||||
|
.github/cuttlefish.sh setup
|
||||||
|
.github/cuttlefish.sh download ${{ matrix.branch }} ${{ matrix.device }}
|
||||||
|
curl -LO https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip
|
||||||
|
unzip ninja-linux.zip -d $ANDROID_HOME/platform-tools
|
||||||
|
chmod +x $ANDROID_HOME/platform-tools/ninja
|
||||||
|
rm -rf $ANDROID_HOME/cmake
|
||||||
|
ccache -o cache_dir=${{ github.workspace }}/.ccache
|
||||||
|
ccache -o hash_dir=false
|
||||||
|
ccache -o compiler_check='%compiler% -dumpmachine; %compiler% -dumpversion'
|
||||||
|
- name: Run Cuttlefish test
|
||||||
|
timeout-minutes: 10
|
||||||
|
run: su $USER -c '.github/cuttlefish.sh test'
|
||||||
|
- name: Upload logs on error
|
||||||
|
if: ${{ failure() }}
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: "cvd-logs-${{ matrix.device }}"
|
||||||
|
path: |
|
||||||
|
/home/runner/aosp_cf_phone/cuttlefish/instances/cvd-1/logs
|
||||||
|
/home/runner/aosp_cf_phone/cuttlefish/instances/cvd-1/cuttlefish_config.json
|
||||||
|
Loading…
x
Reference in New Issue
Block a user