-
Notifications
You must be signed in to change notification settings - Fork 31
203 lines (173 loc) · 6.2 KB
/
rust.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
196
197
198
199
200
201
202
203
name: Rust
on: [push, pull_request]
jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Format
run: cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install aarch64-linux-android Rust target
run: rustup target add aarch64-linux-android
- name: Clippy
# Use one of our supported targets to lint all crates including
# the target-specific `ndk` in one go.
# This assumes our host-tools (cargo-apk and dependencies)
# also compile cleanly under this target.
run: cargo clippy --all --all-targets --all-features --target aarch64-linux-android -- -Dwarnings
check_msrv:
name: Check MSRV (1.64.0)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: dtolnay/[email protected]
with:
target: aarch64-linux-android
- name: Check
# See comment above about using one of our supported targets.
run: cargo check --workspace --all-targets --all-features --target aarch64-linux-android
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
rust-channel: ["stable", "nightly"]
rust-target:
- "armv7-linux-androideabi"
- "aarch64-linux-android"
- "i686-linux-android"
- "x86_64-linux-android"
include:
- os: windows-latest
rust-channel: "stable"
rust-target: "aarch64-linux-android"
- os: windows-latest
rust-channel: "stable"
rust-target: "x86_64-linux-android"
runs-on: ${{ matrix.os }}
name: Build apk
steps:
- uses: actions/checkout@v2
- name: Installing Rust ${{ matrix.rust-channel }} w/ ${{ matrix.rust-target }}
run: |
rustup toolchain install ${{ matrix.rust-channel }}
rustup default ${{ matrix.rust-channel }}
rustup target add ${{ matrix.rust-target }}
- name: Install cargo-apk
run: cargo install --path cargo-apk
- name: Cargo apk build for target ${{ matrix.rust-target }}
run: cargo apk build -p examples --target ${{ matrix.rust-target }} --examples
- uses: actions/upload-artifact@v2
# Only need this for CI, unless users are interested in downloading
# a ready-made app that does nothing but printing "hello world".
if: ${{ matrix.rust-target == 'x86_64-linux-android' }}
name: Upload hello_world apk
with:
name: hello_world_${{ matrix.os }}_${{ matrix.rust-target }}
path: ./target/debug/apk/examples/hello_world.apk
android_emulator:
name: hello_world example on emulator
needs: build
runs-on: macos-latest
strategy:
matrix:
source_os: [ubuntu-latest, windows-latest, local]
env:
api-level: 29
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
arch: x86_64
# the `googleapis` emulator target is considerably slower on CI.
target: default
profile: Nexus 6
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
name: Download hello_world APK
if: ${{ matrix.source_os != 'local' }}
id: download
with:
name: hello_world_${{ matrix.source_os }}_x86_64-linux-android
- name: Install `cargo-apk` and add `x86_64-linux-android` target
if: ${{ matrix.source_os == 'local' }}
run: |
cargo install --path cargo-apk
rustup target add x86_64-linux-android
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
# Bump the trailing number when making changes to the emulator setup below
key: avd-${{ env.api-level }}-1
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.api-level }}
arch: ${{ env.arch }}
target: ${{ env.target }}
profile: ${{ env.profile }}
emulator-options: ${{ env.emulator-options }}
disable-animations: true
force-avd-creation: false
script: echo "Generated AVD snapshot for caching."
- name: Start hello_world example
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.api-level }}
arch: ${{ env.arch }}
target: ${{ env.target }}
profile: ${{ env.profile }}
emulator-options: -no-snapshot-save ${{ env.emulator-options }}
disable-animations: true
force-avd-creation: false
script: ./.github/workflows/android_test.sh "${{ steps.download.outputs.download-path }}"
- name: Upload emulator logs
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: log
path: ~/logcat.log
build-host:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
rust-channel: ["stable", "nightly"]
runs-on: ${{ matrix.os }}
name: Host-side tests
steps:
- uses: actions/checkout@v2
- name: Installing Rust ${{ matrix.rust-channel }}
run: |
rustup toolchain install ${{ matrix.rust-channel }}
rustup default ${{ matrix.rust-channel }}
- name: Test ndk-build
run: cargo test -p ndk-build --all-features
- name: Test cargo-apk
run: cargo test -p cargo-apk --all-features
docs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
rust-channel: ["stable", "nightly"]
runs-on: ${{ matrix.os }}
name: Build-test docs
steps:
- uses: actions/checkout@v2
- name: Installing Rust ${{ matrix.rust-channel }}
run: |
rustup toolchain install ${{ matrix.rust-channel }}
rustup default ${{ matrix.rust-channel }}
- name: Document all crates
env:
RUSTDOCFLAGS: -Dwarnings
run: cargo doc --all --all-features