-
Notifications
You must be signed in to change notification settings - Fork 1.3k
177 lines (176 loc) · 5.66 KB
/
check-build-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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