-
-
Notifications
You must be signed in to change notification settings - Fork 8
475 lines (412 loc) · 14.4 KB
/
tests.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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
name: Tests
on:
workflow_call:
inputs:
ref:
description: git branch, tag or SHA to checkout.
type: string
required: true
pull_request:
push:
branches: [main, master]
env:
CARGO_INCREMENTAL: 1
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
CARGO_TERM_COLOR: always
CARGO_TERM_PROGRESS_WHEN: never
# logging:
RUST_LOG: trace
CARGO_PLAYDATE_LOG: trace
# crates lists:
API_CRATES: >-
-p=playdate-color
-p=playdate-controls
-p=playdate-display
-p=playdate-fs
-p=playdate-graphics
-p=playdate-menu
-p=playdate-scoreboards
-p=playdate-sound
-p=playdate-sprite
-p=playdate-system
-p=playdate
PD_BUILD_BINDINGS_ONCE: 1
jobs:
api:
name: API
env:
FEATURES_1: bindgen-runtime
FEATURES_2: bindgen-runtime,bindings-derive-debug
FEATURES_3: bindgen-runtime,bindings-derive-debug,sys/bindings-documentation,sys/error-ctx
BUILD_STD_ARGS: -Zbuild-std=core,alloc --target=thumbv7em-none-eabihf
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-14
- ubuntu-latest
- windows-latest
sdk:
# - beta
- latest
- 2.4.0
steps:
- run: arch
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- name: Cache
uses: actions/cache@v4
with:
path: |
target/
~/.cargo
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Config
run: |
mkdir -p .cargo
cp -rf .github/config.toml .cargo/config.toml
- name: Install Deps
uses: ./.github/actions/tools-deps
- name: Install Playdate SDK ${{ matrix.sdk }}
id: sdk
uses: pd-rs/get-playdate-sdk@main
with:
version: ${{ matrix.sdk }}
custom-url: ${{ matrix.sdk == 'beta' && ((runner.os == 'macOS' && secrets.SDK_BETA_MACOS) || (runner.os == 'Linux' && secrets.SDK_BETA_LINUX) || (runner.os == 'Windows' && secrets.SDK_BETA_WINDOWS)) || '' }}
- name: SDK ${{ steps.sdk.outputs.version }} installed
run: which pdc && pdc --version
# - name: Install Bindgen
# # id: pdbindgen
# # continue-on-error: true
# if: runner.os == 'Windows'
# env:
# # LLVM_CONFIG_PATH: ${{ env.LLVM_PATH }}\\bin\\llvm-config
# LIBCLANG_PATH: ${{ env.LLVM_PATH }}\\bin
# run: >-
# cargo install playdate-bindgen --path ./support/bindgen
# --features=cli
# --debug
# # --features=cli,static --no-default-features
- name: Test Sys (host)
run: |
cargo test -p=playdate-sys --features=lang-items -- --nocapture
cargo test -p=playdate-sys --features=lang-items,$FEATURES_1
cargo test -p=playdate-sys --features=lang-items,$FEATURES_2
- name: Build Sys (device)
# env:
## add env if step.pdbindgen.failed
# DOCS_RS: ${{ runner.os == 'Windows' && 1 || 0 }}
# IGNORE_EXISTING_PLAYDATE_SDK: ${{ runner.os == 'Windows' && 1 || 0 }}
run: |
cargo build -p=playdate-sys ${{ env.BUILD_STD_ARGS }}
cargo build -p=playdate-sys --features=lang-items,$FEATURES_1 ${{ env.BUILD_STD_ARGS }} --examples
cargo build -p=playdate-sys --features=lang-items,$FEATURES_2 ${{ env.BUILD_STD_ARGS }} --examples
- name: Test Crates (host)
run: |
cargo test ${{ env.API_CRATES }} --lib --no-default-features --features=$FEATURES_1 -- --nocapture
cargo test ${{ env.API_CRATES }} --lib --no-default-features --features=$FEATURES_2
# cargo test ${{ env.API_CRATES }} --lib --no-default-features --features=$FEATURES_3
- name: Check Crates (device)
run: cargo check ${{ env.API_CRATES }} --target=thumbv7em-none-eabihf
- name: Build Crates (device)
run: |
cargo build ${{ env.API_CRATES }} --features=sys/lang-items,$FEATURES_1 ${{ env.BUILD_STD_ARGS }} --examples --lib
cargo build ${{ env.API_CRATES }} --features=sys/lang-items,$FEATURES_2 ${{ env.BUILD_STD_ARGS }} --examples --lib
cargo build ${{ env.API_CRATES }} --features=sys/lang-items,$FEATURES_3 ${{ env.BUILD_STD_ARGS }} --examples --lib
# Imitate docs.rs environment
- name: Test in no-sdk environment
env:
DOCS_RS: 1
PLAYDATE_SDK_PATH: 0
IGNORE_EXISTING_PLAYDATE_SDK: 1
run: |
cargo doc -p=playdate-sys --target=thumbv7em-none-eabihf --features=bindings-documentation,bindings-derive-default,bindings-derive-eq,bindings-derive-copy,bindings-derive-debug,bindings-derive-hash,bindings-derive-ord,bindings-derive-partialeq,bindings-derive-partialord
utils:
name: Utils
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-14
- ubuntu-latest
- windows-latest
sdk:
- latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- name: Cache
uses: actions/cache@v4
with:
path: |
target/
~/.cargo
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Config
run: |
mkdir -p .cargo
cp -rf .github/config.toml .cargo/config.toml
- name: Install Deps
uses: ./.github/actions/tools-deps
- name: Install Playdate SDK ${{ matrix.sdk }}
id: sdk
uses: pd-rs/get-playdate-sdk@main
with:
version: ${{ matrix.sdk }}
- name: SDK ${{ steps.sdk.outputs.version }} installed
run: which pdc && pdc --version
- name: Test
run: |
cargo test -p=playdate-build-utils --all-features
cargo test -p=playdate-build --all-features -- --nocapture
cargo test -p=playdate-device
cargo test -p=playdate-tool --all-features
tool:
name: Tool
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-14
- ubuntu-latest
- windows-latest
sdk:
# - beta
- latest
- 2.4.0
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- name: Cache
uses: actions/cache@v4
with:
path: |
target/
~/.cargo
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Config
run: |
mkdir -p .cargo
cp -rf .github/config.toml .cargo/config.toml
- name: Install Deps
uses: ./.github/actions/tools-deps
- name: Install Playdate SDK ${{ matrix.sdk }}
id: sdk
uses: pd-rs/get-playdate-sdk@main
with:
version: ${{ matrix.sdk }}
custom-url: ${{ matrix.sdk == 'beta' && ((runner.os == 'macOS' && secrets.SDK_BETA_MACOS) || (runner.os == 'Linux' && secrets.SDK_BETA_LINUX) || (runner.os == 'Windows' && secrets.SDK_BETA_WINDOWS)) || '' }}
- name: SDK ${{ steps.sdk.outputs.version }} installed
run: which pdc && pdc --version
- name: Check
run: cargo check --tests -p=cargo-playdate --all-features
# Simulator doesn't works in headless mode
# - name: Install Sim Deps
# if: ${{ runner.os == 'Linux' }}
# run: |
# sudo apt update
# sudo apt -y install libwebkit2gtk-4.0-dev
- name: Test
run: cargo test -p=cargo-playdate -- --nocapture
- name: Test (init::)
env:
RUSTFLAGS: --cfg init_tests
run: |
cargo test -p=cargo-playdate init:: -- --nocapture ${{ runner.os == 'Windows' && '--test-threads=1' || '' }}
- name: Clean tmp
run: rm -rf ./target/tmp
# This test is flickering on GH CI 🤷🏻♂️
- name: Test Execution
if: runner.os == 'macOS' && contains(github.event.head_commit.message, 'execution')
env:
RUSTFLAGS: --cfg exec_tests
run: |
cargo test -p=cargo-playdate run -- --nocapture --test-threads=1
sudo killall "Playdate Simulator" || true
rm -rf ./target/tmp
use-tool:
name: Examples
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-14
- ubuntu-latest
# - windows-latest
sdk:
# - beta
- latest
- 2.4.0
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo
key: ${{ runner.os }}-${{ runner.arch }}-cargo-examples-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-cargo-examples-${{ hashFiles('Cargo.lock') }}
${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Config
run: |
rm -rf ./target/tmp || true
rm -rf ./target/playdate || true
mkdir -p .cargo
cp -rf .github/config.toml .cargo/config.toml
cargo clean
- name: Install Deps
uses: ./.github/actions/tools-deps
- name: Install Playdate SDK ${{ matrix.sdk }}
id: sdk
uses: pd-rs/get-playdate-sdk@main
with:
version: ${{ matrix.sdk }}
custom-url: ${{ matrix.sdk == 'beta' && ((runner.os == 'macOS' && secrets.SDK_BETA_MACOS) || (runner.os == 'Linux' && secrets.SDK_BETA_LINUX) || (runner.os == 'Windows' && secrets.SDK_BETA_WINDOWS)) || '' }}
- name: SDK ${{ steps.sdk.outputs.version }} installed
run: which pdc && pdc --version
- name: Install
run: cargo install --path=./cargo --debug
- name: Examples
run: |
FEATURES=sys/lang-items,sys/entry-point
cargo playdate package --features=lang-items --examples --device --simulator -p=playdate-sys
cargo playdate package --features=$FEATURES --examples --device --simulator -p=playdate-color
cargo playdate package --features=$FEATURES --examples --device --simulator -p=playdate-controls
cargo playdate package --features=$FEATURES --examples --device --simulator -p=playdate-display
cargo playdate package --features=$FEATURES --examples --device --simulator -p=playdate-fs
cargo playdate package --features=$FEATURES --examples --device --simulator -p=playdate-graphics
cargo playdate package --features=$FEATURES --examples --device --simulator -p=playdate-menu
cargo playdate package --features=$FEATURES --examples --device --simulator -p=playdate-scoreboards
cargo playdate package --features=$FEATURES --examples --device --simulator -p=playdate-sound
cargo playdate package --features=$FEATURES --examples --device --simulator -p=playdate-sprite
cargo playdate package --features=$FEATURES --examples --device --simulator -p=playdate-system
cargo playdate package --features=lang-items,entry-point --examples --device --simulator -p=playdate
# TODO: build crankstart with examples for compatibility test
format:
name: Format
defaults:
run:
shell: bash
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
permissions:
actions: read
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- name: Check
id: check
continue-on-error: true
run: >-
cargo fmt --all -- --check ||
(echo "::error::Rust format error." && exit 1)
- name: Format
id: format
if: steps.check.outcome == 'failure'
run: cargo fmt --all
# - name: Suggestions
# continue-on-error: true
# uses: parkerbxyz/[email protected]
# with: comment: Rustfmt suggested the formatting changes.
- name: Suggestions
if: steps.check.outcome == 'failure'
uses: reviewdog/action-suggester@v1
with:
filter_mode: diff_context
fail_on_error: false
tool_name: Rustfmt
cleanup: false
- name: Post Check
if: steps.check.outcome == 'failure'
run: exit 1
clippy:
name: Clippy
if: github.event_name == 'pull_request'
defaults:
run:
shell: bash
permissions:
contents: read
checks: write
issues: write
pull-requests: write
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-14
- ubuntu-latest
- windows-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
# fetch-depth: 2
- name: Install Clippy
run: rustup component add clippy
- name: Cache
uses: actions/cache@v4
with:
path: |
target/
~/.cargo
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Config
run: |
mkdir -p .cargo
cp -rf .github/config.toml .cargo/config.toml
- name: Install Deps
uses: ./.github/actions/tools-deps
- name: Cargo & Support
id: clippy
continue-on-error: true
run: >-
cargo clippy --fix --allow-dirty
-p=cargo-playdate
-p=playdate-bindgen
-p=playdate-bindgen-cfg
-p=playdate-build
-p=playdate-device
-p=playdate-simulator-utils
-p=playdate-build-utils
-p=playdate-tool
--bins --examples --all-targets
-- -Aclippy::cargo
|| (echo "::error::Rust format error." && exit 1)
- name: remove config
run: rm -rf .cargo
- name: Suggestions
uses: reviewdog/action-suggester@v1
with:
filter_mode: diff_context
fail_on_error: false
tool_name: Clippy
cleanup: false