From dfbc025413ddc239294f8b335483a740c8dc88b9 Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Thu, 7 Nov 2024 19:11:41 +0000 Subject: [PATCH] Switch to uv in GHA --- .github/workflows/lint.yaml | 17 +++++++++++++---- .github/workflows/pages.yaml | 22 ++++++++++++++++------ .github/workflows/pypi-publish.yaml | 20 +++++++++++++++----- .github/workflows/python-package.yaml | 16 ++++++++++++---- .github/workflows/test-coverage.yaml | 14 ++++++++++---- pyproject.toml | 3 +-- 6 files changed, 67 insertions(+), 25 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index eefe6aa..f9b85c9 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -6,6 +6,10 @@ on: name: lint +env: + PYTHONUNBUFFERED: "1" + UV_SYSTEM_PYTHON: 1 + jobs: lint-ruff: runs-on: ubuntu-latest @@ -13,14 +17,19 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Setup python + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + cache-dependency-glob: pyproject.toml + + - name: Setup Python uses: actions/setup-python@v5 with: - python-version: "3.x" - cache: "pip" + python-version-file: pyproject.toml - name: Install dependencies - run: pip install . ruff + run: uv pip install . ruff - name: Lint with ruff run: ruff check --output-format=github . diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml index 358bf2e..72e6125 100644 --- a/.github/workflows/pages.yaml +++ b/.github/workflows/pages.yaml @@ -7,6 +7,10 @@ on: name: pages +env: + PYTHONUNBUFFERED: "1" + UV_SYSTEM_PYTHON: 1 + jobs: build-sphinx-site: runs-on: ubuntu-latest @@ -17,14 +21,20 @@ jobs: - name: Configure pages uses: actions/configure-pages@v5 - - name: Setup python - uses: actions/setup-python@v5 + - name: Install uv + uses: astral-sh/setup-uv@v3 with: - python-version: "3.x" - cache: "pip" + enable-cache: true + cache-dependency-glob: pyproject.toml + cache-suffix: docs + + - name: Install Python dependencies + run: uv pip install .[docs] - - name: Install dependencies - run: pip install .[docs] + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version-file: pyproject.toml - name: Generate HTML run: | diff --git a/.github/workflows/pypi-publish.yaml b/.github/workflows/pypi-publish.yaml index e47b02f..fbe1fad 100644 --- a/.github/workflows/pypi-publish.yaml +++ b/.github/workflows/pypi-publish.yaml @@ -5,6 +5,10 @@ on: name: pypi-publish +env: + PYTHONUNBUFFERED: "1" + UV_SYSTEM_PYTHON: 1 + jobs: pypi-publish: name: pypi-publish @@ -18,16 +22,22 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + cache-dependency-glob: pyproject.toml + + - name: Install Python dependencies + run: uv pip install . + - name: Setup Python uses: actions/setup-python@v5 with: - python-version: "3.x" - - - name: Install dependencies - run: pip install build + python-version-file: pyproject.toml - name: Build Python dist - run: python -m build + run: uv build - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/python-package.yaml b/.github/workflows/python-package.yaml index 5ca5604..b0a994b 100644 --- a/.github/workflows/python-package.yaml +++ b/.github/workflows/python-package.yaml @@ -18,14 +18,22 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Setup python ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + cache-dependency-glob: pyproject.toml + + - name: Setup Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: "pip" - name: Install tox - run: pip install tox-gh>=1.3.0 + shell: bash + run: | + uv tool install tox --with tox-uv + tox --version - name: Test install with tox - run: tox -v --notest + run: tox r -v --notest diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index e6c0681..1558182 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -18,18 +18,24 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Setup python ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + cache-dependency-glob: pyproject.toml + cache-suffix: test + + - name: Setup Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: "pip" - name: Install dependencies - run: pip install .[test] + run: uv pip install .[test] - name: Run pytest run: | - pytest --doctest-modules \ + uv run pytest --doctest-modules \ --junitxml=junit/test-results-${{ matrix.python-version }}.xml - name: Upload artifacts diff --git a/pyproject.toml b/pyproject.toml index 6f713d9..23b262b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ testpaths = "assesspy/tests" legacy_tox_ini = """ [tox] min_version = 4.0 -envlist = py39, py38, py310, py311, py312 +envlist = py39, py310, py311, py312 [gh] python = @@ -79,7 +79,6 @@ python = 3.11 = py311 3.10 = py310 3.9 = py39 - 3.8 = py38 """ [tool.ruff]