Skip to content

Commit

Permalink
Detect required-version from config file
Browse files Browse the repository at this point in the history
Search for uv.toml and pyproject.toml in repo root or supplied input.
Search for required-version value and use it to determine uv version to download.
  • Loading branch information
eifinger committed Jan 12, 2025
1 parent d577e74 commit 705f6e1
Show file tree
Hide file tree
Showing 18 changed files with 2,434 additions and 19 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,39 @@ jobs:
fi
env:
UV_VERSION: ${{ steps.setup-uv.outputs.uv-version }}
test-version-pyproject-file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install version 0.5.14
id: setup-uv
uses: ./
with:
pyproject-file: "__tests__/fixtures/pyproject-toml-project/pyproject.toml"
- name: Correct version gets installed
run: |
if [ "$UV_VERSION" != "0.5.14" ]; then
exit 1
fi
env:
UV_VERSION: ${{ steps.setup-uv.outputs.uv-version }}
test-version-uv-file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install version 0.5.15
id: setup-uv
uses: ./
with:
pyproject-file: "__tests__/fixtures/uv-toml-project/pyproject.toml"
uv-file: "__tests__/fixtures/uv-toml-project/uv.toml"
- name: Correct version gets installed
run: |
if [ "$UV_VERSION" != "0.5.15" ]; then
exit 1
fi
env:
UV_VERSION: ${{ steps.setup-uv.outputs.uv-version }}
test-checksum:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
1 change: 1 addition & 0 deletions __tests__/fixtures/pyproject-toml-project/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
Empty file.
6 changes: 6 additions & 0 deletions __tests__/fixtures/pyproject-toml-project/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def main():
print("Hello from pyproject-toml-project!")


if __name__ == "__main__":
main()
10 changes: 10 additions & 0 deletions __tests__/fixtures/pyproject-toml-project/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[project]
name = "pyproject-toml-project"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = []

[tool.uv]
required-version = "==0.5.14"
1 change: 1 addition & 0 deletions __tests__/fixtures/uv-toml-project/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
Empty file.
6 changes: 6 additions & 0 deletions __tests__/fixtures/uv-toml-project/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def main():
print("Hello from uv-toml-project!")


if __name__ == "__main__":
main()
10 changes: 10 additions & 0 deletions __tests__/fixtures/uv-toml-project/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[project]
name = "uv-toml-project"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = []

[tool.uv]
required-version = "==0.5.14"
1 change: 1 addition & 0 deletions __tests__/fixtures/uv-toml-project/uv.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
required-version = "==0.5.15"
12 changes: 9 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ description:
author: "astral-sh"
inputs:
version:
description: "The version of uv to install"
default: "latest"
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
Expand All @@ -18,7 +24,7 @@ inputs:
required: false
default: ${{ github.token }}
enable-cache:
description: "Enable caching of the uv cache"
description: "Enable uploading of the uv cache"
default: "auto"
cache-dependency-glob:
description:
Expand Down
4 changes: 3 additions & 1 deletion dist/save-cache/index.js

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

Loading

0 comments on commit 705f6e1

Please sign in to comment.