From 159532c8c8d124852a3df589d4850537d894dc63 Mon Sep 17 00:00:00 2001 From: Yuta Sato Date: Tue, 13 Jan 2026 19:54:27 +0000 Subject: [PATCH] Update pre-commit and test --- .github/workflows/test.yml | 46 ++++++++++++++++++++++++++------------ .pre-commit-config.yaml | 2 +- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 97e2a1d..5e00aff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,42 +9,60 @@ on: branches: [main] jobs: - test: + # Pre-commit runs once (not for each Python version) + pre-commit: runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v6 - name: Set up Python uses: actions/setup-python@v6 with: - python-version: ${{ matrix.python-version }} + python-version: '3.12' - name: Set up uv uses: astral-sh/setup-uv@v7 with: cache-dependency-glob: uv.lock - - name: Sync dependencies - run: | - uv sync --locked --extra cpu --dev - + run: uv sync --locked --extra cpu --dev - name: Cache pre-commit uses: actions/cache@v5 with: path: ~/.cache/pre-commit/ - key: pre-commit-${{ matrix.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }} - + key: pre-commit-3.12-${{ hashFiles('.pre-commit-config.yaml') }} - name: Run pre-commit checks run: uv run pre-commit run --all-files env: SKIP: no-commit-to-branch + + # Tests run in parallel across Python versions + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ['3.10', '3.11', '3.12', '3.13'] + steps: + - uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + + - name: Set up uv + uses: astral-sh/setup-uv@v7 + with: + cache-dependency-glob: uv.lock + + - name: Sync dependencies + run: uv sync --locked --extra cpu --dev + - name: Run tests with coverage - run: | - uv run pytest --cov=city2graph --cov-report=xml + run: uv run pytest --cov=city2graph --cov-report=xml + - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 with: - token: ${{ secrets.CODECOV_TOKEN }} # Set CODECOV_TOKEN in repository secrets + token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml fail_ci_if_error: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index feeb749..b13277f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,6 +50,6 @@ repos: - pandas-stubs - pytest - shapely - - torch + - types-torch - torch-geometric - types-requests