Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复CI,将AVD自动化测试移到Linux机器上 #1352

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .commitlintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ rules:
#允许中文
subject-case: [ 0 ]
footer-max-line-length: [ 0 ]
body-max-line-length: [ 0 ]
helpUrl: https://www.conventionalcommits.org/zh-hans/v1.0.0/
8 changes: 8 additions & 0 deletions .github/actions/post-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: post-build
description: '清理构建环境'
runs:
using: "composite"
steps:
- name: stop gradle deamon for actions/cache
shell: bash
run: ./gradlew --stop
18 changes: 18 additions & 0 deletions .github/actions/pre-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: pre-build
description: '准备构建环境'
runs:
using: "composite"
steps:
- name: revert gradle distributionUrl in every gradle-wrapper.properties
shell: bash
run: git grep -l 'mirrors.tencent.com/gradle' -- gradle-wrapper.properties '**/gradle-wrapper.properties' | xargs sed -i 's/mirrors.tencent.com\/gradle/services.gradle.org\/distributions/g'
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: revert gradle wrapper mirror setting
shell: bash
run: echo "DISABLE_TENCENT_MAVEN_MIRROR=true" >> $GITHUB_ENV
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
177 changes: 177 additions & 0 deletions .github/workflows/check-build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: Check & Build & Test
on:
workflow_call:
push:
branches:
- master
pull_request:
branches: [ master ]

jobs:
check-commit-message:
name: 提交日志格式化检查
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v6
with:
configFile: ./.commitlintrc.yml
check-code-format:
name: 代码格式化检查
runs-on: ubuntu-latest
env:
AndroidStudioVersion: 2021.1.1.20
steps:
- name: checkout
uses: actions/checkout@v4
- name: Cache android-studio
id: cache-android-studio
uses: actions/cache@v4
with:
path: android-studio
key: ${{ runner.os }}-android-studio--${{ env.AndroidStudioVersion }}
- name: download android-studio
if: steps.cache-android-studio.outputs.cache-hit != 'true'
run: |
wget "https://redirector.gvt1.com/edgedl/android/studio/ide-zips/$AndroidStudioVersion/android-studio-$AndroidStudioVersion-linux.tar.gz"
tar -xvzf "android-studio-$AndroidStudioVersion-linux.tar.gz"
rm -rf "android-studio-$AndroidStudioVersion-linux.tar.gz"
- name: use android-studio format all files
run: ./android-studio/bin/format.sh -s .idea/codeStyles/Project.xml -r -m \*.java,\*.kt,\*.xml .
- name: show diff for files not formated
run: |
if ! git diff --quiet; then
git diff --exit-code
fi
build-sdk:
needs: [ check-commit-message, check-code-format ]
name: 构建SDK
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: pre-build
uses: ./.github/actions/pre-build
- name: buildSdk
run: ./gradlew buildSdk -S
- name: post-build
uses: ./.github/actions/post-build
build-sample-maven:
needs: [ check-commit-message, check-code-format ]
name: 构建maven依赖SDK的sample
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: pre-build
uses: ./.github/actions/pre-build
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- name: build sample/maven/host-project
working-directory: projects/sample/maven/host-project
run: ./gradlew assemble
- name: build sample/maven/manager-project
working-directory: projects/sample/maven/manager-project
run: ./gradlew assemble
- name: build sample/maven/plugin-project
working-directory: projects/sample/maven/plugin-project
run: ./gradlew assemble
- name: post-build
uses: ./.github/actions/post-build
build-all:
needs: build-sdk
name: 构建所有源码
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: pre-build
uses: ./.github/actions/pre-build
- name: buildSdk
run: ./gradlew build
- name: post-build
uses: ./.github/actions/post-build
test-agp-compatibility:
needs: build-sdk
name: AGP兼容性自动化测试
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: pre-build
uses: ./.github/actions/pre-build
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: JDK17环境下AGP测试
working-directory: projects/test/gradle-plugin-agp-compat-test
run: ./test_JDK17.sh
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- name: JDK11环境下AGP测试
working-directory: projects/test/gradle-plugin-agp-compat-test
run: ./test_JDK11.sh
- name: post-build
uses: ./.github/actions/post-build
test-sdk-jvm:
needs: build-sdk
name: 自动化测试-JVM部分
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: pre-build
uses: ./.github/actions/pre-build
- name: jvmTestSdk
run: ./gradlew jvmTestSdk -S
- name: post-build
uses: ./.github/actions/post-build
test-sdk-avd:
needs: build-sdk
name: 自动化测试-AVD部分
runs-on: ubuntu-latest
strategy:
matrix:
include:
- api-level: 16 #16是最低支持的API
arch: x86
target: default
- api-level: 28 #28是项目长期使用的测试API
arch: x86
target: default
- api-level: 34
arch: x86_64
target: google_apis
steps:
- name: checkout
uses: actions/checkout@v4
- name: pre-build
uses: ./.github/actions/pre-build
- name: Enable KVM
run: |
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 --name-match=kvm
- name: run AVD tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
profile: pixel_xl
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew androidTestSdk
- name: post-build
uses: ./.github/actions/post-build
31 changes: 0 additions & 31 deletions .github/workflows/pr-check-format-code.yml

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/pr-check-gradle-plugin.yml

This file was deleted.

Loading