From 562ca1150e70aeb1bd9f8ad987918c20620c5dbc Mon Sep 17 00:00:00 2001 From: Hassan Kibirige Date: Tue, 24 Sep 2024 13:48:16 +0300 Subject: [PATCH] CI: Use uv and test lowest-direct dependencies --- .github/workflows/testing.yml | 85 +++++++++++++++++++++-------------- Makefile | 4 +- pyproject.toml | 2 +- 3 files changed, 55 insertions(+), 36 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index c4617f5..124bde3 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -19,7 +19,11 @@ jobs: strategy: matrix: - python-version: ["3.10", "3.12"] + include: + - python-version: "3.10" + resolution: "lowest-direct" + - python-version: 3.12 + resolution: "highest" steps: - name: Checkout Code @@ -30,18 +34,22 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install a specific version of uv + uses: astral-sh/setup-uv@v3 + with: + version: "latest" + + - name: Make uv use system python + run: echo "UV_SYSTEM_PYTHON=true" >> $GITHUB_ENV + - name: Install Packages - shell: bash - run: | - pip install -e ".[test]" + # Install as an editable so that the coverage path is predicable + run: uv pip install --resolution=${{ matrix.resolution }} -e ".[test]" - name: Environment Information - shell: bash - run: | - pip list + run: uv pip list - name: Run Tests - shell: bash run: | coverage erase make test @@ -61,7 +69,8 @@ jobs: strategy: matrix: - python-version: ["3.11"] + python-version: [3.12] + steps: - name: Checkout Code uses: actions/checkout@v4 @@ -71,22 +80,24 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install a specific version of uv + uses: astral-sh/setup-uv@v3 + with: + version: "latest" + + - name: Make uv use system python + run: echo "UV_SYSTEM_PYTHON=true" >> $GITHUB_ENV + - name: Install Linting & Formatting Packages - shell: bash - run: | - pip install ruff - pip install black + run: uv pip install ruff - name: Environment Information - shell: bash - run: pip list + run: uv pip list - - name: Check lint with Ruff - shell: bash + - name: Check lint with ruff run: make lint - - name: Check format with Black - shell: bash + - name: Check format with ruff format run: make format typecheck: @@ -98,7 +109,7 @@ jobs: strategy: matrix: - python-version: [3.11] + python-version: [3.12] steps: - name: Checkout Code @@ -109,17 +120,21 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install a specific version of uv + uses: astral-sh/setup-uv@v3 + with: + version: "latest" + + - name: Make uv use system python + run: echo "UV_SYSTEM_PYTHON=true" >> $GITHUB_ENV + - name: Install Packages - shell: bash - run: | - pip install ".[extra, typing]" + run: uv pip install ".[extra, typing]" - name: Environment Information - shell: bash - run: pip list + run: uv pip list - name: Run Tests - shell: bash run: make typecheck documentation: @@ -131,7 +146,7 @@ jobs: strategy: matrix: - python-version: ["3.12"] + python-version: [3.12] steps: - name: Checkout Code @@ -142,17 +157,21 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install a specific version of uv + uses: astral-sh/setup-uv@v3 + with: + version: "latest" + + - name: Make uv use system python + run: echo "UV_SYSTEM_PYTHON=true" >> $GITHUB_ENV + - name: Install Packages - shell: bash - run: | - pip install -e ".[doc]" + run: uv pip install -e ".[doc]" - name: Environment Information - shell: bash - run: pip list + run: uv pip list - name: Build Documentation - shell: bash run: | pushd doc SPHINXOPTS=-W diff --git a/Makefile b/Makefile index cd61fa8..5458608 100644 --- a/Makefile +++ b/Makefile @@ -80,8 +80,8 @@ dist: build ls -l dist develop: clean-pyc - pip install -e ".[all]" + uv pip install -e ".[all]" install: clean ls -l dist - pip install . + uv pip install . diff --git a/pyproject.toml b/pyproject.toml index c374a28..9a598e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ lint = [ ] test = [ - "pytest-cov" + "pytest-cov>=4.0.0" ] dev = [