-
Notifications
You must be signed in to change notification settings - Fork 5
602 lines (589 loc) · 20.2 KB
/
Copy pathci.yml
File metadata and controls
602 lines (589 loc) · 20.2 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
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
name: CI
on:
workflow_dispatch:
pull_request:
types:
- opened
- synchronize
- reopened
push:
branches:
- main
jobs:
build-jieba-vim-cdylib:
name: Build jieba.vim cdylib required in verifications
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Build py3 binding
shell: bash
run: |
rm -f jieba_vim_rs.so
cargo clean \
--manifest-path rust_backend/Cargo.toml
cargo build --locked -r \
--manifest-path rust_backend/Cargo.toml \
--package jieba_vim_rs_binding_py3
mv rust_backend/target/release/libjieba_vim_rs.so jieba_vim_rs.so
- uses: actions/upload-artifact@v6
with:
name: jieba-vim-cdylib-python
path: jieba_vim_rs.so
if-no-files-found: error
retention-days: 1
compression-level: 0
- name: Build lua51 binding
shell: bash
run: |
rm -f jieba_vim_rs.so
cargo clean \
--manifest-path rust_backend/Cargo.toml
cargo build --locked -r \
--manifest-path rust_backend/Cargo.toml \
--package jieba_vim_rs_binding_lua51
mv rust_backend/target/release/libjieba_vim_jieba_vim_rs.so jieba_vim_rs.so
- uses: actions/upload-artifact@v6
with:
name: jieba-vim-cdylib-lua
path: jieba_vim_rs.so
if-no-files-found: error
retention-days: 1
compression-level: 0
pytest-metatest:
name: Pytest metatest
runs-on: ubuntu-24.04
env:
# uv variables
UV_PROJECT: ${{ github.workspace }}/test/jieba_test_metatest
UV_PYTHON_DOWNLOADS: automatic
UV_MANAGED_PYTHON: '1'
# pytest variables
CI: '1'
steps:
- uses: actions/checkout@v6
- name: Setup uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: '0.11.16'
enable-cache: true
- name: Run uv-sync
shell: bash
run: uv sync --extra dev
- name: Run test on metatest
shell: bash
run: uv run pytest $UV_PROJECT
basic-integrated-verification:
name: >
Basic integrated case verification for
${{ matrix.vim.distr }}@${{ matrix.vim.version }}
+${{ matrix.vim.glue-lang }}
runs-on: ubuntu-24.04
needs:
- build-jieba-vim-cdylib
strategy:
fail-fast: false
matrix:
vim:
- distr: vim
version: v8.2.3455
glue-lang: py39
- distr: vim
version: v9.1.0000
glue-lang: py311
- distr: nvim
version: v0.11.5
glue-lang: lua51
- distr: nvim
version: v0.12.2
glue-lang: lua51
env:
# uv variables
UV_PROJECT: ${{ github.workspace }}/test/jieba_test_metatest
UV_PYTHON_DOWNLOADS: automatic
UV_MANAGED_PYTHON: '1'
# vimrc variables
GLUE_LANG: ${{ matrix.vim.glue-lang }}
JIEBA_VIM_DIR: ${{ github.workspace }}
steps:
# Prepare env.
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-vim
with:
vim-distr: ${{ matrix.vim.distr }}
vim-version: ${{ matrix.vim.version }}
glue-lang: ${{ matrix.vim.glue-lang }}
- name: Setup uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: '0.11.16'
enable-cache: true
- name: Run uv-sync
shell: bash
run: uv sync
- name: Expand basic integrated cases template
shell: bash
run: make -C test/cases/basic_integrated_verification clean all
- name: Get jieba.vim cdylib for vim(+python3)
if: matrix.vim.distr == 'vim'
uses: actions/download-artifact@v7
with:
name: jieba-vim-cdylib-python
path: pythonx/jieba_vim
- name: Get jieba.vim cdylib for nvim
if: matrix.vim.distr == 'nvim'
uses: actions/download-artifact@v7
with:
name: jieba-vim-cdylib-lua
path: lua/jieba_vim
- name: Vim sanity check
shell: bash
run: |
cd test/cases/basic_integrated_verification
case ${{ matrix.vim.distr }} in
vim)
vim -es -u vimrc -cq < /dev/null
;;
nvim)
nvim --headless -u vimrc -cq < /dev/null
;;
esac
- name: Get a filename-safe version of vim.version
id: safe-version
shell: bash
run: |
SAFE_VERSION="$(echo "${{ matrix.vim.version }}" | tr . _)"
echo "safe_version=${SAFE_VERSION}" >> "$GITHUB_OUTPUT"
echo "vim_dist_name=${{ matrix.vim.distr }}_${SAFE_VERSION}_${{ matrix.vim.glue-lang }}" >> "$GITHUB_OUTPUT"
# Do the job.
- name: Run basic integrated case verification
id: run-bi-case-verification
continue-on-error: true
shell: bash
run: |
set +e
case ${{ matrix.vim.distr }} in
vim)
uv run jieba-metatest-bi-verification \
-j4 \
--rc test/cases/basic_integrated_verification/vimrc \
-v vim \
-d bi_verification \
-n ${{ steps.safe-version.outputs.vim_dist_name }} \
-w bi_verification/warns_${{ steps.safe-version.outputs.vim_dist_name }} \
-f bi_verification/errs_${{ steps.safe-version.outputs.vim_dist_name }} \
test/cases/basic_integrated_verification/*.jieba_test_case
;;
nvim)
uv run jieba-metatest-bi-verification \
-j4 \
--rc test/cases/basic_integrated_verification/vimrc \
-v nvim --neovim \
-d bi_verification \
-n ${{ steps.safe-version.outputs.vim_dist_name }} \
-w bi_verification/warns_${{ steps.safe-version.outputs.vim_dist_name }} \
-f bi_verification/errs_${{ steps.safe-version.outputs.vim_dist_name }} \
test/cases/basic_integrated_verification/*.jieba_test_case
;;
esac
exit_code=$?
set -e
echo "exit_code=$exit_code" >> "$GITHUB_OUTPUT"
if [ $exit_code != 0 ]; then
exit $exit_code
fi
- name: Check basic integrated case verification exit code
shell: bash
run: |
code="${{ steps.run-bi-case-verification.outputs.exit_code }}"
if [ "$code" != 0 ] && [ "$code" != 1 ] && [ "$code" != 125 ]; then
echo "bi case verification may have panicked" >&2
exit $code
fi
- name: Indicate whether basic integrated case verification has failed
id: indicate-state
shell: bash
run: |
TOFILE=bi-success-${{ steps.safe-version.outputs.vim_dist_name }}.txt
echo "tofile=$TOFILE" >> "$GITHUB_OUTPUT"
cat <<'EOF' > "$TOFILE"
${{ steps.run-bi-case-verification.outputs.exit_code }} ${{ matrix.vim.distr }} @${{ matrix.vim.version }} +${{ matrix.vim.glue-lang }}
EOF
- uses: actions/upload-artifact@v6
with:
name: bi-success-${{ matrix.vim.distr }}-${{ matrix.vim.version }}-${{ matrix.vim.glue-lang }}
path: ${{ steps.indicate-state.outputs.tofile }}
if-no-files-found: error
retention-days: 1
compression-level: 0
- uses: actions/upload-artifact@v6
with:
name: bi-report-${{ matrix.vim.distr }}-${{ matrix.vim.version }}-${{ matrix.vim.glue-lang }}
path: |
bi_verification/warns_${{ steps.safe-version.outputs.vim_dist_name }}
bi_verification/errs_${{ steps.safe-version.outputs.vim_dist_name }}
retention-days: 5
- name: Collect rust test info jsonl files
uses: actions/upload-artifact@v6
with:
name: rust-core-test-info-${{ matrix.vim.distr }}-${{ matrix.vim.version }}-${{ matrix.vim.glue-lang }}
path: bi_verification/unit-${{ steps.safe-version.outputs.vim_dist_name }}.jsonl
if-no-files-found: error
retention-days: 5
report-basic-integrated-case-verification-errors:
name: Report basic integrated case verification errors
runs-on: ubuntu-24.04
needs: basic-integrated-verification
steps:
- uses: actions/download-artifact@v7
with:
pattern: bi-success-*
merge-multiple: true
- uses: actions/download-artifact@v7
with:
pattern: bi-report-*
merge-multiple: true
- name: Report errors
shell: bash
run: |
for file in $(find . -type f -name 'errs_*'); do
echo "$file -->"
cat "$file"
done
echo "==="
! cat bi-success-*.txt | grep '^1 '
report-basic-integrated-case-verification-warnings:
name: Report basic integrated case verification warnings
runs-on: ubuntu-24.04
needs: basic-integrated-verification
steps:
- uses: actions/download-artifact@v7
with:
pattern: bi-success-*
merge-multiple: true
- uses: actions/download-artifact@v7
with:
pattern: bi-report-*
merge-multiple: true
- name: Report warnings
shell: bash
run: |
for file in $(find . -type f -name 'warns_*'); do
echo "$file -->"
cat "$file"
done
echo "==="
! cat bi-success-*.txt | grep '^125 '
integrated-test:
name: >
Integrated test for
${{ matrix.vim.distr }}@${{ matrix.vim.version }}
+${{ matrix.vim.glue-lang }}
on ${{ matrix.vim.os }}
runs-on: ${{ matrix.vim.os }}
strategy:
fail-fast: false
matrix:
vim:
- distr: vim
version: v8.2.3455
glue-lang: py39
os: ubuntu-24.04
- distr: vim
version: v9.1.0000
glue-lang: py311
os: ubuntu-24.04
- distr: vim
version: v9.2.0321
glue-lang: py311
os: ubuntu-24.04
- distr: nvim
version: v0.10.2
glue-lang: lua51
os: ubuntu-24.04
- distr: nvim
version: v0.10.2
glue-lang: lua51
os: windows-latest
- distr: nvim
version: v0.10.2
glue-lang: lua51
os: macos-14
- distr: nvim
version: v0.11.5
glue-lang: lua51
os: ubuntu-24.04
- distr: nvim
version: v0.11.5
glue-lang: lua51
os: windows-latest
- distr: nvim
version: v0.11.5
glue-lang: lua51
os: macos-14
- distr: nvim
version: v0.12.2
glue-lang: lua51
os: ubuntu-24.04
- distr: nvim
version: v0.12.2
glue-lang: lua51
os: windows-latest
- distr: nvim
version: v0.12.2
glue-lang: lua51
os: macos-14
env:
# uv variables
UV_PROJECT: ${{ github.workspace }}/test/jieba_test_metatest
UV_PYTHON_DOWNLOADS: automatic
UV_MANAGED_PYTHON: '1'
# vimrc variables
GLUE_LANG: ${{ matrix.vim.glue-lang }}
JIEBA_VIM_DIR: ${{ github.workspace }}
VIM_REPEAT_DIR: ${{ github.workspace }}/.vim_bundle/vim-repeat
# jieba.vim build variables
JIEBA_VIM_BUILD_FROM_SOURCE: '1'
JIEBA_VIM_INSTALL_NVIM: ${{ matrix.vim.distr == 'nvim' && '1' || '' }}
steps:
# Prepare env.
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-vim
with:
vim-distr: ${{ matrix.vim.distr }}
vim-version: ${{ matrix.vim.version }}
glue-lang: ${{ matrix.vim.glue-lang }}
- name: Setup uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: '0.11.16'
enable-cache: true
- name: Run uv-sync
shell: bash
run: uv sync
- uses: dtolnay/rust-toolchain@stable
- name: Build jieba.vim cdylib
shell: bash
run: |
case ${{ matrix.vim.os }} in
windows-*)
powershell -ExecutionPolicy Bypass -file ./build.ps1
;;
*)
./build.sh
;;
esac
- name: Get a filename-safe version of vim.version
id: safe-version
shell: bash
run: |
SAFE_VERSION="$(echo "${{ matrix.vim.version }}" | tr . _)"
echo "safe_version=${SAFE_VERSION}" >> "$GITHUB_OUTPUT"
echo "vim_dist_name=${{ matrix.vim.distr }}_${SAFE_VERSION}_${{ matrix.vim.glue-lang }}_${{ matrix.vim.os }}" >> "$GITHUB_OUTPUT"
- name: Expand templates
shell: bash
run: |
case ${{ matrix.vim.os }} in
windows-*)
choco install make
;;
macos-*)
brew install make
;;
esac
make -C test/cases clean all
env:
# This should fix UnicodeEncodeError on Windows.
PYTHONUTF8: '1'
PYTHONIOENCODING: utf-8
- name: Setup vim plugins
shell: bash
run: |
mkdir -p .vim_bundle
git clone https://github.com/tpope/vim-repeat.git .vim_bundle/vim-repeat
# Do the job.
- name: Run integrated test
id: run-i-test
continue-on-error: true
shell: bash
run: |
cum_exit_code=
for dir in $(find test/cases -maxdepth 1 -type d); do
set +e
case ${{ matrix.vim.distr }} in
vim)
uv run jieba-metatest-i-test \
--rc $dir/vimrc \
-v vim \
-d i_test \
-w i_test/warns_${{ steps.safe-version.outputs.vim_dist_name }} \
-f i_test/errs_${{ steps.safe-version.outputs.vim_dist_name }} \
$dir/*.jieba_test_case
;;
nvim)
uv run jieba-metatest-i-test \
--rc $dir/vimrc \
-v nvim --neovim \
-d i_test \
-w i_test/warns_${{ steps.safe-version.outputs.vim_dist_name }} \
-f i_test/errs_${{ steps.safe-version.outputs.vim_dist_name }} \
$dir/*.jieba_test_case
;;
esac
exit_code=$?
set -e
if [ $exit_code != 0 ] && [ $exit_code != 125 ]; then
echo "exit_code=$exit_code" >> "$GITHUB_OUTPUT"
exit $exit_code
fi
if [ -z "$cum_exit_code" ]; then
cum_exit_code=$exit_code
elif [ $exit_code = 125 ]; then
cum_exit_code=125
fi
done
echo "exit_code=$cum_exit_code" >> "$GITHUB_OUTPUT"
- name: Check integrated test exit code
shell: bash
run: |
code="${{ steps.run-i-test.outputs.exit_code }}"
if [ "$code" != 0 ] && [ "$code" != 1 ] && [ "$code" != 125 ]; then
echo "bi case verification may have panicked" >&2
exit $code
fi
- name: Indicate whether integrated test has failed
id: indicate-state
shell: bash
run: |
TOFILE=i-success-${{ steps.safe-version.outputs.vim_dist_name }}.txt
echo "tofile=$TOFILE" >> "$GITHUB_OUTPUT"
cat <<'EOF' > "$TOFILE"
${{ steps.run-i-test.outputs.exit_code }} ${{ matrix.vim.distr }} @${{ matrix.vim.version }} +${{ matrix.vim.glue-lang }} on ${{ matrix.vim.os }}
EOF
- uses: actions/upload-artifact@v6
with:
name: i-success-${{ matrix.vim.distr }}-${{ matrix.vim.version }}-${{ matrix.vim.glue-lang }}-${{ matrix.vim.os }}
path: ${{ steps.indicate-state.outputs.tofile }}
if-no-files-found: error
retention-days: 1
compression-level: 0
- uses: actions/upload-artifact@v6
with:
name: i-report-${{ matrix.vim.distr }}-${{ matrix.vim.version }}-${{ matrix.vim.glue-lang }}-${{ matrix.vim.os }}
path: |
i_test/warns_${{ steps.safe-version.outputs.vim_dist_name }}
i_test/errs_${{ steps.safe-version.outputs.vim_dist_name }}
retention-days: 5
report-integrated-test-errors:
name: Report integrated test errors
runs-on: ubuntu-24.04
needs: integrated-test
steps:
- uses: actions/download-artifact@v7
with:
pattern: i-success-*
merge-multiple: true
- uses: actions/download-artifact@v7
with:
pattern: i-report-*
merge-multiple: true
- name: Report errors
shell: bash
run: |
for file in $(find . -type f -name 'errs_*'); do
echo "$file -->"
cat "$file"
done
echo "==="
! cat i-success-*.txt | grep '^1 '
report-integrated-test-warnings:
name: Report integrated test warnings
runs-on: ubuntu-24.04
needs: integrated-test
steps:
- uses: actions/download-artifact@v7
with:
pattern: i-success-*
merge-multiple: true
- uses: actions/download-artifact@v7
with:
pattern: i-report-*
merge-multiple: true
- name: Report errors
shell: bash
run: |
for file in $(find . -type f -name 'warns_*'); do
echo "$file -->"
cat "$file"
done
echo "==="
! cat i-success-*.txt | grep '^125 '
rust-core-test:
name: Run rust core tests
runs-on: ubuntu-24.04
needs: basic-integrated-verification
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Run unit tests of jieba_vim_rs_test
shell: bash
run: cargo test -r --manifest-path rust_backend/jieba_vim_rs_test/Cargo.toml
- name: Run unit tests of jieba_vim_rs_core
shell: bash
run: cargo test -r --manifest-path rust_backend/jieba_vim_rs_core/Cargo.toml
- uses: actions/download-artifact@v7
with:
path: rust_backend/jieba_vim_rs_core
pattern: rust-core-test-info-*
merge-multiple: true
- name: Run Golden Master integration tests of jieba_vim_rs_core
shell: bash
run: |
cd rust_backend/jieba_vim_rs_core
cargo test -r --test golden_master -- -q unit-*.jsonl
coverage:
name: Test coverage
runs-on: ubuntu-24.04
needs: rust-core-test
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo-tarpaulin
id: cache-cargo-tarpaulin
uses: actions/cache@v5
with:
path: ~/.cargo/bin/cargo-tarpaulin
key: cargo-tarpaulin
- name: Install cargo-tarpaulin
if: steps.cache-cargo-tarpaulin.outputs.cache-hit != 'true'
shell: bash
run: cargo install cargo-tarpaulin
- name: Show cargo-tarpaulin version
shell: bash
run: cargo tarpaulin --version
- uses: actions/download-artifact@v7
with:
path: rust_backend/jieba_vim_rs_core/golden_master_records
pattern: rust-core-test-info-*
merge-multiple: true
- name: Run cargo-tarpaulin
shell: bash
run: |
cd rust_backend
# The working directory in the following command is:
# rust_backend/jieba_vim_rs_core.
GOLDEN_MASTER_DIR=golden_master_records \
cargo tarpaulin --release --out Xml \
--engine Llvm \
--no-dead-code \
--exclude-files 'jieba_vim_rs_test/*' \
--exclude-files 'jieba_vim_rs_core/tests/*' \
--exclude-files 'jieba_vim_rs_binding_lua51/*' \
--exclude-files 'jieba_vim_rs_binding_py3/*' \
--packages jieba_vim_rs_core
- uses: codecov/codecov-action@v7
with:
files: rust_backend/cobertura.xml
disable_search: true
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}