Repository navigation
198 lines (196 loc) · 8.64 KB
/
Copy pathci.yml
File metadata and controls
198 lines (196 loc) · 8.64 KB
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: CI
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on: workflow_dispatch
jobs:
build-debug:
name: Build Debug APKs
runs-on: ubuntu-26.04
# Every GitHub job in this workflow needs a ceiling: run 495's test job hung for
# 4.8 hours with nothing to stop it, because a hung step is not the same as a slow
# one and the runner only reaps the process tree when the job ends.
timeout-minutes: 30
env:
GRADLE_OPTS: -Dorg.gradle.warning.mode=all
MAGISK_IS_CI_BUILD: true
HAS_RELEASE_SIGNING: ${{ secrets.RELEASE_KEYSTORE != '' && secrets.STORE_PASSWORD != '' && secrets.KEY_ALIAS != '' && secrets.KEY_PASSWORD != '' }}
steps:
- name: Configure GitLab submodule credentials
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
if [[ -z "$GITLAB_TOKEN" ]]; then
echo "::error::GITLAB_TOKEN secret is not set; cannot clone gitlab.com submodules"
exit 1
fi
git config --global http.https://gitlab.com/.extraheader "AUTHORIZATION: basic $(printf 'oauth2:%s' "$GITLAB_TOKEN" | base64 -w0)"
- uses: actions/checkout@v7
with:
submodules: recursive
fetch-depth: 0
- uses: ./.github/actions/resolve-ci-toolkit
with:
ref: b2d1d58abfca674a60277ba302d06eae45da3ce4
- name: Setup Android CI
uses: ./.magisk-ci-toolkit/.github/actions/setup-android-ci
with:
checkout: 'false'
# The toolkit defaults to 26, but this project targets 27 (see
# gradle/libs.versions.toml: java / javaBytecode). Lint refuses to run on
# a JVM older than the target, and GitLab never sees that because its
# runner image already ships 27 -- only a GitHub-hosted runner does.
java-version: '27'
- name: Require release signing
if: env.HAS_RELEASE_SIGNING != 'true'
run: |
echo "::error::Release signing is unavailable (RELEASE_KEYSTORE / STORE_PASSWORD / KEY_ALIAS / KEY_PASSWORD). Every build and upload step below is gated on it, so without this the job would report success while producing no artifact at all."
exit 1
- name: Decode Keystore
if: env.HAS_RELEASE_SIGNING == 'true'
run: echo "${{ secrets.RELEASE_KEYSTORE }}" | base64 --decode > release.jks
- name: Build signed debug APKs
if: env.HAS_RELEASE_SIGNING == 'true'
uses: ./.magisk-ci-toolkit/.github/actions/run-gradle-with-retry
with:
arguments: >
--warning-mode all
:app:assembleGithubDebug
-PbuildSplits
-PminifyDebug
env:
KEYSTORE_FILE: release.jks
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Write build summary
if: always() && env.HAS_RELEASE_SIGNING == 'true'
run: |
{
echo "## Debug APK summary"
echo ""
echo "| File | Size |"
echo "| --- | --- |"
while IFS= read -r apk; do
if [ ! -f "$apk" ]; then
continue
fi
size=$(du -h "$apk" | awk '{print $1}')
name=$(basename "$apk")
echo "| $name | $size |"
done < <(find app/build/outputs/apk -path '*/debug/*.apk' | sort)
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload Debug APK (arm64-v8a)
if: always() && env.HAS_RELEASE_SIGNING == 'true'
uses: actions/upload-artifact@v7
with:
name: XposedSmsCode-debug-apks-arm64-v8a
path: app/build/outputs/apk/**/debug/arm64-v8a_*.apk
if-no-files-found: error
- name: Upload Debug APK (armeabi-v7a)
if: always() && env.HAS_RELEASE_SIGNING == 'true'
uses: actions/upload-artifact@v7
with:
name: XposedSmsCode-debug-apks-armeabi-v7a
path: app/build/outputs/apk/**/debug/armeabi-v7a_*.apk
if-no-files-found: error
- name: Upload Debug APK (x86_64)
if: always() && env.HAS_RELEASE_SIGNING == 'true'
uses: actions/upload-artifact@v7
with:
name: XposedSmsCode-debug-apks-x86_64
path: app/build/outputs/apk/**/debug/x86_64_*.apk
if-no-files-found: error
- name: Upload Debug APK (x86)
if: always() && env.HAS_RELEASE_SIGNING == 'true'
uses: actions/upload-artifact@v7
with:
name: XposedSmsCode-debug-apks-x86
path: app/build/outputs/apk/**/debug/x86_[!6]*.apk
if-no-files-found: error
- name: Upload Debug APK (universal)
if: always() && env.HAS_RELEASE_SIGNING == 'true'
uses: actions/upload-artifact@v7
with:
name: XposedSmsCode-debug-apks-universal
path: app/build/outputs/apk/**/debug/universal_*.apk
if-no-files-found: error
test:
name: Post-build Tests
needs: [build-debug]
if: always() && needs.build-debug.result == 'success'
runs-on: ubuntu-26.04
timeout-minutes: 40
# Standing policy, same as MiPushFramework: test results feed code changes afterwards
# and never gate the build or the publish path. Being the last job is not the same as
# being unable to block anything, so the flag states it. A failure still shows here as
# a red job with a warning; the run stays green.
continue-on-error: true
env:
GRADLE_OPTS: -Dorg.gradle.warning.mode=all
steps:
- name: Configure GitLab submodule credentials
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
if [[ -z "$GITLAB_TOKEN" ]]; then
echo "::error::GITLAB_TOKEN secret is not set; cannot clone gitlab.com submodules"
exit 1
fi
git config --global http.https://gitlab.com/.extraheader "AUTHORIZATION: basic $(printf 'oauth2:%s' "$GITLAB_TOKEN" | base64 -w0)"
- uses: actions/checkout@v7
with:
submodules: recursive
fetch-depth: 0
- uses: ./.github/actions/resolve-ci-toolkit
with:
ref: b2d1d58abfca674a60277ba302d06eae45da3ce4
- name: Setup Android CI
uses: ./.magisk-ci-toolkit/.github/actions/setup-android-ci
with:
checkout: 'false'
# The toolkit defaults to 26, but this project targets 27 (see
# gradle/libs.versions.toml: java / javaBytecode). Lint refuses to run on
# a JVM older than the target, and GitLab never sees that because its
# runner image already ships 27 -- only a GitHub-hosted runner does.
java-version: '27'
- name: Run Android tests
shell: bash
run: |
set -euo pipefail
# Command substitution, not `mapfile < <(...)`: the process-substitution form
# drops the selector's exit status, so a dead selector (toolkit unresolved,
# config unreadable) leaves an empty array and the step's own guard below
# reports "no tasks selected" -- a green job that ran nothing at all.
if ! selected="$(
python3 "${MAGISK_CI_TOOLKIT_DIR:-.magisk-ci-toolkit}/ci/select_gradle_tasks.py" \
--root "$PWD" \
--toolkit "${MAGISK_CI_TOOLKIT_DIR:-.magisk-ci-toolkit}" \
--config scripts/config/android-test-tasks.json
)"; then
echo "::error::the test task selector failed; refusing to report a passing job with no tests"
exit 1
fi
mapfile -t selected_tasks <<< "$selected"
if [[ ${#selected_tasks[@]} -eq 0 || -z "${selected_tasks[0]}" ]]; then
echo "No Android test tasks selected for this change."
exit 0
fi
printf 'selected tasks: %s\n' "${selected_tasks[*]}"
# In-shell budget: a stall must end as a step failure the job-level
# continue-on-error can swallow, not as a cancelled job, which it cannot absorb.
rc=0
timeout --kill-after=60s 25m bash "${MAGISK_CI_TOOLKIT_DIR:-.magisk-ci-toolkit}/gradle/run_gradle_with_retry.sh" \
--warning-mode all "${selected_tasks[@]}" -PenableKover=true || rc=$?
if [ "$rc" -eq 124 ] || [ "$rc" -eq 137 ]; then
echo "::warning::tests exceeded their 25m budget (exit $rc). The run stays green by policy, but this is not a passing test run: find the task that stopped producing output."
fi
exit "$rc"
- name: Upload Kover Report
if: always()
uses: actions/upload-artifact@v7
with:
name: kover-report
path: app/build/reports/kover/**