Skip to content

Commit 0d9aa3d

Browse files
committed
Add test workflow for setup-python
1 parent f50e500 commit 0d9aa3d

File tree

5 files changed

+100
-13
lines changed

5 files changed

+100
-13
lines changed

.github/workflows/test.yml

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
with:
2626
persist-credentials: false
2727
- name: Actionlint
28-
uses: eifinger/actionlint-action@23c85443d840cd73bbecb9cddfc933cc21649a38 # v1.9.1
28+
uses: eifinger/actionlint-action@23c85443d840cd73bbecb9cddfc933cc21649a38 # v1.9.1
2929
- name: Run zizmor
3030
uses: zizmorcore/zizmor-action@e673c3917a1aef3c65c972347ed84ccd013ecda4 # v0.2.0
3131
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
@@ -269,13 +269,7 @@ jobs:
269269
runs-on: ${{ matrix.os }}
270270
strategy:
271271
matrix:
272-
os:
273-
[
274-
ubuntu-latest,
275-
macos-latest,
276-
macos-14,
277-
windows-latest,
278-
]
272+
os: [ubuntu-latest, macos-latest, macos-14, windows-latest]
279273
steps:
280274
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
281275
with:
@@ -334,7 +328,7 @@ jobs:
334328
runs-on: ${{ matrix.os }}
335329
strategy:
336330
matrix:
337-
os: [ ubuntu-latest, macos-latest, windows-latest ]
331+
os: [ubuntu-latest, macos-latest, windows-latest]
338332
steps:
339333
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
340334
with:
@@ -371,8 +365,8 @@ jobs:
371365
runs-on: ${{ matrix.os }}
372366
strategy:
373367
matrix:
374-
enable-cache: [ "true", "false", "auto" ]
375-
os: [ "ubuntu-latest", "selfhosted-ubuntu-arm64", "windows-latest" ]
368+
enable-cache: ["true", "false", "auto"]
369+
os: ["ubuntu-latest", "selfhosted-ubuntu-arm64", "windows-latest"]
376370
steps:
377371
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
378372
with:
@@ -389,8 +383,8 @@ jobs:
389383
runs-on: ${{ matrix.os }}
390384
strategy:
391385
matrix:
392-
enable-cache: [ "true", "false", "auto" ]
393-
os: [ "ubuntu-latest", "selfhosted-ubuntu-arm64", "windows-latest" ]
386+
enable-cache: ["true", "false", "auto"]
387+
os: ["ubuntu-latest", "selfhosted-ubuntu-arm64", "windows-latest"]
394388
needs: test-setup-cache
395389
steps:
396390
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -836,6 +830,45 @@ jobs:
836830
exit 1
837831
fi
838832
833+
test-cache-python-installs:
834+
runs-on: ubuntu-latest
835+
steps:
836+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
837+
with:
838+
persist-credentials: false
839+
- name: Verify Python install dir is not populated
840+
run: |
841+
if [ -d ~/.local/share/uv/python ]; then
842+
echo "Python install dir should not exist"
843+
exit 1
844+
fi
845+
- name: Setup uv with cache
846+
uses: ./
847+
with:
848+
enable-cache: true
849+
cache-python: true
850+
- run: uv sync
851+
working-directory: __tests__/fixtures/uv-project-pinned-python
852+
- name: Verify the correct Python version is installed
853+
run: |
854+
PYTHON_VERSION=$(.venv/bin/python -c "import sys; print(sys.version)")
855+
if [[ "$PYTHON_VERSION" != "3.13.3 *" ]]; then
856+
echo "Python version is not correct: $PYTHON_VERSION"
857+
exit 1
858+
fi
859+
- name: Verify Python install dir exists
860+
run: |
861+
if [ ! -d ~/.local/share/uv/python ]; then
862+
echo "Python install dir should exist"
863+
exit 1
864+
fi
865+
- name: Verify Python is installed in install dir
866+
run: |
867+
if [ ! -f ~/.local/share/uv/python/3.13.3/bin/python ]; then
868+
echo "Python binary does not exist"
869+
exit 1
870+
fi
871+
839872
all-tests-passed:
840873
runs-on: ubuntu-latest
841874
needs:

__tests__/fixtures/uv-project-pinned-python/README.md

Whitespace-only changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[project]
2+
name = "uv-project"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = "==3.13.3"
7+
dependencies = [
8+
"ruff>=0.6.2",
9+
]
10+
11+
[build-system]
12+
requires = ["hatchling"]
13+
build-backend = "hatchling.build"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def hello() -> str:
2+
return "Hello from uv-project!"

__tests__/fixtures/uv-project-pinned-python/uv.lock

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)