Fangjun Kuang
Committed by GitHub

Fix CI tests (#804)

  1 +name: run-python-test-macos
  2 +
  3 +on:
  4 + push:
  5 + branches:
  6 + - master
  7 + paths:
  8 + - '.github/workflows/run-python-test-macos.yaml'
  9 + - '.github/scripts/test-python.sh'
  10 + - 'CMakeLists.txt'
  11 + - 'cmake/**'
  12 + - 'sherpa-onnx/csrc/*'
  13 + - 'python-api-examples/**'
  14 + pull_request:
  15 + branches:
  16 + - master
  17 + paths:
  18 + - '.github/workflows/run-python-test-macos.yaml'
  19 + - '.github/scripts/test-python.sh'
  20 + - 'CMakeLists.txt'
  21 + - 'cmake/**'
  22 + - 'sherpa-onnx/csrc/*'
  23 + - 'python-api-examples/**'
  24 + workflow_dispatch:
  25 +
  26 +concurrency:
  27 + group: run-python-test-macos-${{ github.ref }}
  28 + cancel-in-progress: true
  29 +
  30 +permissions:
  31 + contents: read
  32 +
  33 +jobs:
  34 + run-python-test:
  35 + name: ${{ matrix.os }} ${{ matrix.python-version }}
  36 + runs-on: ${{ matrix.os }}
  37 + strategy:
  38 + fail-fast: false
  39 + matrix:
  40 + # See https://github.com/actions/runner-images
  41 + # macos-14 is for arm64
  42 + # macos-14-large is for x64
  43 + include:
  44 + - os: macos-11
  45 + python-version: "3.7"
  46 +
  47 + - os: macos-12
  48 + python-version: "3.8"
  49 +
  50 + - os: macos-13
  51 + python-version: "3.9"
  52 + - os: macos-13
  53 + python-version: "3.10"
  54 + - os: macos-13
  55 + python-version: "3.11"
  56 +
  57 + - os: macos-14
  58 + python-version: "3.12"
  59 +
  60 + steps:
  61 + - uses: actions/checkout@v4
  62 + with:
  63 + fetch-depth: 0
  64 +
  65 + - name: Display OS version
  66 + shell: bash
  67 + run: |
  68 + uname -a
  69 + sw_vers
  70 +
  71 + - name: ccache
  72 + uses: hendrikmuhs/ccache-action@v1.2
  73 + with:
  74 + key: ${{ matrix.os }}-python-${{ matrix.python-version }}
  75 +
  76 + - name: Setup Python
  77 + uses: actions/setup-python@v5
  78 + with:
  79 + python-version: ${{ matrix.python-version }}
  80 +
  81 + - name: Install Python dependencies
  82 + shell: bash
  83 + run: |
  84 + python3 -m pip install --upgrade pip numpy pypinyin sentencepiece>=0.1.96 soundfile
  85 +
  86 + - name: Install sherpa-onnx
  87 + shell: bash
  88 + run: |
  89 + export CMAKE_CXX_COMPILER_LAUNCHER=ccache
  90 + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
  91 + cmake --version
  92 +
  93 + python3 -m pip install --verbose .
  94 +
  95 + - name: Test sherpa-onnx
  96 + shell: bash
  97 + run: |
  98 + export OS=${{ matrix.os }}
  99 + .github/scripts/test-python.sh
  100 + .github/scripts/test-speaker-recognition-python.sh
  101 +
  102 + - uses: actions/upload-artifact@v4
  103 + with:
  104 + name: tts-generated-test-files-${{ matrix.os }}-${{ matrix.python-version }}
  105 + path: tts
@@ -30,9 +30,6 @@ concurrency: @@ -30,9 +30,6 @@ concurrency:
30 permissions: 30 permissions:
31 contents: read 31 contents: read
32 32
33 -env:  
34 - SCCACHE_GHA_ENABLED: "true"  
35 -  
36 jobs: 33 jobs:
37 run-python-test: 34 run-python-test:
38 name: ${{ matrix.os }} ${{ matrix.python-version }} 35 name: ${{ matrix.os }} ${{ matrix.python-version }}
@@ -40,33 +37,37 @@ jobs: @@ -40,33 +37,37 @@ jobs:
40 strategy: 37 strategy:
41 fail-fast: false 38 fail-fast: false
42 matrix: 39 matrix:
43 - os: [ubuntu-latest, macos-latest, windows-latest]  
44 - python-version: ["3.7", "3.8", "3.9", "3.10","3.11", "3.12"]  
45 - exclude:  
46 - - os: macos-latest 40 + include:
  41 + - os: ubuntu-20.04
  42 + python-version: "3.7"
  43 + - os: ubuntu-20.04
  44 + python-version: "3.8"
  45 + - os: ubuntu-20.04
47 python-version: "3.9" 46 python-version: "3.9"
48 - - os: macos-latest 47 +
  48 + - os: ubuntu-22.04
49 python-version: "3.10" 49 python-version: "3.10"
50 - # - os: windows-latest  
51 - # python-version: "3.12" 50 + - os: ubuntu-22.04
  51 + python-version: "3.11"
  52 + - os: ubuntu-22.04
  53 + python-version: "3.12"
52 54
53 steps: 55 steps:
54 - uses: actions/checkout@v4 56 - uses: actions/checkout@v4
55 with: 57 with:
56 fetch-depth: 0 58 fetch-depth: 0
57 59
  60 + - name: Display OS version
  61 + shell: bash
  62 + run: |
  63 + uname -a
  64 + find "/etc" -maxdepth 1 -type f -name "*version" -exec head -n 100 {} \;
  65 +
58 - name: ccache 66 - name: ccache
59 - if: matrix.os != 'windows-latest'  
60 uses: hendrikmuhs/ccache-action@v1.2 67 uses: hendrikmuhs/ccache-action@v1.2
61 with: 68 with:
62 key: ${{ matrix.os }}-python-${{ matrix.python-version }} 69 key: ${{ matrix.os }}-python-${{ matrix.python-version }}
63 70
64 - - name: Run sccache-cache  
65 - if: matrix.os == 'windows-latest'  
66 - uses: mozilla-actions/sccache-action@v0.0.4  
67 - with:  
68 - version: "v0.7.4"  
69 -  
70 - name: Setup Python 71 - name: Setup Python
71 uses: actions/setup-python@v5 72 uses: actions/setup-python@v5
72 with: 73 with:
@@ -76,31 +77,108 @@ jobs: @@ -76,31 +77,108 @@ jobs:
76 shell: bash 77 shell: bash
77 run: | 78 run: |
78 python3 -m pip install --upgrade pip numpy pypinyin sentencepiece>=0.1.96 soundfile 79 python3 -m pip install --upgrade pip numpy pypinyin sentencepiece>=0.1.96 soundfile
  80 + python3 -m pip install wheel twine setuptools
79 81
80 - - name: Install sherpa-onnx  
81 - if: matrix.os != 'windows-latest' 82 + - name: Install ninja
  83 + shell: bash
  84 + run: |
  85 + sudo apt-get install ninja-build
  86 +
  87 + - name: Display ninja version
  88 + shell: bash
  89 + run: |
  90 + ninja --version
  91 + ninja --help || true
  92 + which ninja
  93 +
  94 + - name: Display site packages dir
  95 + shell: bash
  96 + run: |
  97 + python3 -c 'import site; print(site.getsitepackages())'
  98 + p=$(python3 -c 'import site; print(site.getsitepackages())')
  99 + echo "p: $p"
  100 +
  101 + - name: Install patchelf
  102 + shell: bash
  103 + run: |
  104 + sudo apt-get update -q
  105 + sudo apt-get install -q -y patchelf
  106 + patchelf --help
  107 +
  108 + - name: Build sherpa-onnx
82 shell: bash 109 shell: bash
83 run: | 110 run: |
84 export CMAKE_CXX_COMPILER_LAUNCHER=ccache 111 export CMAKE_CXX_COMPILER_LAUNCHER=ccache
85 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" 112 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
86 cmake --version 113 cmake --version
  114 + export SHERPA_ONNX_CMAKE_ARGS="-G Ninja -DCMAKE_BUILD_TYPE=Release"
  115 + export SHERPA_ONNX_MAKE_ARGS="-j 6"
87 116
88 - python3 -m pip install --verbose . 117 + python3 setup.py bdist_wheel
  118 +
  119 + - name: Patch wheels
  120 + shell: bash
  121 + run: |
  122 + mkdir ./dist2
  123 + sudo ./scripts/wheel/patch_wheel.py --in-dir ./dist --out-dir ./dist2
89 124
90 - name: Install sherpa-onnx 125 - name: Install sherpa-onnx
91 - if: matrix.os == 'windows-latest'  
92 shell: bash 126 shell: bash
93 run: | 127 run: |
94 - cmake --version  
95 - export SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER_LAUNCHER=sccache"  
96 - echo "SHERPA_ONNX_CMAKE_ARGS: ${SHERPA_ONNX_CMAKE_ARGS}" 128 + ls -lh dist2
  129 +
  130 + python3 -m pip install ./dist2/*.whl
  131 +
  132 + - uses: actions/upload-artifact@v4
  133 + with:
  134 + name: ${{ matrix.os }}-${{ matrix.python-version }}-whl
  135 + path: ./dist
97 136
98 - python3 -m pip install --verbose . 137 + - uses: actions/upload-artifact@v4
  138 + with:
  139 + name: ${{ matrix.os }}-${{ matrix.python-version }}-whl-patched
  140 + path: ./dist2
  141 +
  142 + - name: Show dependencies
  143 + shell: bash
  144 + run: |
  145 + cd dist
  146 + mkdir t
  147 + cd t
  148 + unzip ../*.whl
  149 + readelf -d _sherpa_onnx*.so
  150 +
  151 + echo "----"
  152 +
  153 + readelf -d sherpa_onnx-*.data/data/bin/sherpa-onnx
  154 +
  155 + - name: Show dependencies (patched)
  156 + shell: bash
  157 + run: |
  158 + cd dist2
  159 + mkdir t
  160 + cd t
  161 + unzip ../*.whl
  162 + readelf -d _sherpa_onnx*.so
  163 +
  164 + echo "----"
  165 +
  166 + readelf -d sherpa_onnx-*.data/data/bin/sherpa-onnx
99 167
100 - name: Test sherpa-onnx 168 - name: Test sherpa-onnx
101 shell: bash 169 shell: bash
102 run: | 170 run: |
103 export OS=${{ matrix.os }} 171 export OS=${{ matrix.os }}
  172 +
  173 + p=$(python3 -c 'import site; print(site.getsitepackages()[0])')
  174 + echo "p: $p"
  175 + p=$p/sherpa_onnx/lib
  176 + echo "p: $p"
  177 + ls -lh $p
  178 +
  179 + export LD_LIBRARY_PATH=$p:$LD_LIBRARY_PATH
  180 + echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
  181 +
104 .github/scripts/test-python.sh 182 .github/scripts/test-python.sh
105 .github/scripts/test-speaker-recognition-python.sh 183 .github/scripts/test-speaker-recognition-python.sh
106 184
@@ -35,8 +35,50 @@ jobs: @@ -35,8 +35,50 @@ jobs:
35 strategy: 35 strategy:
36 fail-fast: false 36 fail-fast: false
37 matrix: 37 matrix:
38 - os: [ubuntu-latest, macos-latest, windows-latest]  
39 - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] 38 + # See https://github.com/actions/runner-images
  39 + include:
  40 + - os: ubuntu-20.04
  41 + python-version: "3.7"
  42 + - os: ubuntu-20.04
  43 + python-version: "3.8"
  44 + - os: ubuntu-20.04
  45 + python-version: "3.9"
  46 + - os: ubuntu-22.04
  47 + python-version: "3.10"
  48 + - os: ubuntu-22.04
  49 + python-version: "3.11"
  50 + - os: ubuntu-22.04
  51 + python-version: "3.12"
  52 +
  53 + - os: macos-11
  54 + python-version: "3.7"
  55 +
  56 + - os: macos-12
  57 + python-version: "3.8"
  58 +
  59 + - os: macos-13
  60 + python-version: "3.9"
  61 + - os: macos-13
  62 + python-version: "3.10"
  63 + - os: macos-13
  64 + python-version: "3.11"
  65 +
  66 + - os: macos-14
  67 + python-version: "3.12"
  68 +
  69 + - os: windows-2019
  70 + python-version: "3.7"
  71 + - os: windows-2019
  72 + python-version: "3.8"
  73 + - os: windows-2019
  74 + python-version: "3.9"
  75 +
  76 + - os: windows-2022
  77 + python-version: "3.10"
  78 + - os: windows-2022
  79 + python-version: "3.11"
  80 + - os: windows-2022
  81 + python-version: "3.12"
40 82
41 steps: 83 steps:
42 - uses: actions/checkout@v4 84 - uses: actions/checkout@v4
@@ -28,11 +28,50 @@ jobs: @@ -28,11 +28,50 @@ jobs:
28 strategy: 28 strategy:
29 fail-fast: false 29 fail-fast: false
30 matrix: 30 matrix:
31 - os: [ubuntu-latest, windows-latest, macos-latest]  
32 - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]  
33 - exclude:  
34 - - os: macos-latest 31 + # See https://github.com/actions/runner-images
  32 + include:
  33 + - os: ubuntu-20.04
35 python-version: "3.7" 34 python-version: "3.7"
  35 + - os: ubuntu-20.04
  36 + python-version: "3.8"
  37 + - os: ubuntu-20.04
  38 + python-version: "3.9"
  39 + - os: ubuntu-22.04
  40 + python-version: "3.10"
  41 + - os: ubuntu-22.04
  42 + python-version: "3.11"
  43 + - os: ubuntu-22.04
  44 + python-version: "3.12"
  45 +
  46 + - os: macos-11
  47 + python-version: "3.7"
  48 +
  49 + - os: macos-12
  50 + python-version: "3.8"
  51 +
  52 + - os: macos-13
  53 + python-version: "3.9"
  54 + - os: macos-13
  55 + python-version: "3.10"
  56 + - os: macos-13
  57 + python-version: "3.11"
  58 +
  59 + - os: macos-14
  60 + python-version: "3.12"
  61 +
  62 + - os: windows-2019
  63 + python-version: "3.7"
  64 + - os: windows-2019
  65 + python-version: "3.8"
  66 + - os: windows-2019
  67 + python-version: "3.9"
  68 +
  69 + - os: windows-2022
  70 + python-version: "3.10"
  71 + - os: windows-2022
  72 + python-version: "3.11"
  73 + - os: windows-2022
  74 + python-version: "3.12"
36 75
37 steps: 76 steps:
38 - uses: actions/checkout@v4 77 - uses: actions/checkout@v4
@@ -35,8 +35,8 @@ jobs: @@ -35,8 +35,8 @@ jobs:
35 strategy: 35 strategy:
36 fail-fast: false 36 fail-fast: false
37 matrix: 37 matrix:
38 - os: [ubuntu-latest, windows-latest, macos-latest]  
39 - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] 38 + os: [ubuntu-20.04, ubuntu-22.04, windows-latest, macos-latest, macos-14]
  39 + python-version: ["3.10"]
40 model_type: ["transducer", "paraformer", "nemo_ctc", "whisper", "tdnn"] 40 model_type: ["transducer", "paraformer", "nemo_ctc", "whisper", "tdnn"]
41 41
42 steps: 42 steps:
@@ -35,8 +35,8 @@ jobs: @@ -35,8 +35,8 @@ jobs:
35 strategy: 35 strategy:
36 fail-fast: false 36 fail-fast: false
37 matrix: 37 matrix:
38 - os: [ubuntu-latest, windows-latest, macos-latest]  
39 - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] 38 + os: [ubuntu-20.04, ubuntu-22.04, windows-latest, macos-latest, macos-14]
  39 + python-version: ["3.10"]
40 model_type: ["transducer", "paraformer", "zipformer2-ctc"] 40 model_type: ["transducer", "paraformer", "zipformer2-ctc"]
41 41
42 steps: 42 steps:
@@ -180,13 +180,20 @@ class BuildExtension(build_ext): @@ -180,13 +180,20 @@ class BuildExtension(build_ext):
180 print('Setting make_args to "-j4"') 180 print('Setting make_args to "-j4"')
181 make_args = "-j4" 181 make_args = "-j4"
182 182
183 - build_cmd = f"""  
184 - cd {self.build_temp} 183 + if "-G Ninja" in cmake_args:
  184 + build_cmd = f"""
  185 + cd {self.build_temp}
  186 + cmake {cmake_args} {sherpa_onnx_dir}
  187 + ninja {make_args} install
  188 + """
  189 + else:
  190 + build_cmd = f"""
  191 + cd {self.build_temp}
185 192
186 - cmake {cmake_args} {sherpa_onnx_dir} 193 + cmake {cmake_args} {sherpa_onnx_dir}
187 194
188 - make {make_args} install/strip  
189 - """ 195 + make {make_args} install/strip
  196 + """
190 print(f"build command is:\n{build_cmd}") 197 print(f"build command is:\n{build_cmd}")
191 198
192 ret = os.system(build_cmd) 199 ret = os.system(build_cmd)