diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d731756 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,49 @@ +name: Tests + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + pytest: + name: pytest (${{ matrix.os }}, py${{ matrix.python }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # Windows 是桌面版的目标平台,POSIX 假设的回归必须在这里同样暴露 + include: + - os: ubuntu-latest + python: "3.12" + - os: windows-latest + python: "3.12" + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + cache: pip + cache-dependency-path: | + requirements.txt + requirements-dev.txt + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + + - name: Run tests + env: + # 中文断言与日志在 Windows 控制台默认代码页下会乱码 + PYTHONIOENCODING: utf-8 + run: python -m pytest tests -q diff --git a/.gitignore b/.gitignore index 1d2fddd..6d52631 100644 --- a/.gitignore +++ b/.gitignore @@ -95,6 +95,8 @@ data/workspace/ temp/ *.tmp *.txt +# 依赖清单是源码,不受上面的 *.txt 影响 +!requirements*.txt *.xlsx *.xls diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..aa01d7a --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,5 @@ +# 测试与开发期依赖;运行应用只需 requirements.txt +-r requirements.txt + +pytest>=8.0 +pytest-asyncio>=0.23