name: 跑测试 on: push: branches: [ "dev", "master" ] paths: - '.github/workflows/*.yml' # 工作流定义 - 'usage/**/*.py' # 工作流脚本 - 'assets/config/*.yml' # option配置文件 - 'src/**/*.py' # 源码 - 'tests/**/*.py' # 测试代码 jobs: test: # This code is based on https://github.com/gaogaotiantian/viztracer/blob/master/.github/workflows/python-package.yml strategy: matrix: python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11" ] os: [ ubuntu-latest ] runs-on: ${{ matrix.os }} timeout-minutes: 5 steps: - name: Checkout repository uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies if: matrix.os != 'windows-latest' run: | python -m pip install --upgrade pip if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi - name: Install dependencies on Windows if: matrix.os == 'windows-latest' run: | python -m pip install --upgrade pip if (Test-Path -Path '.\requirements-dev.txt' -PathType Leaf) {pip install -r requirements-dev.txt} - name: Install local run: | pip install -e ./ - name: 跑测试 if: matrix.os != 'windows-latest' run: | cd ./tests/ python -m unittest - name: 跑测试(Windows系统) if: matrix.os == 'windows-latest' run: | python -m unittest discover -s ./tests -p "test_*.py"