-
Notifications
You must be signed in to change notification settings - Fork 120
341 lines (320 loc) · 12.5 KB
/
test.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
name: test workflow
on:
push:
pull_request:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
# 簡易テストとするかどうか。workflow_dispatch以外は簡易テストとする
IS_SIMPLE_TEST: ${{ github.event_name != 'workflow_dispatch' }}
defaults:
run:
shell: bash
jobs:
shellcheck:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Update ShellCheck
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: ShellCheck
run: git ls-files | grep -E '\.(ba)?sh' | xargs shellcheck
actionlint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
# ShellCheckとPyflakesをインストールしておくと、shell: bashとshell: pythonのコードを検査してくれるようになる
#
# 参考:
# - https://github.com/rhysd/actionlint/blob/main/docs/checks.md#shellcheck-integration-for-run
# - https://github.com/rhysd/actionlint/blob/main/docs/checks.md#pyflakes-integration-for-run
- name: Update ShellCheck
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Pyflakes
run: pip install 'pyflakes>3,<4'
- name: actionlint
run: |
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
./actionlint -color
validate-cargo-lock:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
- name: Validate Cargo.lock
run: cargo metadata --locked --format-version 1 > /dev/null
rust-lint:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
with:
components: clippy,rustfmt
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
- uses: Swatinem/rust-cache@v2
- run: cargo clippy -vv --all-features --tests -- -D clippy::all -D warnings --no-deps
- run: cargo clippy -vv --all-features -- -D clippy::all -D warnings --no-deps
- run: cargo fmt -- --check
rust-unit-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
- uses: Swatinem/rust-cache@v2
with:
key: "cargo-unit-test-cache"
- name: Run cargo unit test
run: RUST_BACKTRACE=full cargo test --lib --bins -vv --features , -- --include-ignored
- name: Run cargo documentation test
run: RUST_BACKTRACE=full cargo test --doc -vv
rust-integration-test-strategy-matrix: # 実行対象の条件をフィルタリングする
runs-on: ubuntu-latest
outputs:
includes: ${{ steps.strategy-matrix.outputs.includes }}
steps:
- name: declare strategy matrix
id: strategy-matrix
run: |
includes='[
{ "os": "windows-2019", "features": "", "can_skip_in_simple_test": true },
{ "os": "windows-2022", "features": "", "can_skip_in_simple_test": true },
{ "os": "windows-2019", "features": "directml", "can_skip_in_simple_test": false },
{ "os": "windows-2022", "features": "directml", "can_skip_in_simple_test": true },
{ "os": "macos-11", "features": "", "can_skip_in_simple_test": false },
{ "os": "macos-12", "features": "", "can_skip_in_simple_test": true },
{ "os": "ubuntu-20.04", "features": "", "can_skip_in_simple_test": false },
{ "os": "ubuntu-22.04", "features": "", "can_skip_in_simple_test": true }
]'
# FIXME: composite action に切り出す
if ${{ env.IS_SIMPLE_TEST }}; then
includes=$(echo "$includes" | jq -c '[.[] | select(.can_skip_in_simple_test == false)]')
fi
includes=$(echo "$includes" | jq -c '[.[] | del(.can_skip_in_simple_test)]')
echo "includes=${includes}" >> "$GITHUB_OUTPUT"
rust-integration-test:
needs: rust-integration-test-strategy-matrix
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.rust-integration-test-strategy-matrix.outputs.includes) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
- uses: Swatinem/rust-cache@v2
with:
key: "cargo-integration-test-cache-${{ matrix.features }}-${{ matrix.os }}"
- name: Run cargo integration test
run: RUST_BACKTRACE=full cargo test --test "*" -vv --features ,${{ matrix.features }} -- --include-ignored
c-header:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Extract the version of cbindgen that xtask depends on
id: cbindgen-version
run: |
metadata=$(cargo metadata --format-version 1)
version=$(
jq -r '
.workspace_members as $workspace_members
| (.packages[] | select(.name == "xtask").id | select(. as $id | $workspace_members | index($id))) as $xtask
| (.resolve.nodes[] | select(.id == $xtask).deps[] | select(.name == "cbindgen").pkg) as $cbindgen
| .packages[] | select(.id == $cbindgen).version
' <<< "$metadata"
)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Install cbindgen v${{ steps.cbindgen-version.outputs.version }}
run: |
cargo binstall \
cbindgen@${{ steps.cbindgen-version.outputs.version }} \
--pkg-url 'https://github.com/alsuren/cargo-quickinstall/releases/download/{ name }-{ version }-{ target }/{ name }-{ version }-{ target }.tar.gz' \
--pkg-fmt tgz \
--bin-dir '{ bin }{ binary-ext }' \
--no-confirm \
--log-level debug
- name: Assert voicevox_core.h is up to date
run: |
cbindgen --crate voicevox_core_c_api -o /tmp/voicevox_core.h
diff -u --color=always {/tmp,./crates/voicevox_core_c_api/include}/voicevox_core.h
- name: Assert `cargo xtask update-c-header --verify` succeeds
run: |
cargo xtask update-c-header --verify
git diff
build-unix-cpp-example:
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
artifact_name: osx-x64-cpu-cpp-shared
- os: ubuntu-latest
artifact_name: linux-x64-cpu-cpp-shared
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: build voicevox_core_c_api
run: cargo build -p voicevox_core_c_api -vv
- name: 必要なfileをunix用exampleのディレクトリに移動させる
run: |
mkdir -p example/cpp/unix/voicevox_core/
cp -v crates/voicevox_core_c_api/include/voicevox_core.h example/cpp/unix/voicevox_core/
cp -v target/debug/libvoicevox_core.{so,dylib} example/cpp/unix/voicevox_core/ || true
cp -v target/debug/libonnxruntime.so.* example/cpp/unix/voicevox_core/ || true
cp -v target/debug/libonnxruntime.*.dylib example/cpp/unix/voicevox_core/ || true
- if: startsWith(matrix.os, 'mac')
uses: jwlawson/[email protected]
- name: Install build dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y cmake
- name: Build
run: |
cd example/cpp/unix
cmake -S . -B build
cmake --build build
build-windows-cpp-example:
strategy:
fail-fast: false
runs-on: windows-latest
env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: example\cpp\windows\windows_example.sln
# Configuration type to build.
BUILD_CONFIGURATION: Debug
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: build voicevox_core_c_api
run: cargo build -p voicevox_core_c_api -vv
- name: 必要なfileをexampleのディレクトリに移動させる
run: |
mkdir -p example/cpp/windows/simple_tts/lib/x64
cp -v crates/voicevox_core_c_api/include/voicevox_core.h example/cpp/windows/simple_tts/
cp target/debug/voicevox_core.dll.lib example/cpp/windows/simple_tts/lib/x64/voicevox_core.lib
- name: Add MSBuild to PATH
uses: microsoft/[email protected]
- name: Restore NuGet packages
working-directory: ${{env.GITHUB_WORKSPACE}}
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
- name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}
build-and-test-python-api:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
- os: macos-latest
- os: ubuntu-latest
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: ./crates/voicevox_core_python_api
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
- run: |
pip install --upgrade poetry
poetry install --with dev --with test
- run: cargo build -p test_util -vv # build scriptにより/crates/test_util/data/の生成
- run: poetry run maturin build --locked
- run: poetry run maturin develop --locked
- name: 必要なDLLをコピーしてpytestを実行
run: |
cp -v ../../target/debug/onnxruntime.dll . || true
cp -v ../../target/debug/libonnxruntime.so.* . || true
cp -v ../../target/debug/libonnxruntime.*.dylib . || true
poetry run pytest
- name: Exampleを実行
run: |
for file in ../../example/python/run{,-asyncio}.py; do
poetry run python "$file" ../test_util/data/model/sample.vvm --dict-dir ../test_util/data/open_jtalk_dic_utf_8-1.11
done
build-and-test-java-api:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
- os: macos-latest
- os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: "11"
distribution: "adopt"
- name: Build
run: |
cargo build -p voicevox_core_java_api -vv
cargo build -p test_util -vv # build scriptにより/crates/test_util/data/の生成
- name: 必要なDLLをコピーしてテストを実行
working-directory: crates/voicevox_core_java_api
run: |
OS=$(tr '[:upper:]' '[:lower:]' <<<"$RUNNER_OS")
ARCH=$(tr '[:upper:]' '[:lower:]' <<<"$RUNNER_ARCH")
case "$RUNNER_OS" in
Windows)
DLL_NAME="voicevox_core_java_api.dll"
;;
macOS)
DLL_NAME="libvoicevox_core_java_api.dylib"
;;
Linux)
DLL_NAME="libvoicevox_core_java_api.so"
;;
*)
echo "Unsupported OS: $RUNNER_OS"
exit 1
;;
esac
TARGET_NAME="$OS-$ARCH"
mkdir -p "./lib/src/main/resources/dll/$TARGET_NAME"
cp -v "../../target/debug/$DLL_NAME" "./lib/src/main/resources/dll/$TARGET_NAME/$DLL_NAME"
echo "target = $TARGET_NAME, dll = $DLL_NAME"
./gradlew test --info