Fix/code quality checks #243
Workflow file for this run
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: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [develop, main] | |
| # Concurrency controls restored. | |
| # Crucial for preventing cost blowouts when developers push multiple commits rapidly. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # NEW JOB: Code Quality Enforcement | |
| code-quality: | |
| name: Code Quality Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv and Set up Python | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: "3.11" | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Install dependencies with dev extras | |
| run: uv sync --extra dev --extra cpu --locked | |
| # Run Black (formatting check, not auto-fix) | |
| - name: Check Black formatting | |
| run: uv run black --check --diff . | |
| # Run isort (import sorting check) | |
| - name: Check isort | |
| run: uv run isort --check-only --diff . | |
| # Run flake8 (linting) - using lenient config | |
| - name: Run flake8 | |
| run: | | |
| uv run flake8 \ | |
| --max-line-length=88 \ | |
| --extend-ignore=E203,E501,W503,E402,F401,F403,F841,B006,B007,B008,B009,C416,E262 \ | |
| anomavision/ anodet/ apps/ tests/ *.py | |
| continue-on-error: false | |
| tests: | |
| name: Tests (Python ${{ matrix.python-version }}) | |
| runs-on: ubuntu-latest | |
| # Run tests only after code quality passes | |
| needs: code-quality | |
| strategy: | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12"] | |
| fail-fast: false # Prevents the entire matrix from dying if one python version fails | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # UV's official action natively handles downloading Python, installing uv, | |
| # and caching the environment based on your uv.lock file. | |
| - name: Install uv and Set up Python | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Install dependencies (CPU) | |
| # --locked is MANDATORY. This instantly fails the build if the lockfile drifted, | |
| # preventing transient dependencies from sneaking into production. | |
| run: uv sync --extra cpu --locked | |
| - name: Run tests | |
| run: uv run pytest -v | |
| cuda-matrix-check: | |
| name: Verify CUDA Resolvers | |
| runs-on: ubuntu-latest | |
| # Run CUDA checks only after code quality passes | |
| needs: code-quality | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: "3.11" | |
| enable-cache: false # Caching isn't needed since we're only doing dry-runs | |
| # Architect Note: We use --dry-run here. We only want to verify that the | |
| # hardware routing matrix in pyproject.toml correctly resolves all dependencies | |
| # without dependency conflicts. We DO NOT want to physically download 8GB of wheels. | |
| - name: Verify cu118 resolution | |
| run: uv sync --extra cu118 --locked --dry-run | |
| - name: Verify cu121 resolution | |
| run: uv sync --extra cu121 --locked --dry-run | |
| - name: Verify cu124 resolution | |
| run: uv sync --extra cu124 --locked --dry-run |