refactor(backend): 启动环境初始化与资源项目化(零跨项目依赖)
- main.py:uv run main.py 一键启动——读取 backend/.env、TORCH_HOME/NLTK_DATA 指向项目内缓存、certifi SSL + NO_PROXY 网络直连、默认开启 s2s,启动横幅 - vendor/:补丁后 s2s 云化栈移入项目(backend/vendor/s2s-cloud),pyproject sources 改相对路径 - .gitignore:忽略 .torch-cache / nltk_data 缓存 - AGENTS.md:进程管理铁律(AI 不启动/重启服务,由用户操作)
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
ruff:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.0
|
||||
- uses: astral-sh/setup-uv@v8.2.0
|
||||
with:
|
||||
version: "latest"
|
||||
- run: uv sync --group dev
|
||||
- name: Ruff check
|
||||
run: uv run ruff check src/ tests/
|
||||
- name: Ruff format
|
||||
run: uv run ruff format --check src/ tests/
|
||||
|
||||
mypy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.0
|
||||
- uses: astral-sh/setup-uv@v8.2.0
|
||||
with:
|
||||
version: "latest"
|
||||
- run: uv sync --group dev
|
||||
- name: Mypy
|
||||
run: uv run mypy src/
|
||||
|
||||
pytest:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.0
|
||||
- uses: astral-sh/setup-uv@v8.2.0
|
||||
with:
|
||||
version: "latest"
|
||||
- run: uv sync --group dev
|
||||
- name: NLTK data (punkt_tab for sent_tokenize)
|
||||
run: uv run python -c "import nltk; nltk.download('punkt_tab')"
|
||||
- name: Pytest
|
||||
run: uv run pytest tests/ -x -q
|
||||
|
||||
package:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.0
|
||||
- uses: astral-sh/setup-uv@v8.2.0
|
||||
with:
|
||||
version: "latest"
|
||||
- name: Build distributions
|
||||
run: uv build
|
||||
- name: Check package metadata
|
||||
run: uvx twine check --strict dist/*
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: dist
|
||||
path: dist/*
|
||||
|
||||
install-smoke:
|
||||
name: Install smoke (${{ matrix.label }})
|
||||
needs: package
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 30
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- label: linux
|
||||
os: ubuntu-latest
|
||||
- label: macos-arm64
|
||||
os: macos-14
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.0
|
||||
- uses: actions/setup-python@v6.3.0
|
||||
with:
|
||||
python-version: "3.11"
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: dist
|
||||
path: dist
|
||||
- name: Install wheel with pip
|
||||
shell: bash
|
||||
run: |
|
||||
python -m venv .venv-smoke
|
||||
source .venv-smoke/bin/activate
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install dist/speech_to_speech-*.whl
|
||||
python -m pip check
|
||||
- name: Run installed CLI smoke test
|
||||
shell: bash
|
||||
run: |
|
||||
source .venv-smoke/bin/activate
|
||||
unset OPENAI_API_KEY
|
||||
# Validate the installed entry point without loading models or calling OpenAI.
|
||||
python tests/install_smoke.py
|
||||
@@ -0,0 +1,48 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
|
||||
with:
|
||||
version: "latest"
|
||||
enable-cache: false
|
||||
- name: Build distributions
|
||||
run: uv build
|
||||
- name: Check package metadata
|
||||
run: uvx twine check --strict dist/*
|
||||
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: dist
|
||||
path: dist/*
|
||||
|
||||
publish:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: pypi
|
||||
url: https://pypi.org/project/speech-to-speech/
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: dist
|
||||
path: dist
|
||||
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
|
||||
@@ -0,0 +1,38 @@
|
||||
name: Update star history chart
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
update-chart:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.repository.default_branch }}
|
||||
|
||||
- name: Generate chart
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: python3 .github/scripts/star_history.py "${{ github.repository }}" assets/star-history.svg
|
||||
|
||||
- name: Commit to update branch if changed
|
||||
env:
|
||||
BASE_BRANCH: ${{ github.event.repository.default_branch }}
|
||||
UPDATE_BRANCH: star-history-update-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add assets/star-history.svg
|
||||
if ! git diff --cached --quiet; then
|
||||
git commit -m "chore: update star history chart [skip ci]"
|
||||
git push origin "HEAD:refs/heads/${UPDATE_BRANCH}"
|
||||
pr_url="https://github.com/${{ github.repository }}/compare/${BASE_BRANCH}...${UPDATE_BRANCH}?expand=1"
|
||||
echo "Open a PR: ${pr_url}"
|
||||
echo "Open a PR: [${UPDATE_BRANCH}](${pr_url})" >> "$GITHUB_STEP_SUMMARY"
|
||||
else
|
||||
echo "No changes"
|
||||
fi
|
||||
Reference in New Issue
Block a user