-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
164 lines (145 loc) · 5.36 KB
/
Copy pathandroid-compile-check.yml
File metadata and controls
164 lines (145 loc) · 5.36 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
name: Android Compile Check
# Compiles all app Kotlin (by building the debug APK) on PRs that change Kotlin
# source, to catch Kotlin compile breaks before they reach main. The full signed
# release build (build-android.yml) is workflow_call-only and never runs on PRs,
# so without this gate a Kotlin break (e.g. the bare success() call in #8754)
# could merge undetected.
#
# Scope: the PR trigger runs only on Kotlin (*.kt) changes. It intentionally
# does NOT run on Go/gomobile-AAR or Flutter/dep changes — a Go change that
# breaks the AAR<->Kotlin interface would surface in build-android.yml /
# release, not here. workflow_dispatch exists only for benchmarking/debugging.
#
# Debug build only: no keystore/APP_ENV secrets, no AAB, no artifact upload.
on:
workflow_dispatch:
pull_request:
paths:
- "**/*.kt"
# keep the self-trigger so edits to this workflow re-run it
- ".github/workflows/android-compile-check.yml"
concurrency:
group: android-compile-check-${{ github.ref }}
cancel-in-progress: true
jobs:
compile-check:
permissions:
contents: "read"
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- name: Cache Flutter dependencies
uses: actions/cache@v4
timeout-minutes: 5
continue-on-error: true
with:
path: |
~/.pub-cache
key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-flutter-
- name: Set up Java 17 (Gradle cache)
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: "gradle"
cache-dependency-path: |
**/*.gradle*
**/gradle-wrapper.properties
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Free Linux runner disk
if: runner.os == 'Linux'
shell: bash
run: |
set -euxo pipefail
df -h
sdk_root="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-}}"
sdk_root="${sdk_root%/}"
if [[ -z "$sdk_root" || "$sdk_root" == "/" || "$sdk_root" != /* ]]; then
echo "Android SDK root is not set to a safe absolute path: '${sdk_root}'" >&2
exit 1
fi
# Keep the preinstalled Android platforms/build-tools/CMake/NDK; the
# shared Makefile defaults match the versions this job needs.
sudo rm -rf \
"$sdk_root/emulator" \
"$sdk_root/system-images" \
/opt/ghc \
/opt/hostedtoolcache/CodeQL \
/usr/local/.ghcup \
/usr/local/julia* \
/usr/local/share/boost \
/usr/share/dotnet \
/usr/share/swift
df -h
- name: Install Android SDK components
shell: bash
run: |
set -euxo pipefail
make install-android-sdk
make android-env >> "$GITHUB_ENV"
- name: Install Flutter
uses: subosito/flutter-action@v2.22.0
with:
channel: stable
flutter-version-file: .github/flutter-version.yaml
cache: true
- name: Set gomobile cache dir
shell: bash
run: |
echo "GOMOBILECACHE=$HOME/.cache/gomobile" >> "$GITHUB_ENV"
mkdir -p "$HOME/.cache/gomobile"
- name: Cache gomobile
uses: actions/cache@v4
timeout-minutes: 10
continue-on-error: true
with:
path: ~/.cache/gomobile
key: ${{ runner.os }}-gomobile-${{ hashFiles('**/go.mod', '**/go.sum') }}
restore-keys: |
${{ runner.os }}-gomobile-
- name: Cache Android AAR
id: android-aar-cache
uses: actions/cache@v4
timeout-minutes: 5
continue-on-error: true
with:
path: |
bin/android/liblantern.aar
android/app/libs/liblantern.aar
key: ${{ runner.os }}-android-aar-${{ hashFiles('go.mod', 'go.sum', 'Makefile', '**/*.go') }}
- name: Mark restored Android AAR fresh
if: steps.android-aar-cache.outputs.cache-hit == 'true'
run: |
test -s bin/android/liblantern.aar
test -s android/app/libs/liblantern.aar
touch bin/android/liblantern.aar android/app/libs/liblantern.aar
- name: Install dependencies (gomobile)
if: steps.android-aar-cache.outputs.cache-hit != 'true'
run: make install-android-deps
env:
GOMOBILECACHE: ${{ env.GOMOBILECACHE }}
- name: Flutter pub get + codegen
run: |
make pubget
make gen
# app.env is a declared pubspec asset, normally decoded from a secret by
# the release workflow. This compile-only gate doesn't run the app, so an
# empty placeholder is enough to satisfy asset bundling without the secret.
- name: Create placeholder app.env
run: touch app.env
# Uses the cached gomobile AAR when possible, then compiles the debug APK
# (all app Kotlin). A Kotlin compile error fails this step — the whole
# point of the gate.
- name: Build debug APK (compiles Kotlin)
run: make android-debug-ci
env:
GOMOBILECACHE: ${{ env.GOMOBILECACHE }}