Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Use setup-uv action #1552

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/script/install-uv.sh

This file was deleted.

58 changes: 17 additions & 41 deletions .github/workflows/ci-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ env:
SCCACHE_GHA_ENABLED: "true"
HUGR_BIN_DIR: ${{ github.workspace }}/target/debug
HUGR_BIN: ${{ github.workspace }}/target/debug/hugr
UV_CACHE_DIR: /tmp/.uv-cache

jobs:
# Check if changes were made to the relevant files.
Expand Down Expand Up @@ -53,18 +52,13 @@ jobs:
uses: mozilla-actions/[email protected]

- name: Set up uv
run: .github/script/install-uv.sh
- name: "Set up Python"
uses: actions/setup-python@v5
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
- name: Restore uv cache
uses: actions/cache@v4
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}
version: "0.4.18"
enable-cache: true
- name: Install Python
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we know how fast this is compared to the default setup python action, any reason to prefer it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say fast enough
image

They recommend doing it this way
https://github.com/astral-sh/setup-uv?tab=readme-ov-file#do-i-still-need-actionssetup-python-alongside-setup-uv

In the docs they mention this, but I don't think it makes much of a difference

Alternatively, the official GitHub setup-python action can be used. This can be faster, because GitHub caches the Python versions alongside the runner.

run: uv python install ${{ matrix.python-version }}

- name: Setup dependencies. Fail if the lockfile is outdated.
run: uv sync --locked

Expand All @@ -77,9 +71,6 @@ jobs:
- name: Lint with ruff
run: uv run ruff check

- name: Minimize uv cache
run: uv cache prune --ci

build_binary:
needs: changes
if: ${{ needs.changes.outputs.python == 'true' }}
Expand Down Expand Up @@ -115,20 +106,14 @@ jobs:
- { py: '3.12', coverage: true }
steps:
- uses: actions/checkout@v4

- name: Set up uv
run: .github/script/install-uv.sh
- name: "Set up Python"
uses: actions/setup-python@v5
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version.py }}
- name: Restore uv cache
uses: actions/cache@v4
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}
version: "0.4.18"
enable-cache: true
- name: Install Python
run: uv python install ${{ matrix.python-version.py }}

- name: Download the hugr binary
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -163,9 +148,6 @@ jobs:
flags: python
token: ${{ secrets.CODECOV_TOKEN }}

- name: Minimize uv cache
run: uv cache prune --ci

# Ensure that the serialization schema is up to date
serialization-schema:
needs: [changes]
Expand All @@ -178,18 +160,12 @@ jobs:
uses: mozilla-actions/[email protected]

- name: Set up uv
run: .github/script/install-uv.sh
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Restore uv cache
uses: actions/cache@v4
uses: astral-sh/setup-uv@v3
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}
version: "0.4.18"
enable-cache: true
- name: Install Python
run: uv python install 3.12

- name: Setup dependencies
run: uv sync
Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ concurrency:
group: "pages"
cancel-in-progress: true

env:
UV_CACHE_DIR: /tmp/.uv-cache

jobs:
build:
name: Build docs.
Expand All @@ -38,18 +35,12 @@ jobs:
fetch-tags: true

- name: Set up uv
run: ../.github/script/install-uv.sh
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Restore uv cache
uses: actions/cache@v4
uses: astral-sh/setup-uv@v3
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}
version: "0.4.18"
enable-cache: true
- name: Install Python
run: uv python install 3.12

- name: Build docs
run: |
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/python-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ jobs:
uses: mozilla-actions/[email protected]

- name: Set up uv
run: .github/script/install-uv.sh
- name: "Set up Python"
uses: actions/setup-python@v5
uses: astral-sh/setup-uv@v3
with:
python-version: '3.12'
version: "0.4.18"
enable-cache: true
- name: Install Python
run: uv python install 3.12

- name: Build sdist and wheels
run: |
Expand Down
Loading