Skip to content

Commit a63bf8d

Browse files
committed
fix(ci): resolve Python 3.13 null-byte path change; slim CI to 3.13; add lefthook
- paths: explicit null byte guard in project_db_path — Python 3.13 no longer raises from pathlib on null bytes, so the check must be ours - ci: drop Python matrix, run lint and test as parallel single jobs on 3.13; halves CI wall time and makes lint failures visible independently - lefthook: run ruff check on staged .py files before every commit; run pytest before every push
1 parent 8d7fe8d commit a63bf8d

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
name: CI
22
on: [push, pull_request]
33
jobs:
4-
test:
4+
lint:
55
runs-on: windows-2022
6-
strategy:
7-
fail-fast: false
8-
matrix:
9-
python-version: ["3.11", "3.12", "3.13"]
106
steps:
117
- uses: actions/checkout@v4
128
- uses: astral-sh/setup-uv@v3
13-
- name: Set up Python ${{ matrix.python-version }}
14-
run: uv python install ${{ matrix.python-version }}
15-
- name: Install
16-
run: uv sync --all-extras
9+
- run: uv python install 3.13
10+
- run: uv sync --all-extras
1711
- name: Lint
1812
run: uv run ruff check
1913
- name: Type check
2014
run: uv run mypy src
15+
16+
test:
17+
runs-on: windows-2022
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: astral-sh/setup-uv@v3
21+
- run: uv python install 3.13
22+
- run: uv sync --all-extras
2123
- name: Test
2224
run: uv run pytest

‎lefthook.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pre-commit:
2+
commands:
3+
lint:
4+
run: uv run ruff check {staged_files}
5+
glob: "*.py"
6+
7+
pre-push:
8+
commands:
9+
test:
10+
run: uv run pytest -q --tb=short

‎src/token_goat/paths.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def project_db_path(project_hash: str) -> Path:
6666
Raises ValueError if the resolved path escapes the projects/ subdirectory,
6767
which would happen with traversal sequences like ``../../../evil``.
6868
"""
69+
if "\x00" in project_hash:
70+
raise ValueError(f"project_hash contains null byte: {project_hash!r}")
6971
base = data_dir() / "projects"
7072
candidate = (base / f"{project_hash}.db").resolve()
7173
try:

0 commit comments

Comments
 (0)