fix(flow): fix some bugs in podcast flow #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pre-commit Checks | |
| # 触发条件:当有 PR 提交到 master 分支时自动运行 | |
| on: | |
| pull_request: | |
| branches: [ "master" ] | |
| workflow_dispatch: # 添加这行支持手动触发 | |
| inputs: | |
| branch: | |
| description: 'Branch to test' | |
| required: false | |
| default: 'master' | |
| type: string | |
| jobs: | |
| pre-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 第一步:检出代码到 runner 环境 | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.branch || github.ref }} # 支持指定分支 | |
| # 第二步:设置 Python 环境 | |
| # 使用 Python 3.11 确保与开发环境一致 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| # 第三步:缓存 pre-commit hooks | |
| # 避免每次都重新下载和安装 hooks,提高构建速度 | |
| - name: Cache pre-commit | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | |
| # 第四步:安装 pre-commit 工具 | |
| # 升级 pip 确保使用最新版本,然后安装 pre-commit | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pre-commit | |
| # 第五步:安装项目依赖 | |
| # 支持 requirements.txt 和 pyproject.toml 两种依赖管理方式 | |
| # 以可编辑模式安装项目,确保 imports 正常工作 | |
| - name: Install project dependencies | |
| run: | | |
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
| if [ -f pyproject.toml ]; then pip install -e .; fi | |
| # 第六步:运行所有 pre-commit hooks | |
| # 包括代码格式检查、linting、单元测试等 | |
| # --all-files 确保检查所有文件,不仅仅是变更的文件 | |
| - name: Run pre-commit hooks | |
| run: pre-commit run --all-files |