Skip to content

Commit

Permalink
ci: 重构CI配置,AVD测试改到linux机器
Browse files Browse the repository at this point in the history
更新了格式化代码的Android studio版本。
更新了AVD插件。经测试API 18虚拟机无法用AVD缓存,会卡住。
本身创建虚拟机并不是特别慢,去掉了AVD缓存。
  • Loading branch information
shifujun committed Nov 21, 2024
1 parent a2d6df4 commit 7650e36
Show file tree
Hide file tree
Showing 24 changed files with 210 additions and 522 deletions.
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

0 comments on commit 7650e36

Please sign in to comment.