1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [ "main" ]
6+ tags :
7+ - v*
8+ pull_request :
9+ branches : [ "main" ]
10+
11+ jobs :
12+ check-python-style :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - uses : actions/checkout@v4
16+ with :
17+ submodules : recursive
18+
19+ - name : Set up Python 3.9
20+ uses : actions/setup-python@v5
21+ with :
22+ python-version : 3.9
23+
24+ - name : Setup UV
25+ uses : astral-sh/setup-uv@v5
26+ with :
27+ version : " latest"
28+
29+ - name : Install dependencies
30+ run : |
31+ uv pip install --system black==24.* flake8==7.* flake8-pyproject==1.* isort==5.*
32+
33+ - name : Check code format with Black
34+ run : |
35+ black --check ctc_forced_aligner/*.py
36+
37+ - name : Check imports order with isort
38+ run : |
39+ isort --check-only ctc_forced_aligner/*.py
40+
41+ - name : Check code style with Flake8
42+ run : |
43+ flake8 ctc_forced_aligner/*.py
44+
45+ build-python-wheels :
46+ needs : [check-python-style]
47+ runs-on : ${{ matrix.os }}
48+ strategy :
49+ matrix :
50+ os : [ubuntu-20.04, windows-2019, macos-14]
51+ arch : [auto64]
52+ include :
53+ - os : ubuntu-20.04
54+ arch : aarch64
55+ - os : windows-2019
56+ arch : ARM64
57+
58+ steps :
59+ - uses : actions/checkout@v4
60+ with :
61+ submodules : recursive
62+
63+ - uses : docker/setup-qemu-action@v3
64+ if : ${{ matrix.arch == 'aarch64' }}
65+ name : Set up QEMU
66+
67+ - name : Setup UV
68+ uses : astral-sh/setup-uv@v5
69+ with :
70+ version : " latest"
71+
72+ - name : Build wheels
73+ 74+ with :
75+ output-dir : python/wheelhouse
76+ env :
77+ CIBW_MANYLINUX_X86_64_IMAGE : manylinux2014
78+ CIBW_MANYLINUX_AARCH64_IMAGE : manylinux2014
79+ CIBW_ARCHS : ${{ matrix.arch }}
80+ CIBW_SKIP : pp* *-musllinux_*
81+ CIBW_BUILD_FRONTEND : " build[uv]"
82+
83+ - name : Upload Python wheels
84+ uses : actions/upload-artifact@v4
85+ with :
86+ name : python-wheels-${{ runner.os }}-${{ matrix.arch }}
87+ path : python/wheelhouse
88+
89+ test-python-wheels :
90+ # We could test the Python wheels using cibuildwheel but we prefer to run the tests outside
91+ # the build environment to ensure wheels correctly embed all dependencies.
92+ needs : [build-python-wheels]
93+ runs-on : ${{ matrix.os }}
94+ strategy :
95+ matrix :
96+ python-version : ["3.9", "3.10", "3.11", "3.12"]
97+ os : [ubuntu-20.04, windows-2019, macos-14]
98+ arch : [auto64]
99+
100+ steps :
101+ - uses : actions/checkout@v4
102+ with :
103+ submodules : recursive
104+
105+ - name : Set up Python ${{ matrix.python-version }}
106+ uses : actions/setup-python@v5
107+ with :
108+ python-version : ${{ matrix.python-version }}
109+
110+ - name : Download Python wheels
111+ uses : actions/download-artifact@v4
112+ with :
113+ pattern : python-wheels-${{ runner.os }}-${{ matrix.arch }}
114+ merge-multiple : true
115+ path : wheels
116+
117+ - name : Setup UV
118+ uses : astral-sh/setup-uv@v5
119+ with :
120+ version : " latest"
121+
122+ - name : Install wheel
123+ shell : bash
124+ run : |
125+ wheel_name=$(find wheels -type f -name "*$(echo ${{ matrix.python-version }} | tr -d '.')*")
126+ uv pip install --system "pytest-xdist" "$wheel_name[dev]" --extra-index-url https://download.pytorch.org/whl/cpu
127+
128+ - name : Run tests
129+ shell : bash
130+ run : |
131+ pytest -v -n auto tests/
132+
133+ publish-python-wheels-on-pypi :
134+ needs : [test-python-wheels]
135+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
136+ runs-on : ubuntu-latest
137+ steps :
138+ - name : Download Python wheels
139+ uses : actions/download-artifact@v4
140+ with :
141+ pattern : python-wheels-*
142+ merge-multiple : true
143+ path : .
144+
145+ - name : Publish Python wheels to PyPI
146+ uses : pypa/gh-action-pypi-publish@release/v1
147+ with :
148+ user : __token__
149+ password : ${{ secrets.PYPI_API_TOKEN }}
150+ packages-dir : .
0 commit comments