mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-10-18 08:37:01 +00:00
Respect UV_CACHE_DIR and cache-dir (#612)
Some checks failed
CodeQL / Analyze (TypeScript) (push) Failing after 2s
test / lint (push) Failing after 2s
test / test-default-version (ubuntu-latest) (push) Failing after 2s
test / test-uv-no-modify-path (push) Failing after 2s
test / test-specific-version (map[expected-version:0.3.0 version-input:0.3.0]) (push) Failing after 1s
test / test-specific-version (map[expected-version:0.3.2 version-input:0.3.2]) (push) Failing after 1s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3.x]) (push) Failing after 2s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3]) (push) Failing after 2s
test / test-specific-version (map[expected-version:0.4.30 version-input:>=0.4.25,<0.5]) (push) Failing after 2s
test / test-latest-version (>=0.8) (push) Failing after 1s
test / test-latest-version (latest) (push) Failing after 2s
test / test-setup-cache-save-cache-false (push) Failing after 1s
test / test-from-working-directory-version (map[expected-version:0.5.14 working-directory:__tests__/fixtures/pyproject-toml-project]) (push) Failing after 2s
test / test-from-working-directory-version (map[expected-version:0.5.15 working-directory:__tests__/fixtures/uv-toml-project]) (push) Failing after 1s
test / test-version-file-version (map[expected-version:0.5.15 version-file:__tests__/fixtures/.tool-versions]) (push) Failing after 2s
test / test-version-file-version (map[expected-version:0.6.17 version-file:__tests__/fixtures/uv-in-requirements-txt-project/requirements.txt]) (push) Failing after 2s
test / test-version-file-version (map[expected-version:0.8.3 version-file:__tests__/fixtures/uv-in-requirements-hash-txt-project/requirements.txt]) (push) Failing after 1s
test / test-malformed-pyproject-file-fallback (push) Failing after 1s
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Failing after 1s
test / test-with-explicit-token (push) Failing after 1s
test / test-uvx (push) Failing after 1s
test / test-tool-install (ubuntu-latest) (push) Failing after 1s
test / test-python-version (ubuntu-latest) (push) Failing after 1s
test / test-activate-environment (ubuntu-latest) (push) Failing after 2s
test / test-setup-cache (auto, ubuntu-latest) (push) Failing after 1s
test / test-setup-cache (false, ubuntu-latest) (push) Failing after 2s
test / test-setup-cache (true, ubuntu-latest) (push) Failing after 2s
test / test-setup-cache-requirements-txt (push) Failing after 2s
test / test-musl (push) Failing after 5s
test / test-restore-cache-requirements-txt (push) Has been skipped
test / test-setup-cache-dependency-glob (push) Failing after 2s
test / test-restore-cache-dependency-glob (push) Has been skipped
test / test-restore-cache-save-cache-false (push) Has been skipped
test / test-setup-cache-restore-cache-false (push) Failing after 1s
test / test-restore-cache-restore-cache-false (push) Has been skipped
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Failing after 2s
test / test-cache-local-cache-disabled (push) Failing after 4s
test / test-no-python-version (push) Failing after 5s
test / test-custom-manifest-file (push) Failing after 5s
test / test-absolute-path (push) Failing after 5s
test / test-relative-path (push) Failing after 5s
test / test-cache-prune-force (push) Failing after 5s
test / test-cache-dir-from-file (push) Failing after 5s
Release Drafter / ✏️ Draft release (push) Has been cancelled
test / test-default-version (macos-14) (push) Has been cancelled
test / test-default-version (macos-latest) (push) Has been cancelled
test / test-default-version (windows-latest) (push) Has been cancelled
test / test-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Has been cancelled
test / test-tool-install (macos-14) (push) Has been cancelled
test / test-tool-install (macos-latest) (push) Has been cancelled
test / test-tool-install (windows-latest) (push) Has been cancelled
test / test-tilde-expansion-tool-dirs (push) Has been cancelled
test / test-python-version (macos-latest) (push) Has been cancelled
test / test-python-version (windows-latest) (push) Has been cancelled
test / test-activate-environment (macos-latest) (push) Has been cancelled
test / test-activate-environment (windows-latest) (push) Has been cancelled
test / test-setup-cache (auto, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-setup-cache (auto, windows-latest) (push) Has been cancelled
test / test-setup-cache (false, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-setup-cache (false, windows-latest) (push) Has been cancelled
test / test-setup-cache (true, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-setup-cache (true, windows-latest) (push) Has been cancelled
test / test-cache-local (map[expected-cache-dir:/home/ubuntu/.cache/uv os:selfhosted-ubuntu-arm64]) (push) Has been cancelled
test / test-cache-local (map[expected-cache-dir:D:\a\_temp\setup-uv-cache os:windows-latest]) (push) Has been cancelled
test / test-setup-cache-local (push) Has been cancelled
test / test-tilde-expansion-cache-local-path (push) Has been cancelled
test / test-tilde-expansion-cache-dependency-glob (push) Has been cancelled
test / test-restore-cache (false, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache (false, windows-latest) (push) Has been cancelled
test / test-restore-cache (true, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-restore-cache (true, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache (true, windows-latest) (push) Has been cancelled
test / test-restore-cache (auto, windows-latest) (push) Has been cancelled
test / test-restore-cache (false, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-restore-cache (auto, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-restore-cache (auto, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache-local (push) Has been cancelled
test / cleanup-tilde-expansion-tests (push) Has been cancelled
test / all-tests-passed (push) Has been cancelled
Some checks failed
CodeQL / Analyze (TypeScript) (push) Failing after 2s
test / lint (push) Failing after 2s
test / test-default-version (ubuntu-latest) (push) Failing after 2s
test / test-uv-no-modify-path (push) Failing after 2s
test / test-specific-version (map[expected-version:0.3.0 version-input:0.3.0]) (push) Failing after 1s
test / test-specific-version (map[expected-version:0.3.2 version-input:0.3.2]) (push) Failing after 1s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3.x]) (push) Failing after 2s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3]) (push) Failing after 2s
test / test-specific-version (map[expected-version:0.4.30 version-input:>=0.4.25,<0.5]) (push) Failing after 2s
test / test-latest-version (>=0.8) (push) Failing after 1s
test / test-latest-version (latest) (push) Failing after 2s
test / test-setup-cache-save-cache-false (push) Failing after 1s
test / test-from-working-directory-version (map[expected-version:0.5.14 working-directory:__tests__/fixtures/pyproject-toml-project]) (push) Failing after 2s
test / test-from-working-directory-version (map[expected-version:0.5.15 working-directory:__tests__/fixtures/uv-toml-project]) (push) Failing after 1s
test / test-version-file-version (map[expected-version:0.5.15 version-file:__tests__/fixtures/.tool-versions]) (push) Failing after 2s
test / test-version-file-version (map[expected-version:0.6.17 version-file:__tests__/fixtures/uv-in-requirements-txt-project/requirements.txt]) (push) Failing after 2s
test / test-version-file-version (map[expected-version:0.8.3 version-file:__tests__/fixtures/uv-in-requirements-hash-txt-project/requirements.txt]) (push) Failing after 1s
test / test-malformed-pyproject-file-fallback (push) Failing after 1s
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Failing after 1s
test / test-with-explicit-token (push) Failing after 1s
test / test-uvx (push) Failing after 1s
test / test-tool-install (ubuntu-latest) (push) Failing after 1s
test / test-python-version (ubuntu-latest) (push) Failing after 1s
test / test-activate-environment (ubuntu-latest) (push) Failing after 2s
test / test-setup-cache (auto, ubuntu-latest) (push) Failing after 1s
test / test-setup-cache (false, ubuntu-latest) (push) Failing after 2s
test / test-setup-cache (true, ubuntu-latest) (push) Failing after 2s
test / test-setup-cache-requirements-txt (push) Failing after 2s
test / test-musl (push) Failing after 5s
test / test-restore-cache-requirements-txt (push) Has been skipped
test / test-setup-cache-dependency-glob (push) Failing after 2s
test / test-restore-cache-dependency-glob (push) Has been skipped
test / test-restore-cache-save-cache-false (push) Has been skipped
test / test-setup-cache-restore-cache-false (push) Failing after 1s
test / test-restore-cache-restore-cache-false (push) Has been skipped
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Failing after 2s
test / test-cache-local-cache-disabled (push) Failing after 4s
test / test-no-python-version (push) Failing after 5s
test / test-custom-manifest-file (push) Failing after 5s
test / test-absolute-path (push) Failing after 5s
test / test-relative-path (push) Failing after 5s
test / test-cache-prune-force (push) Failing after 5s
test / test-cache-dir-from-file (push) Failing after 5s
Release Drafter / ✏️ Draft release (push) Has been cancelled
test / test-default-version (macos-14) (push) Has been cancelled
test / test-default-version (macos-latest) (push) Has been cancelled
test / test-default-version (windows-latest) (push) Has been cancelled
test / test-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Has been cancelled
test / test-tool-install (macos-14) (push) Has been cancelled
test / test-tool-install (macos-latest) (push) Has been cancelled
test / test-tool-install (windows-latest) (push) Has been cancelled
test / test-tilde-expansion-tool-dirs (push) Has been cancelled
test / test-python-version (macos-latest) (push) Has been cancelled
test / test-python-version (windows-latest) (push) Has been cancelled
test / test-activate-environment (macos-latest) (push) Has been cancelled
test / test-activate-environment (windows-latest) (push) Has been cancelled
test / test-setup-cache (auto, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-setup-cache (auto, windows-latest) (push) Has been cancelled
test / test-setup-cache (false, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-setup-cache (false, windows-latest) (push) Has been cancelled
test / test-setup-cache (true, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-setup-cache (true, windows-latest) (push) Has been cancelled
test / test-cache-local (map[expected-cache-dir:/home/ubuntu/.cache/uv os:selfhosted-ubuntu-arm64]) (push) Has been cancelled
test / test-cache-local (map[expected-cache-dir:D:\a\_temp\setup-uv-cache os:windows-latest]) (push) Has been cancelled
test / test-setup-cache-local (push) Has been cancelled
test / test-tilde-expansion-cache-local-path (push) Has been cancelled
test / test-tilde-expansion-cache-dependency-glob (push) Has been cancelled
test / test-restore-cache (false, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache (false, windows-latest) (push) Has been cancelled
test / test-restore-cache (true, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-restore-cache (true, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache (true, windows-latest) (push) Has been cancelled
test / test-restore-cache (auto, windows-latest) (push) Has been cancelled
test / test-restore-cache (false, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-restore-cache (auto, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-restore-cache (auto, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache-local (push) Has been cancelled
test / cleanup-tilde-expansion-tests (push) Has been cancelled
test / all-tests-passed (push) Has been cancelled
Fixes: #583
This commit is contained in:
committed by
GitHub
parent
f610be5ff9
commit
535dc2664c
47
.github/workflows/test.yml
vendored
47
.github/workflows/test.yml
vendored
@@ -599,6 +599,7 @@ jobs:
|
||||
- name: Setup with cache
|
||||
uses: ./
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}-test-cache-local
|
||||
- run: |
|
||||
if [ "$UV_CACHE_DIR" != "${{ matrix.inputs.expected-cache-dir }}" ]; then
|
||||
@@ -607,6 +608,25 @@ jobs:
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
test-cache-local-cache-disabled:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Setup without cache
|
||||
uses: ./
|
||||
with:
|
||||
enable-cache: false
|
||||
|
||||
- name: Check UV_CACHE_DIR is not set
|
||||
run: |
|
||||
if [ -n "$UV_CACHE_DIR" ]; then
|
||||
echo "UV_CACHE_DIR should not be set when cache is disabled: $UV_CACHE_DIR"
|
||||
exit 1
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
test-setup-cache-local:
|
||||
runs-on: selfhosted-ubuntu-arm64
|
||||
steps:
|
||||
@@ -791,6 +811,31 @@ jobs:
|
||||
- run: uv run long-running.py &
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
|
||||
test-cache-dir-from-file:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Verify uv cache dir is not populated
|
||||
run: |
|
||||
if [ -f "/tmp/pyproject-toml-defined-cache-path/CACHEDIR.TAG" ]; then
|
||||
echo "Cache dir should not exist"
|
||||
exit 1
|
||||
fi
|
||||
- name: Setup uv
|
||||
uses: ./
|
||||
with:
|
||||
working-directory: __tests__/fixtures/cache-dir-defined-project
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/cache-dir-defined-project
|
||||
- name: Verify uv cache dir is populated
|
||||
run: |
|
||||
if [ ! -f "/tmp/pyproject-toml-defined-cache-path/CACHEDIR.TAG" ]; then
|
||||
echo "Cache dir should exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
all-tests-passed:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
@@ -811,6 +856,7 @@ jobs:
|
||||
- test-activate-environment
|
||||
- test-musl
|
||||
- test-cache-local
|
||||
- test-cache-local-cache-disabled
|
||||
- test-setup-cache
|
||||
- test-restore-cache
|
||||
- test-setup-cache-requirements-txt
|
||||
@@ -831,6 +877,7 @@ jobs:
|
||||
- test-absolute-path
|
||||
- test-relative-path
|
||||
- test-cache-prune-force
|
||||
- test-cache-dir-from-file
|
||||
if: always()
|
||||
steps:
|
||||
- name: All tests passed
|
||||
|
@@ -316,11 +316,18 @@ By default, the cache will be saved.
|
||||
|
||||
### Local cache path
|
||||
|
||||
This action controls where uv stores its cache on the runner's filesystem by setting `UV_CACHE_DIR`.
|
||||
If caching is enabled, this action controls where uv stores its cache on the runner's filesystem
|
||||
by setting `UV_CACHE_DIR`.
|
||||
|
||||
It defaults to `setup-uv-cache` in the `TMP` dir, `D:\a\_temp\uv-tool-dir` on Windows and
|
||||
`/tmp/setup-uv-cache` on Linux/macOS. You can change the default by specifying the path with the
|
||||
`cache-local-path` input.
|
||||
|
||||
> [!NOTE]
|
||||
> If the environment variable `UV_CACHE_DIR` is already set this action will not override it.
|
||||
> If you configured [cache-dir](https://docs.astral.sh/uv/reference/settings/#cache-dir) in your
|
||||
> config file then it is also respected and this action will not set `UV_CACHE_DIR`.
|
||||
|
||||
```yaml
|
||||
- name: Define a custom uv cache path
|
||||
uses: astral-sh/setup-uv@v6
|
||||
|
16
__tests__/fixtures/cache-dir-defined-project/pyproject.toml
Normal file
16
__tests__/fixtures/cache-dir-defined-project/pyproject.toml
Normal file
@@ -0,0 +1,16 @@
|
||||
[project]
|
||||
name = "uv-project"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"ruff>=0.6.2",
|
||||
]
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.uv]
|
||||
cache-dir = "/tmp/pyproject-toml-defined-cache-path"
|
@@ -0,0 +1,2 @@
|
||||
def hello() -> str:
|
||||
return "Hello from uv-project!"
|
38
__tests__/fixtures/cache-dir-defined-project/uv.lock
generated
Normal file
38
__tests__/fixtures/cache-dir-defined-project/uv.lock
generated
Normal file
@@ -0,0 +1,38 @@
|
||||
version = 1
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[[package]]
|
||||
name = "ruff"
|
||||
version = "0.6.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/23/f4/279d044f66b79261fd37df76bf72b64471afab5d3b7906a01499c4451910/ruff-0.6.2.tar.gz", hash = "sha256:239ee6beb9e91feb8e0ec384204a763f36cb53fb895a1a364618c6abb076b3be", size = 2460281 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/72/4b/47dd7a69287afb4069fa42c198e899463605460a58120196711bfcf0446b/ruff-0.6.2-py3-none-linux_armv6l.whl", hash = "sha256:5c8cbc6252deb3ea840ad6a20b0f8583caab0c5ef4f9cca21adc5a92b8f79f3c", size = 9695871 },
|
||||
{ url = "https://files.pythonhosted.org/packages/ae/c3/8aac62ac4638c14a740ee76a755a925f2d0d04580ab790a9887accb729f6/ruff-0.6.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:17002fe241e76544448a8e1e6118abecbe8cd10cf68fde635dad480dba594570", size = 9459354 },
|
||||
{ url = "https://files.pythonhosted.org/packages/2f/cf/77fbd8d4617b9b9c503f9bffb8552c4e3ea1a58dc36975e7a9104ffb0f85/ruff-0.6.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:3dbeac76ed13456f8158b8f4fe087bf87882e645c8e8b606dd17b0b66c2c1158", size = 9163871 },
|
||||
{ url = "https://files.pythonhosted.org/packages/05/1c/765192bab32b79efbb498b06f0b9dcb3629112b53b8777ae1d19b8209e09/ruff-0.6.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:094600ee88cda325988d3f54e3588c46de5c18dae09d683ace278b11f9d4d534", size = 10096250 },
|
||||
{ url = "https://files.pythonhosted.org/packages/08/d0/86f3cb0f6934c99f759c232984a5204d67a26745cad2d9edff6248adf7d2/ruff-0.6.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:316d418fe258c036ba05fbf7dfc1f7d3d4096db63431546163b472285668132b", size = 9475376 },
|
||||
{ url = "https://files.pythonhosted.org/packages/cd/cc/4c8d0e225b559a3fae6092ec310d7150d3b02b4669e9223f783ef64d82c0/ruff-0.6.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d72b8b3abf8a2d51b7b9944a41307d2f442558ccb3859bbd87e6ae9be1694a5d", size = 10295634 },
|
||||
{ url = "https://files.pythonhosted.org/packages/db/96/d2699cfb1bb5a01c68122af43454c76c31331e1c8a9bd97d653d7c82524b/ruff-0.6.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:2aed7e243be68487aa8982e91c6e260982d00da3f38955873aecd5a9204b1d66", size = 11024941 },
|
||||
{ url = "https://files.pythonhosted.org/packages/8b/a9/6ecd66af8929e0f2a1ed308a4137f3521789f28f0eb97d32c2ca3aa7000c/ruff-0.6.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d371f7fc9cec83497fe7cf5eaf5b76e22a8efce463de5f775a1826197feb9df8", size = 10606894 },
|
||||
{ url = "https://files.pythonhosted.org/packages/e4/73/2ee4cd19f44992fedac1cc6db9e3d825966072f6dcbd4032f21cbd063170/ruff-0.6.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a8f310d63af08f583363dfb844ba8f9417b558199c58a5999215082036d795a1", size = 11552886 },
|
||||
{ url = "https://files.pythonhosted.org/packages/60/4c/c0f1cd35ce4a93c54a6bb1ee6934a3a205fa02198dd076678193853ceea1/ruff-0.6.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7db6880c53c56addb8638fe444818183385ec85eeada1d48fc5abe045301b2f1", size = 10264945 },
|
||||
{ url = "https://files.pythonhosted.org/packages/c4/89/e45c9359b9cdd4245512ea2b9f2bb128a997feaa5f726fc9e8c7a66afadf/ruff-0.6.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:1175d39faadd9a50718f478d23bfc1d4da5743f1ab56af81a2b6caf0a2394f23", size = 10100007 },
|
||||
{ url = "https://files.pythonhosted.org/packages/06/74/0bd4e0a7ed5f6908df87892f9bf60a2356c0fd74102d8097298bd9b4f346/ruff-0.6.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:5b939f9c86d51635fe486585389f54582f0d65b8238e08c327c1534844b3bb9a", size = 9559267 },
|
||||
{ url = "https://files.pythonhosted.org/packages/54/03/3dc6dc9419f276f05805bf888c279e3e0b631284abd548d9e87cebb93aec/ruff-0.6.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:d0d62ca91219f906caf9b187dea50d17353f15ec9bb15aae4a606cd697b49b4c", size = 9905304 },
|
||||
{ url = "https://files.pythonhosted.org/packages/5c/5b/d6a72a6a6bbf097c09de468326ef5fa1c9e7aa5e6e45979bc0d984b0dbe7/ruff-0.6.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:7438a7288f9d67ed3c8ce4d059e67f7ed65e9fe3aa2ab6f5b4b3610e57e3cb56", size = 10341480 },
|
||||
{ url = "https://files.pythonhosted.org/packages/79/a9/0f2f21fe15ba537c46598f96aa9ae4a3d4b9ec64926664617ca6a8c772f4/ruff-0.6.2-py3-none-win32.whl", hash = "sha256:279d5f7d86696df5f9549b56b9b6a7f6c72961b619022b5b7999b15db392a4da", size = 7961901 },
|
||||
{ url = "https://files.pythonhosted.org/packages/b0/80/fff12ffe11853d9f4ea3e5221e6dd2e93640a161c05c9579833e09ad40a7/ruff-0.6.2-py3-none-win_amd64.whl", hash = "sha256:d9f3469c7dd43cd22eb1c3fc16926fb8258d50cb1b216658a07be95dd117b0f2", size = 8783320 },
|
||||
{ url = "https://files.pythonhosted.org/packages/56/91/577cdd64cce5e74d3f8b5ecb93f29566def569c741eb008aed4f331ef821/ruff-0.6.2-py3-none-win_arm64.whl", hash = "sha256:f28fcd2cd0e02bdf739297516d5643a945cc7caf09bd9bcb4d932540a5ea4fa9", size = 8225886 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uv-project"
|
||||
version = "0.1.0"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "ruff" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [{ name = "ruff" }]
|
997
dist/save-cache/index.js
generated
vendored
997
dist/save-cache/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
169
dist/setup/index.js
generated
vendored
169
dist/setup/index.js
generated
vendored
@@ -129387,6 +129387,7 @@ const core = __importStar(__nccwpck_require__(37484));
|
||||
const exec = __importStar(__nccwpck_require__(95236));
|
||||
const restore_cache_1 = __nccwpck_require__(95391);
|
||||
const download_version_1 = __nccwpck_require__(28255);
|
||||
const config_file_1 = __nccwpck_require__(27846);
|
||||
const constants_1 = __nccwpck_require__(56156);
|
||||
const inputs_1 = __nccwpck_require__(9612);
|
||||
const platforms_1 = __nccwpck_require__(98361);
|
||||
@@ -129409,7 +129410,7 @@ async function run() {
|
||||
setupPython();
|
||||
await activateEnvironment();
|
||||
addMatchers();
|
||||
setCacheDir(inputs_1.cacheLocalPath);
|
||||
setCacheDir();
|
||||
core.setOutput("uv-version", setupResult.version);
|
||||
core.saveState(constants_1.STATE_UV_VERSION, setupResult.version);
|
||||
core.info(`Successfully installed uv version ${setupResult.version}`);
|
||||
@@ -129537,9 +129538,16 @@ async function activateEnvironment() {
|
||||
core.exportVariable("VIRTUAL_ENV", path.resolve(`${inputs_1.workingDirectory}${path.sep}.venv`));
|
||||
}
|
||||
}
|
||||
function setCacheDir(cacheLocalPath) {
|
||||
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
|
||||
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
|
||||
function setCacheDir() {
|
||||
if (inputs_1.enableCache) {
|
||||
const cacheDirFromConfig = (0, config_file_1.getConfigValueFromTomlFile)("", "cache-dir");
|
||||
if (cacheDirFromConfig !== undefined) {
|
||||
core.info("Using cache-dir from uv config file, not modifying UV_CACHE_DIR");
|
||||
return;
|
||||
}
|
||||
core.exportVariable("UV_CACHE_DIR", inputs_1.cacheLocalPath);
|
||||
core.info(`Set UV_CACHE_DIR to ${inputs_1.cacheLocalPath}`);
|
||||
}
|
||||
}
|
||||
function addMatchers() {
|
||||
if (inputs_1.addProblemMatchers) {
|
||||
@@ -129550,6 +129558,67 @@ function addMatchers() {
|
||||
run();
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 27846:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getConfigValueFromTomlFile = getConfigValueFromTomlFile;
|
||||
const node_fs_1 = __importDefault(__nccwpck_require__(73024));
|
||||
const toml = __importStar(__nccwpck_require__(27106));
|
||||
function getConfigValueFromTomlFile(filePath, key) {
|
||||
if (!node_fs_1.default.existsSync(filePath) || !filePath.endsWith(".toml")) {
|
||||
return undefined;
|
||||
}
|
||||
const fileContent = node_fs_1.default.readFileSync(filePath, "utf-8");
|
||||
if (filePath.endsWith("pyproject.toml")) {
|
||||
const tomlContent = toml.parse(fileContent);
|
||||
return tomlContent?.tool?.uv?.[key];
|
||||
}
|
||||
const tomlContent = toml.parse(fileContent);
|
||||
return tomlContent[key];
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 56156:
|
||||
@@ -129642,6 +129711,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.addProblemMatchers = exports.manifestFile = exports.githubToken = exports.toolDir = exports.toolBinDir = exports.ignoreEmptyWorkdir = exports.ignoreNothingToCache = exports.pruneCache = exports.cacheDependencyGlob = exports.cacheLocalPath = exports.cacheSuffix = exports.saveCache = exports.restoreCache = exports.enableCache = exports.checkSum = exports.activateEnvironment = exports.pythonVersion = exports.versionFile = exports.version = exports.workingDirectory = void 0;
|
||||
const node_path_1 = __importDefault(__nccwpck_require__(76760));
|
||||
const core = __importStar(__nccwpck_require__(37484));
|
||||
const config_file_1 = __nccwpck_require__(27846);
|
||||
exports.workingDirectory = core.getInput("working-directory");
|
||||
exports.version = core.getInput("version");
|
||||
exports.versionFile = getVersionFile();
|
||||
@@ -129711,6 +129781,14 @@ function getCacheLocalPath() {
|
||||
const tildeExpanded = expandTilde(cacheLocalPathInput);
|
||||
return resolveRelativePath(tildeExpanded);
|
||||
}
|
||||
const cacheDirFromConfig = getCacheDirFromConfig();
|
||||
if (cacheDirFromConfig !== undefined) {
|
||||
return cacheDirFromConfig;
|
||||
}
|
||||
if (process.env.UV_CACHE_DIR !== undefined) {
|
||||
core.info(`UV_CACHE_DIR is already set to ${process.env.UV_CACHE_DIR}`);
|
||||
return process.env.UV_CACHE_DIR;
|
||||
}
|
||||
if (process.env.RUNNER_ENVIRONMENT === "github-hosted") {
|
||||
if (process.env.RUNNER_TEMP !== undefined) {
|
||||
return `${process.env.RUNNER_TEMP}${node_path_1.default.sep}setup-uv-cache`;
|
||||
@@ -129722,6 +129800,24 @@ function getCacheLocalPath() {
|
||||
}
|
||||
return `${process.env.HOME}${node_path_1.default.sep}.cache${node_path_1.default.sep}uv`;
|
||||
}
|
||||
function getCacheDirFromConfig() {
|
||||
for (const filePath of [exports.versionFile, "uv.toml", "pyproject.toml"]) {
|
||||
const resolvedPath = resolveRelativePath(filePath);
|
||||
try {
|
||||
const cacheDir = (0, config_file_1.getConfigValueFromTomlFile)(resolvedPath, "cache-dir");
|
||||
if (cacheDir !== undefined) {
|
||||
core.info(`Found cache-dir in ${resolvedPath}: ${cacheDir}`);
|
||||
return cacheDir;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
const message = err.message;
|
||||
core.warning(`Error while parsing ${filePath}: ${message}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function getCacheDependencyGlob() {
|
||||
const cacheDependencyGlobInput = core.getInput("cache-dependency-glob");
|
||||
if (cacheDependencyGlobInput !== "") {
|
||||
@@ -129888,67 +129984,6 @@ async function isMuslOs() {
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9931:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getRequiredVersionFromConfigFile = getRequiredVersionFromConfigFile;
|
||||
const node_fs_1 = __importDefault(__nccwpck_require__(73024));
|
||||
const toml = __importStar(__nccwpck_require__(27106));
|
||||
function getRequiredVersionFromConfigFile(filePath) {
|
||||
if (!filePath.endsWith(".toml")) {
|
||||
return undefined;
|
||||
}
|
||||
const fileContent = node_fs_1.default.readFileSync(filePath, "utf-8");
|
||||
if (filePath.endsWith("pyproject.toml")) {
|
||||
const tomlContent = toml.parse(fileContent);
|
||||
return tomlContent?.tool?.uv?.["required-version"];
|
||||
}
|
||||
const tomlContent = toml.parse(fileContent);
|
||||
return tomlContent["required-version"];
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4569:
|
||||
@@ -130068,7 +130103,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getUvVersionFromFile = getUvVersionFromFile;
|
||||
const node_fs_1 = __importDefault(__nccwpck_require__(73024));
|
||||
const core = __importStar(__nccwpck_require__(37484));
|
||||
const config_file_1 = __nccwpck_require__(9931);
|
||||
const config_file_1 = __nccwpck_require__(27846);
|
||||
const requirements_file_1 = __nccwpck_require__(4569);
|
||||
const tool_versions_file_1 = __nccwpck_require__(4895);
|
||||
function getUvVersionFromFile(filePath) {
|
||||
@@ -130081,7 +130116,7 @@ function getUvVersionFromFile(filePath) {
|
||||
try {
|
||||
uvVersion = (0, tool_versions_file_1.getUvVersionFromToolVersions)(filePath);
|
||||
if (uvVersion === undefined) {
|
||||
uvVersion = (0, config_file_1.getRequiredVersionFromConfigFile)(filePath);
|
||||
uvVersion = (0, config_file_1.getConfigValueFromTomlFile)(filePath, "required-version");
|
||||
}
|
||||
if (uvVersion === undefined) {
|
||||
uvVersion = (0, requirements_file_1.getUvVersionFromRequirementsFile)(filePath);
|
||||
|
@@ -8,6 +8,7 @@ import {
|
||||
resolveVersion,
|
||||
tryGetFromToolCache,
|
||||
} from "./download/download-version";
|
||||
import { getConfigValueFromTomlFile } from "./utils/config-file";
|
||||
import { STATE_UV_PATH, STATE_UV_VERSION } from "./utils/constants";
|
||||
import {
|
||||
activateEnvironment as activateEnvironmentInput,
|
||||
@@ -53,7 +54,7 @@ async function run(): Promise<void> {
|
||||
setupPython();
|
||||
await activateEnvironment();
|
||||
addMatchers();
|
||||
setCacheDir(cacheLocalPath);
|
||||
setCacheDir();
|
||||
|
||||
core.setOutput("uv-version", setupResult.version);
|
||||
core.saveState(STATE_UV_VERSION, setupResult.version);
|
||||
@@ -224,9 +225,18 @@ async function activateEnvironment(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
function setCacheDir(cacheLocalPath: string): void {
|
||||
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
|
||||
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
|
||||
function setCacheDir(): void {
|
||||
if (enableCache) {
|
||||
const cacheDirFromConfig = getConfigValueFromTomlFile("", "cache-dir");
|
||||
if (cacheDirFromConfig !== undefined) {
|
||||
core.info(
|
||||
"Using cache-dir from uv config file, not modifying UV_CACHE_DIR",
|
||||
);
|
||||
return;
|
||||
}
|
||||
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
|
||||
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
|
||||
}
|
||||
}
|
||||
|
||||
function addMatchers(): void {
|
||||
|
24
src/utils/config-file.ts
Normal file
24
src/utils/config-file.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import fs from "node:fs";
|
||||
import * as toml from "smol-toml";
|
||||
|
||||
export function getConfigValueFromTomlFile(
|
||||
filePath: string,
|
||||
key: string,
|
||||
): string | undefined {
|
||||
if (!fs.existsSync(filePath) || !filePath.endsWith(".toml")) {
|
||||
return undefined;
|
||||
}
|
||||
const fileContent = fs.readFileSync(filePath, "utf-8");
|
||||
|
||||
if (filePath.endsWith("pyproject.toml")) {
|
||||
const tomlContent = toml.parse(fileContent) as {
|
||||
tool?: { uv?: Record<string, string | undefined> };
|
||||
};
|
||||
return tomlContent?.tool?.uv?.[key];
|
||||
}
|
||||
const tomlContent = toml.parse(fileContent) as Record<
|
||||
string,
|
||||
string | undefined
|
||||
>;
|
||||
return tomlContent[key];
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
import path from "node:path";
|
||||
import * as core from "@actions/core";
|
||||
import { getConfigValueFromTomlFile } from "./config-file";
|
||||
|
||||
export const workingDirectory = core.getInput("working-directory");
|
||||
export const version = core.getInput("version");
|
||||
@@ -82,6 +83,14 @@ function getCacheLocalPath(): string {
|
||||
const tildeExpanded = expandTilde(cacheLocalPathInput);
|
||||
return resolveRelativePath(tildeExpanded);
|
||||
}
|
||||
const cacheDirFromConfig = getCacheDirFromConfig();
|
||||
if (cacheDirFromConfig !== undefined) {
|
||||
return cacheDirFromConfig;
|
||||
}
|
||||
if (process.env.UV_CACHE_DIR !== undefined) {
|
||||
core.info(`UV_CACHE_DIR is already set to ${process.env.UV_CACHE_DIR}`);
|
||||
return process.env.UV_CACHE_DIR;
|
||||
}
|
||||
if (process.env.RUNNER_ENVIRONMENT === "github-hosted") {
|
||||
if (process.env.RUNNER_TEMP !== undefined) {
|
||||
return `${process.env.RUNNER_TEMP}${path.sep}setup-uv-cache`;
|
||||
@@ -96,6 +105,24 @@ function getCacheLocalPath(): string {
|
||||
return `${process.env.HOME}${path.sep}.cache${path.sep}uv`;
|
||||
}
|
||||
|
||||
function getCacheDirFromConfig(): string | undefined {
|
||||
for (const filePath of [versionFile, "uv.toml", "pyproject.toml"]) {
|
||||
const resolvedPath = resolveRelativePath(filePath);
|
||||
try {
|
||||
const cacheDir = getConfigValueFromTomlFile(resolvedPath, "cache-dir");
|
||||
if (cacheDir !== undefined) {
|
||||
core.info(`Found cache-dir in ${resolvedPath}: ${cacheDir}`);
|
||||
return cacheDir;
|
||||
}
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
core.warning(`Error while parsing ${filePath}: ${message}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getCacheDependencyGlob(): string {
|
||||
const cacheDependencyGlobInput = core.getInput("cache-dependency-glob");
|
||||
if (cacheDependencyGlobInput !== "") {
|
||||
|
@@ -1,22 +0,0 @@
|
||||
import fs from "node:fs";
|
||||
import * as toml from "smol-toml";
|
||||
|
||||
export function getRequiredVersionFromConfigFile(
|
||||
filePath: string,
|
||||
): string | undefined {
|
||||
if (!filePath.endsWith(".toml")) {
|
||||
return undefined;
|
||||
}
|
||||
const fileContent = fs.readFileSync(filePath, "utf-8");
|
||||
|
||||
if (filePath.endsWith("pyproject.toml")) {
|
||||
const tomlContent = toml.parse(fileContent) as {
|
||||
tool?: { uv?: { "required-version"?: string } };
|
||||
};
|
||||
return tomlContent?.tool?.uv?.["required-version"];
|
||||
}
|
||||
const tomlContent = toml.parse(fileContent) as {
|
||||
"required-version"?: string;
|
||||
};
|
||||
return tomlContent["required-version"];
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
import * as core from "@actions/core";
|
||||
import { getRequiredVersionFromConfigFile } from "./config-file";
|
||||
import { getConfigValueFromTomlFile } from "../utils/config-file";
|
||||
import { getUvVersionFromRequirementsFile } from "./requirements-file";
|
||||
import { getUvVersionFromToolVersions } from "./tool-versions-file";
|
||||
|
||||
@@ -14,7 +14,7 @@ export function getUvVersionFromFile(filePath: string): string | undefined {
|
||||
try {
|
||||
uvVersion = getUvVersionFromToolVersions(filePath);
|
||||
if (uvVersion === undefined) {
|
||||
uvVersion = getRequiredVersionFromConfigFile(filePath);
|
||||
uvVersion = getConfigValueFromTomlFile(filePath, "required-version");
|
||||
}
|
||||
if (uvVersion === undefined) {
|
||||
uvVersion = getUvVersionFromRequirementsFile(filePath);
|
||||
|
Reference in New Issue
Block a user