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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project follows the structure from Keep a Changelog and intends to use Sema

### Fixed

- **CLI flags no longer open the TUI:** `github-usage --export` / `--no-interactive` (and any other dashed argv, including `github-usage -v`) stay on the CLI when stdin and stdout are TTYs. Only a bare `github-usage` in a terminal launches the Textual app. `./start.sh -v` is unchanged because `start.sh` already maps `-v` to `--version` before Python routing.
- **Artifact storage partial failures:** a per-repo artifact API error no longer blanks the whole Actions Artifact Storage section — successfully scanned repos still render, and failed repos are listed as skipped in the text/HTML email and PDF exports.
- **Email Actions section:** plain-text and HTML emails show **private-repo quota** against the 2,000 min / 500 MB free tier (with public usage labeled free) instead of comparing combined account totals to the private quota. When no visibility split is available, the report says so explicitly rather than implying the total is all quota-counted.
- **Copilot AI credits:** email report data now reads GitHub's `…/billing/ai_credit/usage` endpoint (preferred over legacy premium-request usage after Copilot's 2026 metering change) and labels the email Copilot section and forecast row accordingly; org-licensed Copilot without personal usage gets an explanatory note. Usage displays **credit quantities** (`grossQuantity`) rather than dollar `netAmount`, which is often zero on included allowance. Failed usage API calls surface as report errors or notes instead of looking like zero usage. Forecast exports (CSV/XLSX/PDF/legacy) use the same Copilot metric label as email.
Expand Down
25 changes: 24 additions & 1 deletion scripts/check
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,30 @@ echo "==> Python syntax"
scripts/python -m py_compile github-usage src/github_usage/*.py

echo "==> Unit tests"
PYTHONPATH=src scripts/python -m unittest discover -s tests -v
unit_pid=""
cleanup_unit() {
if [ -n "${unit_pid}" ]; then
kill -9 "$unit_pid" 2>/dev/null || true
fi
}
trap cleanup_unit EXIT
PYTHONPATH=src scripts/python -m unittest discover -s tests -v </dev/null &
unit_pid=$!
i=0
while kill -0 "$unit_pid" 2>/dev/null; do
if [ "$i" -ge 180 ]; then
echo "unit tests exceeded 180s" >&2
kill -9 "$unit_pid" 2>/dev/null || true
wait "$unit_pid" 2>/dev/null || true
unit_pid=""
exit 1
fi
sleep 1
i=$((i + 1))
done
wait "$unit_pid"
unit_pid=""
trap - EXIT

echo "==> CLI smoke"
test -x start.sh
Expand Down
2 changes: 1 addition & 1 deletion scripts/coverage-check
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TOTAL_MIN="${COVERAGE_TOTAL_MIN:-75}"
FILE_MIN="${COVERAGE_FILE_MIN:-82}"

echo "==> Running tests under coverage (src only)"
PYTHONPATH=src scripts/python -m coverage run --source="$SRC" -m unittest discover -s tests
PYTHONPATH=src scripts/python -m coverage run --source="$SRC" -m unittest discover -s tests </dev/null

echo "==> Coverage report"
PYTHONPATH=src scripts/python -m coverage report
Expand Down
2 changes: 1 addition & 1 deletion src/github_usage/cli_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def route_entry(argv: Sequence[str]) -> RouteResult:
if cli_mode:
return RouteResult(handled=False, argv=stripped)

if sys.stdin.isatty() and sys.stdout.isatty():
if not stripped and sys.stdin.isatty() and sys.stdout.isatty():
return RouteResult(handled=True, argv=[], exit_code=run_tui())

if not stripped:
Expand Down
13 changes: 13 additions & 0 deletions tests/test_gui_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ def test_tty_default_launches_tui(self) -> None:
self.assertEqual(result.exit_code, 0)
run_tui.assert_called_once()

def test_dashed_argv_on_tty_skips_tui(self) -> None:
argv = ["--export", "json", "--no-interactive"]
with (
mock.patch("github_usage.cli_gui.run_tui", return_value=0) as run_tui,
mock.patch("sys.stdin.isatty", return_value=True),
mock.patch("sys.stdout.isatty", return_value=True),
mock.patch.dict(os.environ, {}, clear=True),
):
result = route_entry(argv)
self.assertFalse(result.handled)
self.assertEqual(result.argv, argv)
run_tui.assert_not_called()

def test_missing_gui_message_contains_venv_python(self) -> None:
self.assertIn("uv pip install --python .venv -e '.[gui]'", _MISSING_GUI_MESSAGE)

Expand Down
Loading