Skip to content

Commit

Permalink
Test installation using uv
Browse files Browse the repository at this point in the history
  • Loading branch information
evansd committed Oct 16, 2024
1 parent 40a0814 commit 831cb66
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install `uv`
uses: astral-sh/setup-uv@f3bcaebff5eace81a1c062af9f9011aae482ca9d # v3.1.7
with:
version: "0.4.20"
- name: Install dependencies
run: |
python -m pip install -r requirements.dev.txt
Expand Down
29 changes: 29 additions & 0 deletions tests/test_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,35 @@ def test_packaging(package_type, tmp_path, older_version_file):
assert "Successfully installed opensafely" in result.stdout


def test_installing_with_uv(tmp_path, older_version_file):
uv_bin = shutil.which("uv")
if uv_bin is None:
pytest.skip("Skipping as `uv` not installed")

package_path = build_package("bdist_wheel")
bin_path = tmp_path / "bin"
uv_env = dict(
os.environ,
UV_TOOL_BIN_DIR=bin_path,
UV_TOOL_DIR=tmp_path / "tools",
)
python_version = f"python{sys.version_info[0]}.{sys.version_info[1]}"
subprocess_run(
[uv_bin, "tool", "install", "--python", python_version, package_path],
env=uv_env,
check=True,
)
# Basic smoketest
subprocess_run([bin_path / "opensafely", "run", "--help"], check=True)
subprocess_run([bin_path / "opensafely", "--version"], check=True)
# The `upgrade` command should prompt the user to use `uv upgrade` instead
result = subprocess_run(
[bin_path / "opensafely", "upgrade"], capture_output=True, text=True
)
assert result.returncode != 0
assert "uv tool upgrade opensafely" in result.stdout


def build_package(package_type):
extension = {"sdist": "tar.gz", "bdist_wheel": "whl"}[package_type]
project_root = Path(__file__).parent.parent
Expand Down

0 comments on commit 831cb66

Please sign in to comment.