buzz/.github/workflows/ci.yml
2025-08-30 10:48:03 +00:00

399 lines
12 KiB
YAML

name: CI
on:
push:
branches:
- main
tags:
- "*"
paths-ignore:
- '**/*.po'
- '**/*.mo'
- 'locales/**'
pull_request:
paths-ignore:
- '**/*.po'
- '**/*.mo'
- 'locales/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ${{ matrix.os }}
env:
BUZZ_DISABLE_TELEMETRY: true
strategy:
fail-fast: false
matrix:
include:
- os: macos-13
- os: macos-latest
- os: windows-latest
- os: ubuntu-22.04
- os: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-python@v5
with:
python-version: "3.11.9"
- name: Install Poetry Action
uses: snok/install-poetry@v1.3.1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/poetry.lock') }}
- name: Load cached Whisper models
id: cached-whisper-models
uses: actions/cache@v4
with:
path: |
~/Library/Caches/Buzz
~/.cache/whisper
~/.cache/huggingface
~/AppData/Local/Buzz/Buzz/Cache
key: whisper-models
- uses: AnimMouse/setup-ffmpeg@v1.2.1
id: setup-ffmpeg
with:
version: ${{ matrix.os == 'macos-13' && '7.1.1' || matrix.os == 'macos-latest' && '71' || '7.1' }}
- name: Test ffmpeg
run: ffmpeg -i ./testdata/audio-long.mp3 ./testdata/audio-long.wav
- name: Downgrade torch for Intel macOS
run: |
poetry add torch==2.2.2 torchaudio==2.2.2
if: "matrix.os == 'macos-13'"
# Should be removed with next update to whisper.cpp
- name: Downgrade Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.0.0'
if: matrix.os == 'macos-latest'
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
if: runner.os == 'Windows'
- name: Install apt dependencies
run: |
sudo apt-get update
if [ "$(lsb_release -rs)" != "24.04" ]; then
sudo apt-get install libegl1-mesa
fi
sudo apt-get install libyaml-dev libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libxcb-cursor0 libportaudio2 gettext libpulse0 libgl1-mesa-dev
if: "startsWith(matrix.os, 'ubuntu-')"
- name: Install Vulkan SDK
uses: humbletim/install-vulkan-sdk@v1.2
with:
version: 1.4.309.0
cache: true
- name: Install dependencies
run: poetry install
- name: Test
run: |
poetry run make test
shell: bash
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v4
with:
flags: ${{ runner.os }}
token: ${{ secrets.CODECOV_TOKEN }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
env:
BUZZ_DISABLE_TELEMETRY: true
strategy:
fail-fast: false
matrix:
include:
- os: macos-13
- os: macos-latest
- os: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-python@v5
with:
python-version: "3.11.9"
- name: Install Poetry Action
uses: snok/install-poetry@v1.3.1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/poetry.lock') }}
- uses: AnimMouse/setup-ffmpeg@v1.2.1
id: setup-ffmpeg
with:
version: ${{ matrix.os == 'macos-13' && '7.1.1' || matrix.os == 'macos-latest' && '71' || '7.1' }}
- name: Install Vulkan SDK
uses: humbletim/install-vulkan-sdk@v1.2
with:
version: 1.4.309.0
cache: true
- name: Install CUDA torch for Windows
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
poetry source add --priority=supplemental torch https://download.pytorch.org/whl/cu128
poetry source add --priority=supplemental nvidia https://pypi.ngc.nvidia.com
poetry add msvc-runtime
poetry add torch==2.7.1+cu128 torchaudio==2.7.1+cu128
poetry add nvidia-cublas-cu12==12.8.3.14 nvidia-cuda-cupti-cu12==12.8.57 nvidia-cuda-nvrtc-cu12==12.8.61 nvidia-cuda-runtime-cu12==12.8.57 nvidia-cudnn-cu12==9.7.1.26 nvidia-cufft-cu12==11.3.3.41 nvidia-curand-cu12==10.3.9.55 nvidia-cusolver-cu12==11.7.2.55 nvidia-cusparse-cu12==12.5.7.53 nvidia-cusparselt-cu12==0.6.3 nvidia-nvjitlink-cu12==12.8.61 nvidia-nvtx-cu12==12.8.55
echo yes | poetry cache clear --all .
fi
shell: bash
- name: Downgrade torch and ctranslate for Intel macOS
run: |
poetry add torch==2.2.2 torchaudio==2.2.2 ctranslate2==4.3.1
if: "matrix.os == 'macos-13'"
# Should be removed with next update to whisper.cpp
- name: Downgrade Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.0.0'
if: matrix.os == 'macos-latest'
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
if: runner.os == 'Windows'
- name: Install dependencies
run: poetry install
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0"
bundler-cache: true
if: "startsWith(matrix.os, 'ubuntu-')"
- name: Install apt dependencies
run: |
sudo apt-get update
if [ "$(lsb_release -rs)" != "24.04" ]; then
sudo apt-get install libegl1-mesa
fi
sudo apt-get install libyaml-dev libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-shape0 libxcb-cursor0 libportaudio2 gettext libpulse0 libgl1-mesa-dev
if: "startsWith(matrix.os, 'ubuntu-')"
- name: Install FPM
run: gem install fpm
if: "startsWith(matrix.os, 'ubuntu-')"
- name: Clear space on Windows
if: runner.os == 'Windows'
run: |
rm 'C:\Android\android-sdk\' -r -force
rm 'C:\Program Files (x86)\Google\' -r -force
rm 'C:\tools\kotlinc\' -r -force
rm 'C:\tools\php\' -r -force
rm 'C:\selenium\' -r -force
shell: pwsh
- name: Bundle
run: |
if [ "$RUNNER_OS" == "macOS" ]; then
brew install create-dmg
sudo pkill -9 XProtect >/dev/null || true;
while pgrep XProtect; do sleep 3; done;
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
xcrun notarytool store-credentials --apple-id "$APPLE_ID" --password "$APPLE_APP_PASSWORD" --team-id "$APPLE_TEAM_ID" notarytool --validate
poetry run make bundle_mac
elif [ "$RUNNER_OS" == "Windows" ]; then
cp -r ./dll_backup ./buzz/
poetry run make bundle_windows
fi
env:
BUZZ_CODESIGN_IDENTITY: ${{ secrets.BUZZ_CODESIGN_IDENTITY }}
BUZZ_KEYCHAIN_NOTARY_PROFILE: ${{ secrets.BUZZ_KEYCHAIN_NOTARY_PROFILE }}
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
shell: bash
- uses: actions/upload-artifact@v4
with:
name: Buzz-${{ runner.os }}-${{ runner.arch }}
path: |
dist/Buzz*-windows.exe
dist/Buzz*-windows-*.bin
dist/Buzz*-mac.dmg
build_wheels:
runs-on: ${{ matrix.os }}
env:
BUZZ_DISABLE_TELEMETRY: true
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
# Should be removed with next update to whisper.cpp
- name: Downgrade Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.0.0'
if: matrix.os == 'macos-latest'
- name: Build wheels
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9,<3.13"
CIBW_SKIP: "cp313-* cp314-*"
CIBW_ARCHS_WINDOWS: "auto64"
CIBW_ARCHS_MACOS: "auto64"
CIBW_ARCHS_LINUX: "auto64"
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
publish_pypi:
needs: [build_wheels, test]
runs-on: ubuntu-latest
env:
BUZZ_DISABLE_TELEMETRY: true
environment: pypi
permissions:
id-token: write
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
password: ${{ secrets.PYPI_TOKEN }}
release:
runs-on: ${{ matrix.os }}
env:
BUZZ_DISABLE_TELEMETRY: true
strategy:
fail-fast: false
matrix:
include:
- os: macos-13
- os: macos-latest
- os: windows-latest
needs: [build, test]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/download-artifact@v4
with:
name: Buzz-${{ runner.os }}-${{ runner.arch }}
- name: Rename .dmg files
if: runner.os == 'macOS'
run: |
for file in Buzz*.dmg; do
mv "$file" "${file%.dmg}-${{ runner.arch }}.dmg"
done
- name: Install Poetry Action
uses: snok/install-poetry@v1.3.1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
Buzz*-unix.tar.gz
Buzz*-windows.exe
Buzz*-mac.dmg
deploy_brew_cask:
runs-on: macos-latest
env:
BUZZ_DISABLE_TELEMETRY: true
needs: [release]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Poetry Action
uses: snok/install-poetry@v1.3.1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Upload to Brew
run: make upload_brew
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}