Repository navigation
257 lines (213 loc) · 8.04 KB
/
Copy pathci.yml
File metadata and controls
257 lines (213 loc) · 8.04 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
# Keep the Android Gradle build from walking the whole repository.
GRADLE_OPTS: -Dorg.gradle.jvmargs=-Xmx3g
jobs:
# ---------------------------------------------------------------------------
# The gate every change has to pass: format, lints, tests, and a build of
# the workspace on the host platform.
# ---------------------------------------------------------------------------
checks:
name: Format, lints, tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libgl1-mesa-dev \
libegl1-mesa-dev \
libxkbcommon-dev \
libwayland-dev \
libx11-dev \
libxcb1-dev \
libxrandr-dev \
libxi-dev \
libxcursor-dev \
libxinerama-dev \
pkg-config
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Formatting
run: cargo fmt --all --check
- name: Clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: Check every crate and target
run: cargo check --workspace --all-targets --all-features
- name: Tests
run: cargo test --workspace --all-features
- name: Docs build without warnings
run: cargo doc --workspace --no-deps
env:
RUSTDOCFLAGS: -D warnings
# ---------------------------------------------------------------------------
# The bundled backend: built, started, and hit over a real socket.
# ---------------------------------------------------------------------------
backend:
name: Backend (build + smoke test)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --package server
- name: Smoke test the shared contract
run: |
./target/debug/server --bind 127.0.0.1:8080 &
server_pid=$!
trap 'kill "$server_pid" 2>/dev/null || true' EXIT
for _ in $(seq 1 50); do
curl -sf http://127.0.0.1:8080/api/health >/dev/null && break
sleep 0.1
done
curl -sf http://127.0.0.1:8080/api/health
curl -sf http://127.0.0.1:8080/api/users
curl -sf 'http://127.0.0.1:8080/api/users/search?q=wonder'
# ---------------------------------------------------------------------------
# Every target the Linux runner can produce, so a change that breaks Android
# or Web is caught here rather than on a developer's phone.
# ---------------------------------------------------------------------------
cross-compile:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: Android (all four ABIs)
target: aarch64-linux-android
extra: armv7-linux-androideabi i686-linux-android x86_64-linux-android
- name: Web (wasm32)
target: wasm32-unknown-unknown
extra: ""
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }} ${{ matrix.extra }}
- uses: Swatinem/rust-cache@v2
# Source scripts/android-env.sh so the NDK clang is found for both the
# Rust linker and the C compiler cc-rs needs.
- name: Android NDK
if: contains(matrix.name, 'Android')
uses: nttld/setup-ndk@v1
with:
ndk-version: r27c
- name: Build
if: contains(matrix.name, 'Android')
run: |
source scripts/android-env.sh
for triple in ${{ matrix.target }} ${{ matrix.extra }}; do
echo "::group::$triple"
cargo build --package example-app --target "$triple"
test -f "target/$triple/debug/libexample_app.so"
echo "::endgroup::"
done
- name: Install Trunk
if: contains(matrix.name, 'Web')
run: cargo install --locked trunk
- name: Build
if: contains(matrix.name, 'Web')
run: scripts/build-web.sh
- uses: actions/upload-artifact@v4
if: contains(matrix.name, 'Android')
with:
name: android-so-debug
path: |
target/*/debug/libexample_app.so
if-no-files-found: error
# ---------------------------------------------------------------------------
# The real APK, assembled by Gradle around the Rust `.so`.
# ---------------------------------------------------------------------------
android-apk:
name: Android APK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android, armv7-linux-androideabi
- uses: nttld/setup-ndk@v1
with:
ndk-version: r27c
- uses: Swatinem/rust-cache@v2
with:
workspaces: android-app -> build
- uses: gradle/actions/setup-gradle@v4
- name: Assemble
working-directory: android-app
run: ./gradlew assembleDebug -PandroidAbi=arm64-v8a,armeabi-v7a
- uses: actions/upload-artifact@v4
with:
name: example-app-debug.apk
path: android-app/app/build/outputs/apk/debug/*.apk
if-no-files-found: error
# ---------------------------------------------------------------------------
# Native desktop builds. Each runs on its own platform, because there is no
# honest way to prove a Windows or macOS binary from Linux.
# ---------------------------------------------------------------------------
desktop:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { name: Linux desktop, os: ubuntu-latest, out: target/debug/example-app }
- { name: macOS desktop, os: macos-latest, out: target/debug/example-app }
- { name: Windows desktop, os: windows-latest, out: target/debug/example-app.exe }
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install Linux build dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libgl1-mesa-dev libegl1-mesa-dev libxkbcommon-dev libwayland-dev \
libx11-dev libxcb1-dev libxrandr-dev libxi-dev libxcursor-dev \
libxinerama-dev pkg-config
- run: cargo build --package example-app
- uses: actions/upload-artifact@v4
with:
name: example-app-${{ matrix.os }}
path: ${{ matrix.out }}
if-no-files-found: error
# ---------------------------------------------------------------------------
# iOS can only be built on macOS. This checks it compiles; producing a signed
# `.ipa` needs certificates that a public CI runner does not have.
# ---------------------------------------------------------------------------
ios:
name: iOS (compile only)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-ios, aarch64-apple-ios-sim, x86_64-apple-ios
- uses: Swatinem/rust-cache@v2
- name: Build the device library
run: scripts/build-ios.sh --release
- uses: actions/upload-artifact@v4
with:
name: libexample_app-ios.a
path: target/aarch64-apple-ios/release/libexample_app.a
if-no-files-found: error