Skip to content
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
28 changes: 20 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
id: setup-uv
uses: ./
with:
pyproject-file: "__tests__/fixtures/pyproject-toml-project/pyproject.toml"
working-directory: "__tests__/fixtures/pyproject-toml-project"
- name: Correct version gets installed
run: |
if [ "$(uv --version)" != "uv 0.5.14" ]; then
Expand All @@ -131,9 +131,8 @@ jobs:
id: setup-uv
uses: ./
with:
pyproject-file: "__tests__/fixtures/malformed-pyproject-toml-project/pyproject.toml"
- run: uv sync
working-directory: __tests__/fixtures/uv-project
working-directory: "__tests__/fixtures/malformed-pyproject-toml-project"
- run: uv --help

test-uv-file-version:
runs-on: ubuntu-latest
Expand All @@ -143,8 +142,7 @@ jobs:
id: setup-uv
uses: ./
with:
pyproject-file: "__tests__/fixtures/uv-toml-project/pyproject.toml"
uv-file: "__tests__/fixtures/uv-toml-project/uv.toml"
working-directory: "__tests__/fixtures/uv-toml-project"
- name: Correct version gets installed
run: |
if [ "$(uv --version)" != "uv 0.5.15" ]; then
Expand Down Expand Up @@ -229,7 +227,7 @@ jobs:
fi

test-python-version:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
Expand All @@ -246,8 +244,21 @@ jobs:
exit 1
fi
shell: bash

test-activate-environment:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
steps:
- uses: actions/checkout@v4
- name: Install latest version
uses: ./
with:
python-version: 3.13.1t
activate-environment: true
- name: Verify packages can be installed
run: uv pip install --python=3.13.1t pip
run: uv pip install pip
shell: bash
- name: Verify python version is correct
run: |
Expand Down Expand Up @@ -508,6 +519,7 @@ jobs:
- test-tool-install
- test-tilde-expansion-tool-dirs
- test-python-version
- test-activate-environment
- test-musl
- test-restore-cache
- test-restore-cache-requirements-txt
Expand Down
58 changes: 32 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
- [Install the latest version](#install-the-latest-version)
- [Install a specific version](#install-a-specific-version)
- [Install a version by supplying a semver range or pep440 specifier](#install-a-version-by-supplying-a-semver-range-or-pep440-specifier)
- [Install a required-version](#install-a-required-version)
- [Python version](#python-version)
- [Activate environment](#activate-environment)
- [Working directory](#working-directory)
- [Validate checksum](#validate-checksum)
- [Enable Caching](#enable-caching)
- [Cache dependency glob](#cache-dependency-glob)
Expand Down Expand Up @@ -90,32 +91,9 @@ to install the latest version that satisfies the range.
version: ">=0.4.25,<0.5"
```

### Install a required-version

You can specify a [required-version](https://docs.astral.sh/uv/reference/settings/#required-version)
in either a `uv.toml` or `pyproject.toml` file:

```yaml
- name: Install required-version defined in uv.toml
uses: astral-sh/setup-uv@v5
with:
uv-file: "path/to/uv.toml"
```

```yaml
- name: Install required-version defined in pyproject.toml
uses: astral-sh/setup-uv@v5
with:
pyproject-file: "path/to/pyproject.toml"
```

### Python version

You can use the input `python-version` to

- set the environment variable `UV_PYTHON` for the rest of your workflow
- create a new virtual environment with the specified python version
- activate the virtual environment for the rest of your workflow
You can use the input `python-version` to set the environment variable `UV_PYTHON` for the rest of your workflow

This will override any python version specifications in `pyproject.toml` and `.python-version`

Expand Down Expand Up @@ -146,6 +124,34 @@ jobs:
run: uv run --frozen pytest
```

### Activate environment

You can set `activate-environment` to `true` to automatically activate a venv.
This allows directly using it in later steps:

```yaml
- name: Install the latest version of uv and activate the environment
uses: astral-sh/setup-uv@v5
with:
activate-environment: true
- run: uv pip install pip
```

### Working directory

You can set the working directory with the `working-directory` input.
This controls where we look for `pyproject.toml`, `uv.toml` and `.python-version` files
which are used to determine the version of uv and python to install.

It also controls where [the venv gets created](#activate-environment).

```yaml
- name: Install uv based on the config files in the working-directory
uses: astral-sh/setup-uv@v5
with:
working-directory: my/subproject/dir
```

### Validate checksum

You can specify a checksum to validate the downloaded executable. Checksums up to the default version
Expand Down Expand Up @@ -383,7 +389,7 @@ This action downloads uv from the uv repo's official
[GitHub Actions Toolkit](https://github.com/actions/toolkit) to cache it as a tool to speed up
consecutive runs on self-hosted runners.

The installed version of uv is then added to the runner PATH, enabling subsequent steps to invoke it
The installed version of uv is then added to the runner PATH, enabling later steps to invoke it
by name (`uv`).

## FAQ
Expand Down
12 changes: 6 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ inputs:
version:
description: "The version of uv to install e.g., `0.5.0` Defaults to the version in pyproject.toml or 'latest'."
default: ""
pyproject-file:
description: "Path to a pyproject.toml"
default: ""
uv-file:
description: "Path to a uv.toml"
default: ""
python-version:
description: "The version of Python to set UV_PYTHON to"
required: false
activate-environment:
description: "Use uv venv to activate a venv ready to be used by later steps. "
default: "false"
working-directory:
description: "The directory to execute all commands in and look for files such as pyproject.toml"
default: ${{ github.workspace }}
checksum:
description: "The checksum of the uv version to install"
required: false
Expand Down
8 changes: 4 additions & 4 deletions dist/save-cache/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading