Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CLI tests

on:
pull_request:
types: [opened, synchronize, reopened]
branches: [staging]
push:
branches: [staging]

concurrency:
group: cli-tests-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Install dependencies
run: uv sync --extra dev

- name: Run end-to-end CLI tests against the live API
env:
JUDGMENT_API_KEY: ${{ secrets.JUDGMENT_STAGING_TEST_API_KEY }}
JUDGMENT_ORG_ID: ${{ secrets.JUDGMENT_STAGING_TEST_ORG_ID }}
JUDGMENT_BASE_URL: ${{ secrets.JUDGMENT_STAGING_BASE_URL }}
run: uv run pytest -v
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ dependencies = [
[project.optional-dependencies]
dev = [
"httpx",
"pytest>=7.0",
]

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-q"

[project.scripts]
judgment = "judgment_cli.main:main"

Expand Down
Empty file added tests/__init__.py
Empty file.
37 changes: 37 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""Shared fixtures and bootstrap for the live CLI E2E tests.

Loads ``cli/.env`` (if present) into ``os.environ`` so that subprocess
invocations of the CLI inherit the dev creds. In CI this is a no-op
because the GitHub Actions secrets are already in the env.
"""

from __future__ import annotations

import os
import sys
from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parent.parent
SRC_DIR = REPO_ROOT / "src"


def _load_dotenv(path: Path) -> None:
"""Minimal .env reader (no extra dependency)."""
if not path.exists():
return
for line in path.read_text().splitlines():
line = line.strip()
if not line or line.startswith("#"):
continue
key, sep, value = line.partition("=")
if not sep:
continue
key = key.strip()
value = value.strip().strip('"').strip("'")
os.environ.setdefault(key, value)


_load_dotenv(REPO_ROOT / ".env")

if str(SRC_DIR) not in sys.path:
sys.path.insert(0, str(SRC_DIR))
Loading