Skip to content

Commit 763c3ea

Browse files
enforce proper encoding on lock file, mypy typing, and ruff tooling
1 parent 53b7131 commit 763c3ea

3 files changed

Lines changed: 64 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,45 @@ env:
1414
VCPKG_COMMIT: "66c0373dc7fca549e5803087b9487edfe3aca0a1"
1515

1616
jobs:
17+
python-lint:
18+
name: Python Linting (ruff)
19+
runs-on: ubuntu-24.04
20+
timeout-minutes: 10
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Validate Python lockfile
27+
shell: bash
28+
run: |
29+
set -euo pipefail
30+
LOCKFILE="requirements-lock.txt"
31+
test -f "$LOCKFILE"
32+
if od -An -tx1 "$LOCKFILE" | tr -s ' ' '\n' | grep -qx '00'; then
33+
echo "ERROR: $LOCKFILE contains NUL bytes (binary corruption)" >&2
34+
exit 1
35+
fi
36+
iconv -f UTF-8 -t UTF-8 "$LOCKFILE" > /dev/null 2>&1
37+
echo "OK: $LOCKFILE is valid UTF-8 and contains no NUL bytes"
38+
39+
- name: Setup Python and dependencies
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: "3.12"
43+
cache: "pip"
44+
cache-dependency-path: requirements-lock.txt
45+
46+
- name: Install Python dependencies
47+
run: |
48+
python -m pip install --upgrade pip
49+
python -m pip install -r requirements-lock.txt
50+
51+
- name: Run ruff checks
52+
run: |
53+
ruff check tests --output-format=github
54+
ruff format --check tests
55+
1756
python-typecheck:
1857
name: Python Type Checking (mypy)
1958
runs-on: ubuntu-24.04

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
[tool.ruff]
2+
line-length = 120
3+
target-version = "py312"
4+
exclude = [
5+
"build",
6+
"build-server",
7+
"build-windows-server",
8+
"build-windows-server-release",
9+
"build-test",
10+
"vcpkg_installed",
11+
]
12+
13+
[tool.ruff.lint]
14+
select = ["E", "F"]
15+
16+
[tool.ruff.format]
17+
quote-style = "double"
18+
indent-style = "space"
19+
skip-magic-trailing-comma = false
20+
line-ending = "auto"
21+
122
[tool.pytest.ini_options]
223
minversion = "7.0"
324
addopts = "--strict-markers -ra -vv --tb=short"

tests/conftest.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ def _find_server_executable(root: Path) -> Path:
3030
if path.exists() and path.is_file():
3131
return path.resolve()
3232
# Warn but fall back if env var points to nowhere
33-
print(
34-
f"WARNING: FLUXGRAPH_SERVER_EXE={env_path} does not exist. Falling back to search."
35-
)
33+
print(f"WARNING: FLUXGRAPH_SERVER_EXE={env_path} does not exist. Falling back to search.")
3634

3735
# Search common build locations
3836
names = ["fluxgraph-server.exe", "fluxgraph-server"]
@@ -112,11 +110,7 @@ def has_required_bindings(path: Path) -> bool:
112110
has_bindings = has_required_bindings(python_proto_dir)
113111

114112
if not has_bindings:
115-
missing = [
116-
filename
117-
for filename in required_files
118-
if not (python_proto_dir / filename).is_file()
119-
]
113+
missing = [filename for filename in required_files if not (python_proto_dir / filename).is_file()]
120114
pytest.fail(
121115
"Python protobuf bindings missing after generation.\n"
122116
f"Directory: {python_proto_dir}\n"
@@ -202,9 +196,7 @@ def get_logs(self) -> str:
202196

203197

204198
@pytest.fixture
205-
def fluxgraph_server(
206-
server_exe: Path, free_port: int, proto_bindings: Path
207-
) -> Iterator[ServerProcess]:
199+
def fluxgraph_server(server_exe: Path, free_port: int, proto_bindings: Path) -> Iterator[ServerProcess]:
208200
"""
209201
Start a fluxgraph-server instance on a random port.
210202
Yields a ServerProcess object.
@@ -228,9 +220,7 @@ def fluxgraph_server(
228220
stdout=subprocess.PIPE,
229221
stderr=subprocess.PIPE,
230222
text=True,
231-
cwd=str(
232-
_repo_root()
233-
), # Run from repo root so relative config paths work if needed
223+
cwd=str(_repo_root()), # Run from repo root so relative config paths work if needed
234224
)
235225
server = ServerProcess(proc, port)
236226

0 commit comments

Comments
 (0)