-
Notifications
You must be signed in to change notification settings - Fork 110
190 lines (153 loc) · 5.33 KB
/
run-cpp-test.yaml
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
# Copyright 2022 Xiaomi Corp. (author: Fangjun Kuang)
# See ../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Run C++ tests
on:
push:
branches:
- master
paths:
- '.github/workflows/run-cpp-test.yaml'
- '.github/scripts/run-offline-transducer.sh'
- '.github/scripts/run-online-transducer.sh'
- '.github/scripts/run-offline-ctc.sh'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa/csrc/**'
- 'sherpa/cpp_api/**'
pull_request:
types: [labeled]
paths:
- '.github/workflows/run-cpp-test.yaml'
- '.github/scripts/run-offline-transducer.sh'
- '.github/scripts/run-online-transducer.sh'
- '.github/scripts/run-offline-ctc.sh'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa/csrc/**'
- 'sherpa/cpp_api/**'
concurrency:
group: run_cpp_tests-${{ github.ref }}
cancel-in-progress: true
jobs:
run_cpp_tests:
if: github.event.label.name == 'ready' || github.event.label.name == 'cpp' || github.event_name == 'push'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
torch: ["2.1.2"]
python-version: ["3.8"]
build_type: ["Release", "Debug"]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: ccache
uses: hendrikmuhs/ccache-action@v1.1
with:
key: ${{ matrix.os }}-${{ matrix.torch }}-${{ matrix.python-version }}-${{ matrix.build_type }}
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Display gcc version
if: startsWith(matrix.os, 'ubuntu')
run: |
gcc --version
- name: Display clang version
if: startsWith(matrix.os, 'macos')
run: |
clang --version
- name: Install PyTorch ${{ matrix.torch }}
shell: bash
run: |
sudo apt-get -qq install git-lfs tree sox
sox --version
sudo apt-get install -y libsnappy-dev libzzip-dev zlib1g-dev libboost-all-dev
python3 -m pip install --upgrade pip kaldi_native_io sentencepiece>=0.1.96
python3 -m pip install wheel twine typing_extensions
python3 -m pip install torch==${{ matrix.torch }} numpy -f https://download.pytorch.org/whl/cpu/torch_stable.html
python3 -m pip install k2==1.24.4.dev20231220+cpu.torch${{ matrix.torch }} -f https://k2-fsa.org/nightly/index.html
python3 -m pip install kaldifeat==1.25.3.dev20231221+cpu.torch${{ matrix.torch }} -f https://csukuangfj.github.io/kaldifeat/cpu.html
python3 -m torch.utils.collect_env
- name: Build sherpa
shell: bash
env:
BUILD_TYPE: ${{ matrix.build_type }}
run: |
echo "Build type: $BUILD_TYPE"
mkdir build
cd build
cmake \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DSHERPA_ENABLE_TESTS=ON ..
make -j4 VERBOSE=1
ls -lh lib
ls -lh bin
- name: Display dependencies
if: startsWith(matrix.os, 'ubuntu')
shell: bash
run: |
cd build
ldd lib/libsherpa_core.so
ldd bin/sherpa-offline
readelf -d lib/libsherpa_core.so
readelf -d bin/sherpa-offline
readelf -d bin/sherpa-online
- name: Display dependencies
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
cd build
otool -L lib/libsherpa_core.dylib
otool -l lib/libsherpa_core.dylib
otool -L bin/sherpa-offline
otool -l bin/sherpa-offline
otool -L bin/sherpa-online
otool -l bin/sherpa-online
- name: Test sherpa
shell: bash
run: |
cd build
# test_log
SHERPA_LOG_LEVEL=TRACE ./bin/test-log
SHERPA_LOG_LEVEL=DEBUG ./bin/test-log
SHERPA_LOG_LEVEL=INFO ./bin/test-log
SHERPA_LOG_LEVEL=WARNING ./bin/test-log
SHERPA_LOG_LEVEL=ERROR ./bin/test-log
ctest --verbose --output-on-failure -E py # exclude Python tests
- name: Display sherpa version
shell: bash
run: |
cd build
./bin/sherpa-version
./bin/sherpa-offline --help
- name: Run offline transducer
shell: bash
run: |
.github/scripts/run-offline-transducer.sh
- name: Run offline CTC
shell: bash
run: |
.github/scripts/run-offline-ctc.sh
- name: Run online transducer
shell: bash
run: |
.github/scripts/run-online-transducer.sh