ci: add ruff static gate to make check and Gitea workflow
ci / check (push) Failing after 40s
ci / check (pull_request) Failing after 6s

Adds ruff as a dev dependency with an explicit py312 E/F rule set, so the
gate stays stable across ruff releases. make check now runs uv sync --frozen,
ruff, compileall, and pytest; make lint runs ruff alone.

The Gitea job splits the same checks into named steps for readable failures
and has a 10-minute timeout. No secrets, image push, or cluster access.
This commit is contained in:
Noel Sabia committed 2026-11-14 06:04:15 +01:00
1 parent 8656d9bc8a
commit 2b9617fd71
6 files changed
+63 -10

No files matched your search

+14 -4
View File
@@ -13,6 +13,7 @@ permissions:
jobs: jobs:
check: check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10
steps: steps:
- name: Check out - name: Check out
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -25,7 +26,16 @@ jobs:
- name: Install uv - name: Install uv
run: python -m pip install "uv==0.10.4" run: python -m pip install "uv==0.10.4"
# Same gate as local: uv sync --frozen, compileall src, pytest. # Same checks as local `make check`, split into steps for readable CI
# No secrets, no image push, no cluster access. # failures. No secrets, no image push, no cluster access.
- name: Check - name: Sync locked environment
run: make check run: uv sync --frozen
- name: Static analysis (ruff)
run: uv run ruff check src tests main.py
- name: Byte-compile
run: uv run python -m compileall src
- name: Tests
run: uv run pytest -q
+7 -2
View File
@@ -1,13 +1,14 @@
UV ?= uv UV ?= uv
.PHONY: help data train test check serve docker clean .PHONY: help data train test lint check serve docker clean
help: help:
@printf '%s\n' \ @printf '%s\n' \
'make data parse/clean the raw CSV, join weather + holidays, export JSON' \ 'make data parse/clean the raw CSV, join weather + holidays, export JSON' \
'make train fit the 28-day holdout model, export metrics/forecasts/model' \ 'make train fit the 28-day holdout model, export metrics/forecasts/model' \
'make test run pytest' \ 'make test run pytest' \
'make check CI gate: uv sync --frozen, compileall, pytest' \ 'make lint run ruff static checks' \
'make check CI gate: sync --frozen, ruff, compileall, pytest' \
'make serve run the FastAPI service on :8000' \ 'make serve run the FastAPI service on :8000' \
'make docker build the multi-stage image (pulsecast-ml:local)' \ 'make docker build the multi-stage image (pulsecast-ml:local)' \
'make clean remove caches and generated artifacts (keeps data/raw)' 'make clean remove caches and generated artifacts (keeps data/raw)'
@@ -21,8 +22,12 @@ train:
test: test:
$(UV) run pytest $(UV) run pytest
lint:
$(UV) run ruff check src tests main.py
check: check:
$(UV) sync --frozen $(UV) sync --frozen
$(UV) run ruff check src tests main.py
$(UV) run python -m compileall src $(UV) run python -m compileall src
$(UV) run pytest -q $(UV) run pytest -q
+2 -2
View File
@@ -48,7 +48,7 @@ uv sync
make data # needs the raw CSV, first run also fetches Open-Meteo weather make data # needs the raw CSV, first run also fetches Open-Meteo weather
make train # writes artifacts/model.joblib, metrics.json, forecasts.json make train # writes artifacts/model.joblib, metrics.json, forecasts.json
make test make test
make check # CI gate: uv sync --frozen, compileall, pytest make check # CI gate: sync --frozen, ruff, compileall, pytest
make serve # http://localhost:8000 make serve # http://localhost:8000
``` ```
@@ -153,7 +153,7 @@ src/pulsecast/
small.py busy classifier + flexible CSV parser small.py busy classifier + flexible CSV parser
retrain.py runtime forecast retraining from upload retrain.py runtime forecast retraining from upload
server.py FastAPI app and training job manager server.py FastAPI app and training job manager
tests/ schema, health, prediction, small-training job tests/ schema, bootstrap, health, prediction, small-training job
model_card.md features, split, baseline, ablation, limits, leakage model_card.md features, split, baseline, ablation, limits, leakage
``` ```
+9
View File
@@ -27,7 +27,16 @@ packages = ["src/pulsecast"]
testpaths = ["tests"] testpaths = ["tests"]
addopts = "-q" addopts = "-q"
[tool.ruff]
target-version = "py312"
line-length = 100
[tool.ruff.lint]
# Stable, fast static gate: syntax errors, undefined/unused names, imports.
select = ["E4", "E7", "E9", "F"]
[dependency-groups] [dependency-groups]
dev = [ dev = [
"pytest>=9.2.0", "pytest>=9.2.0",
"ruff>=0.17.5",
] ]
+1 -1
View File
@@ -19,7 +19,7 @@ SENSOR_KEYS = {"id", "name", "lat", "lon", "mean", "p95", "battery"}
def _timestamp(value: str) -> datetime: def _timestamp(value: str) -> datetime:
assert value.endswith("Z") assert value.endswith("Z")
return datetime.fromisoformat(value.replace("Z", "+00:00")) return datetime.fromisoformat(value)
def test_bootstrap_shape(client): def test_bootstrap_shape(client):
Generated
+30 -1
View File
@@ -441,6 +441,7 @@ dependencies = [
[package.dev-dependencies] [package.dev-dependencies]
dev = [ dev = [
{ name = "pytest" }, { name = "pytest" },
{ name = "ruff" },
] ]
[package.metadata] [package.metadata]
@@ -457,7 +458,10 @@ requires-dist = [
] ]
[package.metadata.requires-dev] [package.metadata.requires-dev]
dev = [{ name = "pytest", specifier = ">=9.2.0" }] dev = [
{ name = "pytest", specifier = ">=9.2.0" },
{ name = "ruff", specifier = ">=0.17.5" },
]
[[package]] [[package]]
name = "pyarrow" name = "pyarrow"
@@ -734,6 +738,31 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" }, { url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" },
] ]
[[package]]
name = "ruff"
version = "0.17.5"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/86/cc/7b71512eb8b49926efb887cc66c74dd993642943c29eba51a877f6b85692/ruff-0.17.5.tar.gz", hash = "sha256:625e57d80cd43352d12ea81690f3eac46cddc8c0f35026d137fb0f157f94592e", size = 5368382, upload-time = "2026-11-12T17:54:55.04Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d4/f2/61df414cb4338617290a9023ad09486e207fb9a6d09357a7be34f2e369a4/ruff-0.17.5-py3-none-linux_armv6l.whl", hash = "sha256:d511dd302982e46a285528942fa6557d57730edc4bdb9def95e86a2603d77396", size = 10231309, upload-time = "2026-11-12T17:54:09.314Z" },
{ url = "https://files.pythonhosted.org/packages/d1/72/8ed970f3361f7c8d3f8e1b3b1af27cf086bc4b3a6b62ec20e21a1aaaaff5/ruff-0.17.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b72fbc232e328bdbb9cdddf4f1aedcd61bd1aa64d75fc012114b4add0bd7f26b", size = 10250018, upload-time = "2026-11-12T17:54:11.983Z" },
{ url = "https://files.pythonhosted.org/packages/dc/4b/8b10f6c9d0a18413301ae8dd2af9d180a81bb738b1b731d944a37404c523/ruff-0.17.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:6f0db748508f04a04e3fbebcc636a5c8b3bd76274f8ed28f497c44d75c2ea2d7", size = 9504737, upload-time = "2026-11-12T17:54:14.567Z" },
{ url = "https://files.pythonhosted.org/packages/b7/ea/1b3afa3943239dede7a0755ea139bdb51879f0f3f96f92894081d5c7d2e5/ruff-0.17.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6f6a7b138edf9cc402ca736a59d9525e6d766e5395760b72e7e146e6251ac963", size = 10168006, upload-time = "2026-11-12T17:54:17.195Z" },
{ url = "https://files.pythonhosted.org/packages/31/08/ee641daa45f83792f91274b65796cb011f1065f588911bfa3909ad9e31e7/ruff-0.17.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e52622ecf3a0df9d03e796fe3eed4aa085adda65520db7e0619cbd2192a97342", size = 10043751, upload-time = "2026-11-12T17:54:19.815Z" },
{ url = "https://files.pythonhosted.org/packages/f8/cf/1c59fdb42d0b5671ad5b160636fab4005ee28db72cb06aef6e3f3c04f377/ruff-0.17.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54c0f67d1be11b55d12c184a819fc229f5eee3ef45c16c4fcad41258e83b4882", size = 10690562, upload-time = "2026-11-12T17:54:22.789Z" },
{ url = "https://files.pythonhosted.org/packages/49/c5/578074716173fb0c1591e9648a9f85c469888d9530cb35b89b757dc1208b/ruff-0.17.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dd0dfe7c6fe5a447fce467c58e69893be1d9a7e4378f5b9906432da33d94a97f", size = 11338465, upload-time = "2026-11-12T17:54:25.523Z" },
{ url = "https://files.pythonhosted.org/packages/aa/b9/d6428bcf5ed88f4dc1d6e3417ee350236ed36e7a35f9477b727c00e437bf/ruff-0.17.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ec4ecf40fb4d6e1265b009dbe551727920926fc0f769070c452d6d84b422a74d", size = 10895501, upload-time = "2026-11-12T17:54:28.441Z" },
{ url = "https://files.pythonhosted.org/packages/f2/8a/1e29c0c3785ae7e5cd0d54ee8717a08867ef71545796340be4c653c57e24/ruff-0.17.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40ca8afaac309b41a5b2e09e4e7beb1f824826b93c25697c4d74f573324fba4e", size = 10613231, upload-time = "2026-11-12T17:54:30.862Z" },
{ url = "https://files.pythonhosted.org/packages/32/b6/88944350c14bb90651014d678ad554e233ae2a79c14ad52101845f93d15b/ruff-0.17.5-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:8e85601bd6d9b6c3e3b95c0e0dccdbac1d23c6bcef006d187fbcddaf8225a5df", size = 10562789, upload-time = "2026-11-12T17:54:33.869Z" },
{ url = "https://files.pythonhosted.org/packages/6f/fd/2792e955b0bf54295cdcdddc4bb3f380c0790d7e60e789f528a9e6e48a31/ruff-0.17.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f93d2b7d449ed9545304f6923699ca20d13c675b69f258481709a08ae61076db", size = 10069824, upload-time = "2026-11-12T17:54:36.663Z" },
{ url = "https://files.pythonhosted.org/packages/07/9c/d7cad341b4c19237948a6dd1fcea1c9c39c9d08b70f22f0e157d1236ebd6/ruff-0.17.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0e5c125c5b31dc8efc948d41357496a4c4a312977565ccba740030efdff83580", size = 10038961, upload-time = "2026-11-12T17:54:39.452Z" },
{ url = "https://files.pythonhosted.org/packages/cc/a1/9cd0d4c371ddc70267d3bd557e718e2bdfb94c25e49d25605edfabb764bd/ruff-0.17.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:50dfc3c6b3ebd0a932f11dfd579bd42234b0b7137e68940eb6abdbfdb9d69697", size = 10385012, upload-time = "2026-11-12T17:54:41.808Z" },
{ url = "https://files.pythonhosted.org/packages/8f/a9/35f078ce98d4df318328ea5270382b5b65e680f7953b3db54f8e009c420c/ruff-0.17.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:86bd1f3b83c25f9b8055c6e796f0685b39d3127ce947322098c3108cf82fd586", size = 10793672, upload-time = "2026-11-12T17:54:44.342Z" },
{ url = "https://files.pythonhosted.org/packages/2c/a5/2e136dede2a88aaaf54498bbbdc81bc810f788ef6ef01efb97037d73cd1d/ruff-0.17.5-py3-none-win32.whl", hash = "sha256:e1546609b2ad73f1d6c5c076881b788672b7b3cc3283981182cbdbb6524ed88a", size = 9929908, upload-time = "2026-11-12T17:54:47.067Z" },
{ url = "https://files.pythonhosted.org/packages/ec/8c/e4db9ae1e0ee233c04df007ab6d0d42f799ae9abd95d352b6092ee7bc4bf/ruff-0.17.5-py3-none-win_amd64.whl", hash = "sha256:aa415d57c244299279901d776607fee3df7831c2a7435433fbfacde8632c6550", size = 10275454, upload-time = "2026-11-12T17:54:49.401Z" },
{ url = "https://files.pythonhosted.org/packages/e6/65/a1648bc1550e7683bf7bf1e2ce2485c9f8535cbca6cca9ec7b73cc12fb8e/ruff-0.17.5-py3-none-win_arm64.whl", hash = "sha256:64a6fd668a336df959c522991de33e9e3c8be463afc0c9ac8f029f9d19ef756e", size = 9849020, upload-time = "2026-11-12T17:54:52.055Z" },
]
[[package]] [[package]]
name = "scikit-learn" name = "scikit-learn"
version = "1.9.1" version = "1.9.1"