mirror of https://github.com/astral-sh/uv
Add smoke test script in Python (#11628)
I wanted to consolidate these anyway, and apparently it's a huge pain to make a Windows task fail early via GitHub's PowerShell setup so I implement this in Python instead.
This commit is contained in:
parent
6a13e4cedd
commit
a28db37f33
|
|
@ -740,6 +740,8 @@ jobs:
|
||||||
name: "smoke test | linux"
|
name: "smoke test | linux"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: "Download binary"
|
- name: "Download binary"
|
||||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
|
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
|
||||||
with:
|
with:
|
||||||
|
|
@ -752,9 +754,10 @@ jobs:
|
||||||
|
|
||||||
- name: "Smoke test"
|
- name: "Smoke test"
|
||||||
run: |
|
run: |
|
||||||
./uv venv -v
|
./uv run scripts/smoke-test
|
||||||
./uv pip install ruff -v
|
|
||||||
./uvx -v ruff --version
|
- name: "Test shell completions"
|
||||||
|
run: |
|
||||||
eval "$(./uv generate-shell-completion bash)"
|
eval "$(./uv generate-shell-completion bash)"
|
||||||
eval "$(./uvx --generate-shell-completion bash)"
|
eval "$(./uvx --generate-shell-completion bash)"
|
||||||
|
|
||||||
|
|
@ -779,14 +782,7 @@ jobs:
|
||||||
|
|
||||||
- name: "Smoke test"
|
- name: "Smoke test"
|
||||||
run: |
|
run: |
|
||||||
# Overwrite the 3.13.0 pin from the project, there are not functional
|
./uv run scripts/smoke-test
|
||||||
# musl distributions for it
|
|
||||||
./uv python pin 3.13
|
|
||||||
./uv venv -v
|
|
||||||
./uv pip install ruff -v
|
|
||||||
./uvx -v ruff --version
|
|
||||||
./uv pip install numpy -v
|
|
||||||
./uv run python -c "import numpy; print(numpy.__version__)"
|
|
||||||
|
|
||||||
smoke-test-macos:
|
smoke-test-macos:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
|
@ -794,6 +790,8 @@ jobs:
|
||||||
name: "smoke test | macos"
|
name: "smoke test | macos"
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: "Download binary"
|
- name: "Download binary"
|
||||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
|
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
|
||||||
with:
|
with:
|
||||||
|
|
@ -806,9 +804,10 @@ jobs:
|
||||||
|
|
||||||
- name: "Smoke test"
|
- name: "Smoke test"
|
||||||
run: |
|
run: |
|
||||||
./uv venv -v
|
./uv run scripts/smoke-test
|
||||||
./uv pip install ruff -v
|
|
||||||
./uvx -v ruff --version
|
- name: "Test shell completions"
|
||||||
|
run: |
|
||||||
eval "$(./uv generate-shell-completion bash)"
|
eval "$(./uv generate-shell-completion bash)"
|
||||||
eval "$(./uvx --generate-shell-completion bash)"
|
eval "$(./uvx --generate-shell-completion bash)"
|
||||||
|
|
||||||
|
|
@ -818,6 +817,8 @@ jobs:
|
||||||
name: "smoke test | windows x86_64"
|
name: "smoke test | windows x86_64"
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: "Download binary"
|
- name: "Download binary"
|
||||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
|
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
|
||||||
with:
|
with:
|
||||||
|
|
@ -826,10 +827,16 @@ jobs:
|
||||||
- name: "Smoke test"
|
- name: "Smoke test"
|
||||||
working-directory: ${{ env.UV_WORKSPACE }}
|
working-directory: ${{ env.UV_WORKSPACE }}
|
||||||
run: |
|
run: |
|
||||||
./uv venv -v
|
./uv run scripts/smoke-test
|
||||||
./uv pip install ruff -v
|
|
||||||
./uvx -v ruff --version
|
- name: "Test uv shell completions"
|
||||||
|
working-directory: ${{ env.UV_WORKSPACE }}
|
||||||
|
run: |
|
||||||
(& ./uv generate-shell-completion powershell) | Out-String | Invoke-Expression
|
(& ./uv generate-shell-completion powershell) | Out-String | Invoke-Expression
|
||||||
|
|
||||||
|
- name: "Test uvx shell completions"
|
||||||
|
working-directory: ${{ env.UV_WORKSPACE }}
|
||||||
|
run: |
|
||||||
(& ./uvx --generate-shell-completion powershell) | Out-String | Invoke-Expression
|
(& ./uvx --generate-shell-completion powershell) | Out-String | Invoke-Expression
|
||||||
|
|
||||||
smoke-test-windows-aarch64:
|
smoke-test-windows-aarch64:
|
||||||
|
|
@ -838,6 +845,8 @@ jobs:
|
||||||
name: "smoke test | windows aarch64"
|
name: "smoke test | windows aarch64"
|
||||||
runs-on: github-windows-11-aarch64-4
|
runs-on: github-windows-11-aarch64-4
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: "Download binary"
|
- name: "Download binary"
|
||||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
|
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
|
||||||
with:
|
with:
|
||||||
|
|
@ -846,13 +855,16 @@ jobs:
|
||||||
- name: "Smoke test"
|
- name: "Smoke test"
|
||||||
working-directory: ${{ env.UV_WORKSPACE }}
|
working-directory: ${{ env.UV_WORKSPACE }}
|
||||||
run: |
|
run: |
|
||||||
$ErrorActionPreference = "Stop"
|
./uv run scripts/smoke-test
|
||||||
$PSNativeCommandUseErrorActionPreference = $true
|
|
||||||
|
|
||||||
./uv venv -v
|
- name: "Test uv shell completions"
|
||||||
./uv pip install ruff -v
|
working-directory: ${{ env.UV_WORKSPACE }}
|
||||||
./uvx -v ruff --version
|
run: |
|
||||||
(& ./uv generate-shell-completion powershell) | Out-String | Invoke-Expression
|
(& ./uv generate-shell-completion powershell) | Out-String | Invoke-Expression
|
||||||
|
|
||||||
|
- name: "Test uvx shell completions"
|
||||||
|
working-directory: ${{ env.UV_WORKSPACE }}
|
||||||
|
run: |
|
||||||
(& ./uvx --generate-shell-completion powershell) | Out-String | Invoke-Expression
|
(& ./uvx --generate-shell-completion powershell) | Out-String | Invoke-Expression
|
||||||
|
|
||||||
integration-test-conda:
|
integration-test-conda:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import shlex
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
SELF_FILE = pathlib.Path(__file__)
|
||||||
|
COMMANDS_FILE = SELF_FILE.parent / "commands.sh"
|
||||||
|
|
||||||
|
|
||||||
|
def read_commands() -> list[list[str]]:
|
||||||
|
return [
|
||||||
|
shlex.split(line)
|
||||||
|
for line in COMMANDS_FILE.read_text().splitlines()
|
||||||
|
# Skip empty lines and comments
|
||||||
|
if line.strip() and not line.strip().startswith("#")
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def run_command(command: list[str]) -> subprocess.CompletedProcess:
|
||||||
|
env = os.environ.copy()
|
||||||
|
# Prepend either the parent uv path to the PATH or the current directory
|
||||||
|
env = {
|
||||||
|
**env,
|
||||||
|
"PATH": str(
|
||||||
|
pathlib.Path(env.get("UV")).parent if "UV" in env else pathlib.Path.cwd()
|
||||||
|
)
|
||||||
|
+ os.pathsep
|
||||||
|
+ env.get("PATH"),
|
||||||
|
}
|
||||||
|
return subprocess.run(command, capture_output=True, text=True, env=env)
|
||||||
|
|
||||||
|
|
||||||
|
def report_result(result: subprocess.CompletedProcess):
|
||||||
|
print("=============================================")
|
||||||
|
print(f"command: {' '.join(result.args)}")
|
||||||
|
print(f"exit code: {result.returncode}")
|
||||||
|
print()
|
||||||
|
print("------- stdout -------")
|
||||||
|
print(result.stdout)
|
||||||
|
print()
|
||||||
|
print("------- stderr -------")
|
||||||
|
print(result.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
results = [run_command(command) for command in read_commands()]
|
||||||
|
failed = sum(result.returncode != 0 for result in results)
|
||||||
|
for result in results:
|
||||||
|
report_result(result)
|
||||||
|
|
||||||
|
print("=============================================")
|
||||||
|
if failed:
|
||||||
|
print(f"FAILURE - {failed}/{len(results)} commands failed")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print(f"SUCCESS - {len(results)}/{len(results)} commands succeeded")
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
# NOTE this is not a real shell-script, it's parsed by `smoke-test/__main__.py` and executed
|
||||||
|
# serially via Python for cross-platform support.
|
||||||
|
|
||||||
|
# Use any Python 3.13 version
|
||||||
|
uv python pin 3.13
|
||||||
|
|
||||||
|
# Create a virtual environment and install a package with `uv pip`
|
||||||
|
uv venv -v
|
||||||
|
uv pip install ruff -v
|
||||||
|
|
||||||
|
# Install a package with extension modules, e.g., `numpy` and make sure it's importable
|
||||||
|
uv pip install numpy -v
|
||||||
|
uv run python -c "import numpy; print(numpy.__version__)"
|
||||||
|
|
||||||
|
# Run a package via `uvx`
|
||||||
|
uvx -v ruff --version
|
||||||
|
|
||||||
Loading…
Reference in New Issue