mirror of https://github.com/astral-sh/uv
Add case for `uv auth login` in registry integration tests (#15593)
Adds an alternative third-party registry test mode that uses `uv auth login` instead of the environment variables to provide configuration.
This commit is contained in:
parent
a13fb3ec64
commit
32bcfdff0a
|
|
@ -1779,8 +1779,32 @@ jobs:
|
||||||
echo "::add-mask::$UV_TEST_GCP_TOKEN"
|
echo "::add-mask::$UV_TEST_GCP_TOKEN"
|
||||||
echo "UV_TEST_GCP_TOKEN=$UV_TEST_GCP_TOKEN" >> $GITHUB_ENV
|
echo "UV_TEST_GCP_TOKEN=$UV_TEST_GCP_TOKEN" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: "Run registry tests"
|
- name: "Run registry tests with environment variable backend"
|
||||||
run: ./uv run -p "${PYTHON_VERSION}" scripts/registries-test.py --uv ./uv --color always --all
|
run: ./uv run -p "${PYTHON_VERSION}" scripts/registries-test.py --uv ./uv --color always --all --auth-method env
|
||||||
|
env:
|
||||||
|
RUST_LOG: uv=debug
|
||||||
|
UV_TEST_ARTIFACTORY_TOKEN: ${{ secrets.UV_TEST_ARTIFACTORY_TOKEN }}
|
||||||
|
UV_TEST_ARTIFACTORY_URL: ${{ secrets.UV_TEST_ARTIFACTORY_URL }}
|
||||||
|
UV_TEST_ARTIFACTORY_USERNAME: ${{ secrets.UV_TEST_ARTIFACTORY_USERNAME }}
|
||||||
|
UV_TEST_AWS_URL: ${{ secrets.UV_TEST_AWS_URL }}
|
||||||
|
UV_TEST_AWS_USERNAME: aws
|
||||||
|
UV_TEST_AZURE_TOKEN: ${{ secrets.UV_TEST_AZURE_TOKEN }}
|
||||||
|
UV_TEST_AZURE_URL: ${{ secrets.UV_TEST_AZURE_URL }}
|
||||||
|
UV_TEST_AZURE_USERNAME: dummy
|
||||||
|
UV_TEST_CLOUDSMITH_TOKEN: ${{ secrets.UV_TEST_CLOUDSMITH_TOKEN }}
|
||||||
|
UV_TEST_CLOUDSMITH_URL: ${{ secrets.UV_TEST_CLOUDSMITH_URL }}
|
||||||
|
UV_TEST_CLOUDSMITH_USERNAME: ${{ secrets.UV_TEST_CLOUDSMITH_USERNAME }}
|
||||||
|
UV_TEST_GCP_URL: ${{ secrets.UV_TEST_GCP_URL }}
|
||||||
|
UV_TEST_GCP_USERNAME: oauth2accesstoken
|
||||||
|
UV_TEST_GEMFURY_TOKEN: ${{ secrets.UV_TEST_GEMFURY_TOKEN }}
|
||||||
|
UV_TEST_GEMFURY_URL: ${{ secrets.UV_TEST_GEMFURY_URL }}
|
||||||
|
UV_TEST_GEMFURY_USERNAME: ${{ secrets.UV_TEST_GEMFURY_USERNAME }}
|
||||||
|
UV_TEST_GITLAB_TOKEN: ${{ secrets.UV_TEST_GITLAB_TOKEN }}
|
||||||
|
UV_TEST_GITLAB_URL: ${{ secrets.UV_TEST_GITLAB_URL }}
|
||||||
|
UV_TEST_GITLAB_USERNAME: token
|
||||||
|
|
||||||
|
- name: "Run registry tests with text store backend"
|
||||||
|
run: ./uv run -p "${PYTHON_VERSION}" scripts/registries-test.py --uv ./uv --color always --all --auth-method text-store
|
||||||
env:
|
env:
|
||||||
RUST_LOG: uv=debug
|
RUST_LOG: uv=debug
|
||||||
UV_TEST_ARTIFACTORY_TOKEN: ${{ secrets.UV_TEST_ARTIFACTORY_TOKEN }}
|
UV_TEST_ARTIFACTORY_TOKEN: ${{ secrets.UV_TEST_ARTIFACTORY_TOKEN }}
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,7 @@ def run_test(
|
||||||
verbosity: int,
|
verbosity: int,
|
||||||
timeout: int,
|
timeout: int,
|
||||||
requires_python: str,
|
requires_python: str,
|
||||||
|
auth_method: str,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
print(uv)
|
print(uv)
|
||||||
"""Attempt to install a package from this registry."""
|
"""Attempt to install a package from this registry."""
|
||||||
|
|
@ -189,19 +190,32 @@ def run_test(
|
||||||
f"** Using default test package name: {package}. To choose a different package, set UV_TEST_{registry_name.upper()}_PKG"
|
f"** Using default test package name: {package}. To choose a different package, set UV_TEST_{registry_name.upper()}_PKG"
|
||||||
)
|
)
|
||||||
print(f"\nAttempting to install {package}")
|
print(f"\nAttempting to install {package}")
|
||||||
|
|
||||||
|
if auth_method == "env":
|
||||||
env[f"UV_INDEX_{registry_name.upper()}_USERNAME"] = username
|
env[f"UV_INDEX_{registry_name.upper()}_USERNAME"] = username
|
||||||
env[f"UV_INDEX_{registry_name.upper()}_PASSWORD"] = token
|
env[f"UV_INDEX_{registry_name.upper()}_PASSWORD"] = token
|
||||||
|
elif auth_method == "text-store":
|
||||||
|
# Use uv's text store for authentication
|
||||||
|
subprocess.check_call(
|
||||||
|
[
|
||||||
|
uv,
|
||||||
|
"auth",
|
||||||
|
"login",
|
||||||
|
f"{registry_url}",
|
||||||
|
"--username",
|
||||||
|
username,
|
||||||
|
"--password",
|
||||||
|
token,
|
||||||
|
],
|
||||||
|
env=env,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Unknown authentication method: {auth_method}")
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as project_dir:
|
with tempfile.TemporaryDirectory() as project_dir:
|
||||||
setup_test_project(registry_name, registry_url, project_dir, requires_python)
|
setup_test_project(registry_name, registry_url, project_dir, requires_python)
|
||||||
|
|
||||||
cmd = [
|
cmd = [uv, "add", package, "--directory", project_dir, "--no-cache"]
|
||||||
uv,
|
|
||||||
"add",
|
|
||||||
package,
|
|
||||||
"--directory",
|
|
||||||
project_dir,
|
|
||||||
]
|
|
||||||
if verbosity:
|
if verbosity:
|
||||||
cmd.extend(["-" + "v" * verbosity])
|
cmd.extend(["-" + "v" * verbosity])
|
||||||
|
|
||||||
|
|
@ -297,6 +311,11 @@ def parse_args() -> argparse.Namespace:
|
||||||
default="3.12",
|
default="3.12",
|
||||||
help="minimum Python version for tests (default: 3.12)",
|
help="minimum Python version for tests (default: 3.12)",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--auth-method",
|
||||||
|
choices=["env", "text-store"],
|
||||||
|
default="env",
|
||||||
|
)
|
||||||
parser.add_argument("--color", choices=["always", "auto", "never"], default="auto")
|
parser.add_argument("--color", choices=["always", "auto", "never"], default="auto")
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
@ -371,6 +390,7 @@ def main() -> None:
|
||||||
args.verbose,
|
args.verbose,
|
||||||
args.timeout,
|
args.timeout,
|
||||||
args.required_python,
|
args.required_python,
|
||||||
|
args.auth_method,
|
||||||
):
|
):
|
||||||
passed.append(registry_name)
|
passed.append(registry_name)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue