-
Notifications
You must be signed in to change notification settings - Fork 17
382 lines (333 loc) · 12 KB
/
native.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
name: Native
on:
pull_request:
push:
branches:
- 'main'
tags:
- 'rustfst-v**'
schedule:
- cron: '0 9 * * *'
# This codes allows to stop the CI when a new commit has been pushed on the same PR or branch.
# It doesn't apply to branches.
# Ref https://docs.github.com/en/enterprise-cloud@latest/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
PYTHON_VERSION: 3.9
GIT_COMMITTER_NAME: garvys-ci-bot
GIT_COMMITTER_EMAIL: alexandre.caulier.a@gmail.com
jobs:
python-fmt:
name: Check python formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }} # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Check formatting
run: |
pip install black==22.3.0
python -m black --check . || fail "Format your code by running black ." 1
rust-fmt:
name: Check rust formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.78.0
components: rustfmt
- name: Cargo fmt check
run: cargo fmt --all -- --check
openfst:
name: Fetch or Build OpenFST
needs: [python-fmt, rust-fmt]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Cache Openfst build
id: cache
uses: actions/cache@v4
with:
path: openfst-1.7.2
key: ${{ runner.os }}-openfst-1.7.2-build
- name: Build Openfst if necessary
if: steps.cache.outputs.cache-hit != 'true'
run: ./build_openfst.sh
- uses: actions/upload-artifact@v4
with:
name: openfst-${{ runner.os }}
path: |
openfst-1.7.2/src/include/
openfst-1.7.2/lib/libfst.a
openfst-1.7.2/bin/
openfst-1.7.2/lib/
if-no-files-found: error
# generate-openfst-output:
# name: Generate OpenFST outputs on the Test Suite
# needs: openfst
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/download-artifact@v3
# with:
# name: openfst-${{ runner.os }}
# path: openfst-1.7.2
# - name: Generate outputs
# run: ./run_openfst.sh
# - uses: actions/upload-artifact@v3
# with:
# name: openfst-test-data
# path: |
# rustfst-tests-data/fst_*/*
# !rustfst-tests-data/fst_*/*.h
# rustfst-tests-data/symt_*/*
# !rustfst-tests-data/symt_*/*.h
# rustfst-tests-data/weights/*.json
rust-tests:
name: rust-tests
needs: openfst
strategy:
fail-fast: false
matrix:
rust: [1.74.0, stable]
os: [ubuntu-latest, macos-13]
cargo-args:
- --all --benches --examples --bins --tests
- --manifest-path rustfst/Cargo.toml --features "state-label-u32"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- uses: actions/download-artifact@v4
with:
name: openfst-${{ runner.os }}
path: openfst-1.7.2
- name: Generate outputs
run: ./run_openfst.sh
- name: Cargo test
run: cargo test ${{ matrix.cargo-args }}
rust-clippy:
name: rust-clippy
needs: openfst
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.78.0
components: clippy
- name: Cargo Clippy
run: cargo clippy -- -D warnings
rust-doc:
name: rust-doc
needs: openfst
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.78.0
- name: Cargo doc`
run: cargo doc --all --no-deps
rustfst-python-bench:
name: rustfst-python-bench
needs: openfst
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }} # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- uses: actions/download-artifact@v4
with:
name: openfst-${{ runner.os }}
path: openfst-1.7.2
- name: Generate outputs
run: ./run_openfst.sh
- name: Install Hyperfine MacOS
if: runner.os == 'macOS'
run: brew install hyperfine
- name: Install Hyperfine Linux
if: runner.os == 'Linux'
run: |
wget https://github.com/sharkdp/hyperfine/releases/download/v1.6.0/hyperfine_1.6.0_amd64.deb
sudo dpkg -i hyperfine_1.6.0_amd64.deb
- name: Build benchmark
run: ./build_bench.sh debug
- name: Test benchmark
run: |
chmod +x openfst-1.7.2/bin/fst*
python -m pip install -e rustfst-python-bench
python rustfst-python-bench/rustfst_python_bench/bench_all.py -w 1 -r 2 debug rustfst-tests-data/fst_003/raw_vector.fst report.md
python rustfst-python-bench/rustfst_python_bench/bench_all_detailed.py -w 1 -r 2 debug rustfst-tests-data/fst_003/raw_vector.fst report2.md
rustfst-python:
name: rustfst-python
needs: openfst
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }} # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Build rustfst-python
run: |
pip install pylint==2.6.0 pytest==6.2.5
pip install -r rustfst-python/requirements-setup.txt
pip install -e rustfst-python
- name: Test rustfst-python
run: python -m pytest -s --cache-clear --disable-warnings rustfst-python
python-doc:
name: python-doc
needs: openfst
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }} # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Build rustfst-python
run: |
pip install -r rustfst-python/requirements-setup.txt
pip install -e rustfst-python
- name: Install mkdocs
run: pip install -r rustfst-python/requirements-mkdocs.txt
- name: Test doc generation
run: |
cd rustfst-python
mkdocs build -s
publish-python-doc:
name: Publish rustfst-python's doc
needs: [ rust-clippy, rust-doc, rust-tests, rustfst-python-bench, rustfst-python, python-doc ]
runs-on: ubuntu-latest
if: github.event_name != 'schedule' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rustfst-v'))
permissions:
actions: write
contents: write
deployments: write
id-token: write
packages: write
pages: write
repository-projects: write
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: pip install -r rustfst-python/requirements-setup.txt
- run: pip install -e rustfst-python
- run: pip install -r rustfst-python/requirements-mkdocs.txt
- run: git config user.name ${{ env.GIT_COMMITTER_NAME }}
- run: git config user.email ${{ env.GIT_COMMITTER_EMAIL }}
- run: git fetch origin gh-pages --depth=1
- run: cd rustfst-python && mkdocs build -s
- name: Deploy Doc to latest
# if: github.ref == 'refs/heads/main'
run: cd rustfst-python && mike deploy --push latest
- name: Retrieve tag
uses: olegtarasov/get-tag@v2.1
id: tagName
if: startsWith(github.ref, 'refs/tags/rustfst-v')
- name: Deploy Doc to tag
if: startsWith(github.ref, 'refs/tags/rustfst-v')
run: cd rustfst-python && mike deploy --push $GIT_TAG_NAME
publish-rust-crate:
name: Publish Rust Crate to Crates.io
needs: [ rust-clippy, rust-doc, rust-tests, rustfst-python-bench, rustfst-python, python-doc ]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/rustfst-v')
steps:
- uses: actions/checkout@v4
- name: Install Rust Stable
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Publish rustfst
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cd rustfst
cargo publish
sleep 30
cd ..
- name: Publish rustfst-ffi
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cd rustfst-ffi
cargo publish
cd ..
publish-python-wheels:
name: Publish Python Wheels to PyPI
needs: [ rust-clippy, rust-doc, rust-tests, rustfst-python-bench, rustfst-python, python-doc ]
if: startsWith(github.ref, 'refs/tags/rustfst-v')
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-13
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }} # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Build and publish
env:
CIBW_SKIP: cp*-musllinux_i686
CIBW_ENVIRONMENT: PATH="$HOME/.cargo/bin:$PATH"
CIBW_ENVIRONMENT_PASS_LINUX: PATH="$HOME/.cargo/bin:$PATH"
CIBW_BEFORE_BUILD: "which rustup || curl https://sh.rustup.rs -sSf | sh -s -- -y;
. $HOME/.cargo/env; rustup toolchain add stable;
rustup default stable;"
CIBW_BEFORE_BUILD_MACOS: "rustup target add aarch64-apple-darwin;"
# Build `universal2` and `arm64` wheels on an Intel runner.
# Note that the `arm64` wheel and the `arm64` part of the `universal2`
# wheel cannot be tested in this configuration.
CIBW_ARCHS_MACOS: "x86_64 arm64"
# On an Linux Intel runner with qemu installed, build Intel and ARM wheels
CIBW_ARCHS_LINUX: "auto"
run: |
python3.9 -m pip install twine cibuildwheel==2.13.1
mkdir -p wheels
python3.9 -m cibuildwheel --output-dir wheels rustfst-python
python3.9 -m twine upload -u "__token__" -p ${{ secrets.PYPI_PASSWORD }} -r pypi --verbose wheels/*