-
Notifications
You must be signed in to change notification settings - Fork 120
208 lines (199 loc) · 7.39 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
name: test workflow
on:
push:
branches:
- "*"
- "**/*"
pull_request:
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 --features onnxruntime/disable-sys-build-script --tests -- -D clippy::all -D warnings --no-deps
- run: cargo clippy -vv --all-features --features onnxruntime/disable-sys-build-script -- -D clippy::all -D warnings --no-deps
- run: cargo fmt -- --check
rust-test:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
features: ""
- os: windows-2022
features: ""
- os: windows-2019
features: directml
- os: windows-2022
features: directml
- os: macos-12
features: ""
- os: macos-13
features: ""
- os: ubuntu-20.04
features: ""
- os: ubuntu-22.04
features: ""
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:
# cargoのキャッシュが原因でテストが失敗する場合はバージョン部分をカウントアップすること
key: "v2-cargo-test-cache-${{ matrix.features }}-${{ matrix.os }}"
- name: Run cargo test
shell: bash
run: cargo test -vv --features ,${{ matrix.features }}
xtask-generate-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: Install cbindgen
uses: ./.github/actions/cargo-binstall-cbindgen
- name: Generate voicevox_core_1.h
run: cbindgen --crate voicevox_core_c_api -o ./voicevox_core_1.h
- name: Generate voicevox_core_2.h
run: cargo xtask generate-c-header -o ./voicevox_core_2.h
- name: Assert these header files are same
run: diff -u --color=always ./voicevox_core_{1,2}.h
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: Install cbindgen
uses: ./.github/actions/cargo-binstall-cbindgen
- name: build voicevox_core_c_api
run: cargo build -p voicevox_core_c_api -vv
- name: voicevox_core.hを生成
run: cbindgen --crate voicevox_core_c_api -o ./example/cpp/unix/voicevox_core/voicevox_core.h
- name: 必要なfileをunix用exampleのディレクトリに移動させる
run: |
mkdir -p example/cpp/unix/voicevox_core/
cp -v target/debug/libvoicevox_core.{so,dylib} example/cpp/unix/voicevox_core/ || true
cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/libonnxruntime.so.* example/cpp/unix/voicevox_core/ || true
cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/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')
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y cmake
- name: Build
shell: bash
run: |
cd example/cpp/unix
cmake -S . -B build
cmake --build build
build-python-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 Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Set up Rust
uses: ./.github/actions/rust-toolchain-from-file
- name: venv作成
uses: ./.github/actions/create-venv
- shell: bash
run: pip install -r ./crates/voicevox_core_python_api/requirements.txt
- shell: bash
run: cargo build -p voicevox_core_c_api -vv
- shell: bash
run: maturin build --manifest-path ./crates/voicevox_core_python_api/Cargo.toml --locked
- shell: bash
run: maturin develop --manifest-path ./crates/voicevox_core_python_api/Cargo.toml --locked
- name: 必要なDLLをカレントディレクトリにコピー
run: |
cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/onnxruntime.dll . || true
cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/libonnxruntime.so.* . || true
cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/libonnxruntime.*.dylib . || true
- name: '`maturin develop`でインストールした`voicevox_core_python_api`を実行'
shell: python
run: |
import voicevox_core
print(voicevox_core)
env:
CARGO_TERM_COLOR: always