-
Notifications
You must be signed in to change notification settings - Fork 0
255 lines (219 loc) · 7.93 KB
/
ci.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
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
name: CI
on:
pull_request:
push:
branches:
- main
permissions:
contents: write # Needed for Flutter CI which auto-updates bindings
env:
CARGO_TERM_COLOR: always
jobs:
build_rust_and_test:
name: Rust project - latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- run: rustup update stable && rustup default stable
- run: rustup toolchain install nightly -c rustfmt
- run: docker compose up -d
working-directory: test/scripts/forked_state
- run: while ! curl localhost:8545/health; do sleep 1; done
- run: while ! curl localhost:4337/health; do sleep 1; done
- run: while ! curl localhost:3000/ping; do sleep 1; done
- run: cargo build --workspace --features=full --all-targets
- run: cargo test --features=full --lib --bins
- run: cargo clippy --workspace --features=full --all-targets -- -D warnings
- run: cargo clippy -p yttrium --all-targets -- -D warnings # `-p yttrium` to avoid feature unification; kotlin-ffi enables uniffi feature and we want to test without that
- run: cargo +nightly fmt --all -- --check
udeps:
name: Unused dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- run: rustup update stable && rustup default stable
- run: rustup toolchain install nightly -c rustfmt
- run: git submodule update --init --recursive
- run: cargo install cargo-udeps
- run: cargo +nightly udeps --workspace
# build_wasm:
# name: Build on WASM
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
# - name: Run sccache-cache
# uses: mozilla-actions/[email protected]
# - run: rustup update stable && rustup default stable
# - run: rustup target add wasm32-unknown-unknown
# - run: cargo build --workspace --features=full --lib --bins --target wasm32-unknown-unknown --exclude=ffi
build_swift_and_test:
name: Swift Package - latest
runs-on: macos-14
strategy:
matrix:
config:
- debug
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- run: rustup update stable && rustup default stable
- name: Select Xcode 15.4
run: sudo xcode-select -s /Applications/Xcode_15.4.app
# Build bindings
- run: make build-xcframework
# Don't think we actually need this check, since bindings will be updated during release
# - run: git diff crates/ffi
# - run: if [ -n "$(git diff crates/ffi)" ]; then exit 1; fi
# Test that it compiles
- name: Build ${{ matrix.config }}
run: make CONFIG=${{ matrix.config }} build-swift-apple-platforms
build-kotlin:
runs-on: ubuntu-latest
strategy:
matrix:
target: [aarch64-linux-android, armv7-linux-androideabi]
steps:
- uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
components: rust-src
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: Set up Android SDK
uses: android-actions/setup-android@v3
with:
api-level: 35
build-tools: 35.0.0
ndk-version: 27.2.12479018
- name: Build with Gradle
run: |
./gradlew clean assembleRelease -Pversion=${{ env.VERSION }}
- name: Install cargo-ndk
run: |
cargo install cargo-ndk
- name: Build Rust library
run: |
cargo ndk -t ${{ matrix.target }} build --release --features=uniffi/cli
- name: Generate Kotlin bindings (once)
if: ${{ matrix.target == 'aarch64-linux-android' }}
run: |
cargo run --features=uniffi/cli --bin uniffi-bindgen generate --library target/${{ matrix.target }}/release/libuniffi_yttrium.so --language kotlin --out-dir yttrium/kotlin-bindings
- name: Prepare artifacts
run: |
# Map Rust targets to Android ABI names
declare -A abi_map
abi_map[aarch64-linux-android]="arm64-v8a"
abi_map[armv7-linux-androideabi]="armeabi-v7a"
abi_name=${abi_map[${{ matrix.target }}]}
if [ -z "$abi_name" ]; then
echo "Unknown ABI for target ${{ matrix.target }}"
exit 1
fi
mkdir -p yttrium/libs/$abi_name
cp target/${{ matrix.target }}/release/libuniffi_yttrium.so yttrium/libs/$abi_name/
flutter:
runs-on: macos-latest-xlarge
if: github.event_name == 'pull_request'
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
# Need to use a PAT, not GITHUB_TOKEN, or else CI won't run like normal
token: ${{ secrets.RELEASE_TOKEN_V3 }}
# Cache Flutter dependencies
- name: Cache Flutter dependencies
uses: actions/cache@v3
with:
path: ~/.pub-cache
key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
${{ runner.os }}-flutter-
# Install Rust toolchain
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rust-src
# Cache Cargo dependencies
- name: Cache Cargo dependencies
uses: actions/cache@v3
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
# Install Java 17
- name: Install Java 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
architecture: x86_64
cache: 'gradle'
# Cache Gradle
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# Install Flutter
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.5'
# Install flutter_rust_bridge_codegen
- name: Install flutter_rust_bridge_codegen
run: |
cargo install flutter_rust_bridge_codegen
# Get package dependencies
- name: Get package dependencies
shell: bash
working-directory: crates/yttrium_dart
run: |
flutter pub get
# Generate Dart Bindings
- name: Generate Dart Bindings
shell: bash
working-directory: crates/yttrium_dart
run: |
flutter_rust_bridge_codegen generate --config-file flutter_rust_bridge.yaml
- run: git diff crates/yttrium_dart
# - run: if [ -n "$(git diff crates/yttrium_dart)" ]; then exit 1; fi
- name: Commit and push updated Flutter bindings, if necessary
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add crates/yttrium_dart
if git diff --cached --quiet crates/yttrium_dart; then
echo "No changes to commit."
else
git commit -m "chore: update Flutter bindings"
git push origin HEAD:${{ github.head_ref }}
fi