name: tests on: push: branches: [master, main, feat/v3-modernization] pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: # P1.5 - lint gate. ruff is pinned to a major version: an unpinned ruff # drifts the pip cache and can turn a green branch red without a code change. lint: name: Lint (ruff) runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.12" - name: Install ruff (pinned major) run: | python -m pip install --upgrade pip python -m pip install "ruff==0.8.*" - name: Lint run: python -m ruff check . # P1.5 - the test tiers of the modernization plan (section 4): # unit | mock_integration | headless # The headless tier needs a real ComfyUI checkout; COMFYUI_ROOT is empty # here, so those tests skip themselves instead of failing. test: name: Test (python ${{ matrix.python-version }}) strategy: fail-fast: false matrix: os: [ubuntu-latest] python-version: ["3.10", "3.12", "3.13"] runs-on: ${{ matrix.os }} env: COMFYUI_ROOT: "" steps: - name: Check out code uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Cache pip (CPU torch wheel) uses: actions/cache@v4 with: path: ~/.cache/pip key: pip-cpu-torch-${{ runner.os }}-${{ matrix.python-version }}-v1 restore-keys: | pip-cpu-torch-${{ runner.os }}-${{ matrix.python-version }}- - name: Install CPU-only torch and the test dependencies run: | python -m pip install --upgrade pip # CPU wheels are ~200 MB instead of ~2.5 GB of CUDA. # torchvision is a runtime dependency of the package # (modules/keep_processor.py imports it). python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu # numpy 2.4 has no 3.10 wheel -> pin <2.3 on the 3.10 job. # tomli backs tomllib on python 3.10. if [ "${{ matrix.python-version }}" = "3.10" ]; then python -m pip install "numpy<2.3" tomli else python -m pip install numpy fi # PyYAML: the vendored tree imports it eagerly # (modules/deps/basicsr/utils/options.py:5 -> basicsr/utils/__init__.py:8), # so the unit tier fails with "No module named 'yaml'" without it. # requests: the vendored download utility imports it eagerly # (modules/deps/basicsr/utils/download_util.py:3 -> modules/utils.py:19), # so the unit tier fails with "No module named 'requests'" without it. python -m pip install opencv-python-headless einops scipy Pillow tqdm pytest pyyaml requests - name: Run the unit, mock_integration and headless tiers run: python -m pytest -q -m "unit or mock_integration or headless"