diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed87922..cf075fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,44 +7,34 @@ on: branches: [main] jobs: - lint: + test: runs-on: ubuntu-latest - + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + steps: - - name: Checkout code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 with: - fetch-depth: 0 + python-version: ${{ matrix.python-version }} - - name: Install uv - uses: astral-sh/setup-uv@v7 + - name: Cache pip dependencies + uses: actions/cache@v4 with: - version: "0.10.8" - enable-cache: true - - - - name: Set up Python - run: uv python install 3.10 && uv venv --python 3.10 - - - name: Install dependencies - run: uv sync --locked - - - name: Run Ruff Check - run: | - if [ "${{ github.event_name }}" == "pull_request" ]; then - git fetch origin main - git diff --diff-filter=ACMR --name-only -z origin/main...HEAD -- '*.py' \ - | xargs -0 -r uv run ruff check -- - else - uv run ruff check . - fi - - - name: Run Ruff Format - run: | - if [ "${{ github.event_name }}" == "pull_request" ]; then - git fetch origin main - git diff --diff-filter=ACMR --name-only -z origin/main...HEAD -- '*.py' \ - | xargs -0 -r uv run ruff format --check -- - else - uv run ruff format --check . - fi \ No newline at end of file + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.python-version }}- + + - name: Install package and dev dependencies + run: pip install -e ".[dev]" + + - name: Run linter + run: ruff check openverifiablellm/ + + - name: Run tests + run: pytest tests/ -v --tb=short diff --git a/pyproject.toml b/pyproject.toml index 96523a0..21a38dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,9 +17,19 @@ dependencies = [ "tokenizers==0.15.2" ] +# Intentionally duplicated from [dependency-groups] below. +# pip uses this section; uv/PEP 735 uses [dependency-groups]. Keep both in sync. +[project.optional-dependencies] +dev = [ + "pytest>=7.0", + "ruff>=0.15.4", +] + [tool.setuptools.packages.find] include = ["openverifiablellm*"] +# Intentionally duplicated from [project.optional-dependencies] above. +# uv/PEP 735 uses this section; pip uses [project.optional-dependencies]. Keep both in sync. [dependency-groups] dev = [ "pytest>=7.0",