-
Notifications
You must be signed in to change notification settings - Fork 26
195 lines (173 loc) · 6.73 KB
/
build-quick.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Build quick (each platform)
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
pull_request:
branches:
- "**"
push:
branches:
- main
env:
DEBUG: 1
ANDROID_NDK_VERSION: "27.0.12077973"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 80
steps:
- name: Liberate disk space (Ubuntu)
uses: jlumbroso/free-disk-space@main
if: contains(matrix.os, 'ubuntu')
with:
tool-cache: false
android: false
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: false
- uses: actions/checkout@v4
- name: Enable KVM group perms (Ubuntu)
if: contains(matrix.os, 'ubuntu')
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: Fetch submodules
run: git submodule update --init
- name: Install/Set NDK version (Unix)
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
run: |
export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin"
./.github/scripts/install_ndk.sh ${ANDROID_NDK_VERSION}
export ANDROID_NDK_LATEST_HOME="${ANDROID_SDK_ROOT}/ndk/${ANDROID_NDK_VERSION}"
echo "ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME" >> $GITHUB_ENV
echo "ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME" >> $GITHUB_ENV
- name: Install/Set NDK version (Windows)
if: contains(matrix.os, 'windows')
run: |
$env:PATH = "$env:PATH;$env:ANDROID_HOME\cmdline-tools\latest\bin"
./.github/scripts/install_ndk.bat $env:ANDROID_NDK_VERSION
$env:ANDROID_NDK_LATEST_HOME = "$env:ANDROID_SDK_ROOT\ndk\$env:ANDROID_NDK_VERSION"
Add-Content -Path $env:GITHUB_ENV -Value ANDROID_NDK_HOME=$env:ANDROID_NDK_LATEST_HOME
Add-Content -Path $env:GITHUB_ENV -Value ANDROID_NDK_ROOT=$env:ANDROID_NDK_LATEST_HOME
- name: Configure JDK
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21" # matches Anki-Android
- name: Restore Rust Cache (Windows)
uses: actions/cache/restore@v4
if: contains(matrix.os, 'windows')
with:
path: |
~/.cargo/registry
~/.cargo/git
target
anki/out/rust
anki/out/download
# no node_modules, as it doesn't unpack properly
key: ${{ runner.os }}-rust-debug-v7-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('anki/yarn.lock') }}
restore-keys: |
${{ runner.os }}-rust-debug-v7
- name: Restore Rust Cache (Unix)
uses: actions/cache/restore@v4
if: contains(matrix.os, 'windows') == false
with:
path: |
~/.cargo/registry
~/.cargo/git
target
anki/out/rust
anki/out/download
anki/out/node_modules
key: ${{ runner.os }}-rust-debug-v6-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('anki/yarn.lock') }}
restore-keys: |
${{ runner.os }}-rust-debug-v6
- name: Setup N2
run: bash ./anki/tools/install-n2
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
timeout-minutes: 5
with:
# Only write to the cache for builds on the 'main' branches, stops branches evicting main cache
# Builds on other branches will only read from main branch cache writes
# Comment this and the with: above out for performance testing on a branch
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
gradle-home-cache-cleanup: true
- name: Build all (current platform)
# Ubuntu currently requires multiple build attempts before it succeeds - it builds a little further each time then works
# This happens the same way every time in CI so far, and is reproducible locally if you have an Ubuntu system
# This needs a root-cause analysis (see #373) but we will use a retry hack for Ubuntu only to unblock PRs until that is done
uses: nick-fields/retry@v3
with:
timeout_minutes: 30
max_attempts: ${{ contains(matrix.os, 'ubuntu') == true && 5 || 1 }}
retry_wait_seconds: 0
retry_on: error
command: cargo run -p build_rust
- name: Check Rust (Unix)
if: contains(matrix.os, 'windows') == false
run: ./check-rust.sh
- name: Check Rust (Windows)
if: contains(matrix.os, 'windows')
run: ./check-rust.bat
- name: Run tests (Unit)
uses: gradle/gradle-build-action@v3
with:
arguments: test rsdroid:lint --daemon
- name: Run tests (Emulator)
uses: reactivecircus/android-emulator-runner@v2
if: contains(matrix.os, 'ubuntu')
timeout-minutes: 30
with:
api-level: 23
target: default
arch: x86_64
profile: Nexus 6
script: ./gradlew rsdroid-instrumented:connectedCheck
- name: Upload rsdroid AAR as artifact
uses: actions/upload-artifact@v4
with:
name: rsdroid-aar-${{ matrix.os }}
if-no-files-found: error
path: rsdroid/build/outputs/aar
- name: Upload rsdroid-robo JAR as artifact
uses: actions/upload-artifact@v4
with:
name: rsdroid-robo-${{ matrix.os }}
if-no-files-found: error
path: rsdroid-testing/build/libs
- name: Save Rust Cache (Windows)
uses: actions/cache/save@v4
if: contains(matrix.os, 'windows') && github.ref == 'refs/heads/main'
with:
path: |
~/.cargo/registry
~/.cargo/git
target
anki/out/rust
anki/out/download
# no node_modules, as it doesn't unpack properly
key: ${{ runner.os }}-rust-debug-v7-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('anki/yarn.lock') }}
- name: Save Rust Cache (Unix)
uses: actions/cache/save@v4
if: contains(matrix.os, 'windows') == false && github.ref == 'refs/heads/main'
with:
path: |
~/.cargo/registry
~/.cargo/git
target
anki/out/rust
anki/out/download
anki/out/node_modules
key: ${{ runner.os }}-rust-debug-v6-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('anki/yarn.lock') }}