Skip to content

Commit

Permalink
Use setup-uv, uv build, and uv publish in CI (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb authored Oct 1, 2024
1 parent d512247 commit 7c7371e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 72 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,18 @@ jobs:
persist-credentials: false
fetch-depth: 0

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: "${{ env.PYTHON_VERSION }}"

- name: Set up uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- uses: astral-sh/setup-uv@v3

- name: Publish to Test PyPI
id: build
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
UV_PUBLISH_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: |
version=$(./scripts/version dev)
echo "version=$version" >> $GITHUB_OUTPUT
sed -i -e "s/0.0.0/$version/" pyproject.toml
uv tool run -- hatchling build
uv tool run -- twine upload -r testpypi dist/*
uv build
uv publish --publish-url https://test.pypi.org/legacy/
test-install:
# We test the install on a clean machine to avoid poetry behavior attempting to
Expand All @@ -66,9 +58,7 @@ jobs:
with:
python-version: "${{ env.PYTHON_VERSION }}"

- name: Set up uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- uses: astral-sh/setup-uv@v3

- name: Wait for package to be available
run: >
Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,13 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Set up uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
- uses: astral-sh/setup-uv@v3

- name: Check Python lint
run: |
uv tool run -- ruff check . --config pyproject.toml
run: uvx ruff check . --config pyproject.toml

- name: Check Python formatting
run: |
uv tool run -- ruff format --check . --config pyproject.toml
run: uvx ruff format --check . --config pyproject.toml

typos:
runs-on: ubuntu-latest
Expand Down
20 changes: 6 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,19 @@ jobs:
persist-credentials: false
fetch-depth: 0

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v3

- name: Set up uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
# Note: If build and publish steps are ever separated, the version must
# be set before building
- name: Publish package
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
sed -i -e "s/0.0.0/${GITHUB_REF#refs/*/}/" pyproject.toml
uv tool run -- hatchling build
uv tool run -- twine upload dist/*
uv build
uv publish --publish-url https://test.pypi.org/legacy/
release-scenarios:
name: Publish scenarios
Expand All @@ -52,10 +46,8 @@ jobs:
with:
python-version: "3.12"

- name: Set up uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- uses: astral-sh/setup-uv@v3

- name: Install packages
run: |
uv sync --all-extras
Expand Down
32 changes: 2 additions & 30 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,9 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 10

env:
UV_CACHE_DIR: /tmp/.uv-cache

steps:
- uses: actions/checkout@v4

- name: Set up uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install packages
run: |
uv sync --all-extras --dev
- uses: astral-sh/setup-uv@v3

- name: Run tests
run: |
uv run -- pytest tests
- name: Minimize uv cache
run: uv cache prune --ci
run: uv run --all-extras --python ${{ matrix.python-version }} -- pytest tests

0 comments on commit 7c7371e

Please sign in to comment.