ae0e062fb4
* ci: enforce the file-size ceiling on pull requests `check-added-large-files` only ran in pre-commit, so the ceiling was absent from CI: an unhooked clone or `--no-verify` bypassed it entirely, and the hook is weaker than it looks even locally — it inspects only files being *added*, so an existing fixture that grows never trips it. Add `scripts/check_file_sizes.py`, wired into `make lint` and therefore the required `lint` check. It diffs against the base branch's merge base and measures additions, modifications and renames, leaving files already committed above the ceiling alone so no pull request fails for something it did not touch. An unresolvable base is a hard failure rather than a silent pass. The `lint` job now checks out with `fetch-depth: 0` to provide it. Lower the hook's `--maxkb` from 1024 to 640 to match, and pin the two limits equal in a unit test so they cannot drift back apart. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * ci: catch untracked oversized files in the size gate `git diff` cannot see a newly created file until it is staged, so a local `make check-file-sizes` passed a brand-new 700 KB file — verified against the real script, not reasoned about. CI was unaffected (its checkout has everything committed), but the docstring claimed the local run covered uncommitted work, which was only true for edits to already-tracked files. Union in `git ls-files --others --exclude-standard`, which respects .gitignore, and pin both the untracked and the ignored case in tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * ci: exempt the generated search-seed corpora from the size ceiling tests/fixtures/search_seed/ holds embedded corpora regenerated by _dump_search_seed.py. Two of them are already near 1 MB and grew ~60% in one release, so the next refresh would have hit the 640 KB ceiling and the cheapest fix would have been raising it for the whole repository — a gate that teaches people to edit the gate. Exempt that one directory by path prefix instead. Outside it the largest tracked file is ~300 KB, so 640 KB still binds where it matters, including the examples/ case that prompted this work. Three tests pin the carve-out: a sibling of the exempt directory is still caught, the list itself is asserted verbatim so growth shows up in review, and every prefix must name a directory that actually exists. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: zhanghui <zhanghui@shanda.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
138 lines
6.1 KiB
Makefile
138 lines
6.1 KiB
Makefile
.PHONY: help install install-deps lint docs-check check-commits check-pr-title check-assets check-file-sizes check-deprecated-names check-github-docs check-cjk check-datetime openapi check-openapi format test integration package cov ci clean
|
|
|
|
help:
|
|
@echo "Targets:"
|
|
@echo " install Install deps + pre-commit hooks (full dev setup)"
|
|
@echo " install-deps Install deps only (uv sync --frozen, used by CI)"
|
|
@echo " lint ruff (check + format-check) + import-linter + datetime discipline + openapi drift"
|
|
@echo " docs-check Validate Markdown links, use-case banners, and issue template YAML"
|
|
@echo " check-commits Validate Conventional Commit subjects for a git range"
|
|
@echo " check-pr-title Validate PR title uses Conventional Commit format"
|
|
@echo " check-assets Block committed images, videos, and asset/media directories"
|
|
@echo " check-file-sizes Block committed files above the size ceiling (HARD gate, run via lint)"
|
|
@echo " check-deprecated-names Block deprecated product names"
|
|
@echo " check-github-docs Block legacy/internal branch-model residue in contributor docs"
|
|
@echo " check-cjk Scan for CJK outside the language-policy allowlist (advisory)"
|
|
@echo " check-datetime Scan for code that bypasses component/utils/datetime (HARD gate, run via lint)"
|
|
@echo " openapi Regenerate docs/openapi.json from the FastAPI app"
|
|
@echo " check-openapi Verify docs/openapi.json matches app.openapi() (HARD gate, run via lint)"
|
|
@echo " format Format src/tests with ruff"
|
|
@echo " test pytest tests/unit"
|
|
@echo " integration pytest tests/integration"
|
|
@echo " package Build sdist/wheel and smoke-test wheel import"
|
|
@echo " cov pytest tests/unit + tests/integration with coverage (fail under 80%)"
|
|
@echo " ci full CI: lint + test + integration + package"
|
|
@echo " clean Remove caches"
|
|
|
|
# Sync deps from uv.lock; CI calls this directly. --frozen means "lock is the
|
|
# source of truth — fail rather than update it".
|
|
install-deps:
|
|
uv sync --frozen
|
|
|
|
# One-stop dev setup: deps + pre-commit hooks (both pre-commit and commit-msg
|
|
# stages — gitlint runs on commit-msg).
|
|
install: install-deps
|
|
uv run pre-commit install
|
|
uv run pre-commit install --hook-type commit-msg
|
|
|
|
lint:
|
|
uv run ruff check src tests
|
|
uv run ruff format --check src tests
|
|
uv run lint-imports
|
|
uv run python scripts/check_repo_assets.py
|
|
uv run python scripts/check_file_sizes.py
|
|
uv run python scripts/check_deprecated_names.py
|
|
uv run python scripts/check_github_contributor_docs.py
|
|
uv run python scripts/check_datetime_discipline.py
|
|
uv run python scripts/dump_openapi.py --check
|
|
|
|
docs-check:
|
|
python3 scripts/check_docs.py
|
|
python3 scripts/check_github_contributor_docs.py
|
|
ruby -e 'require "yaml"; Dir[".github/ISSUE_TEMPLATE/*.yml"].sort.each { |p| YAML.load_file(p); puts "YAML ok: #{p}" }'
|
|
|
|
check-commits:
|
|
python3 scripts/check_commit_messages.py $(RANGE)
|
|
|
|
check-pr-title:
|
|
python3 scripts/check_pr_title.py
|
|
|
|
# Repository media hygiene gate. Images/videos belong in external hosting,
|
|
# release artifacts, or other approved storage, then linked from docs.
|
|
check-assets:
|
|
uv run python scripts/check_repo_assets.py
|
|
|
|
# Repository file size gate (wired into `lint`, and therefore `ci`). Mirrors
|
|
# the `check-added-large-files` pre-commit hook so the ceiling is enforced on
|
|
# every PR, not only on machines that installed the hooks. Scope is the change
|
|
# under review (diff vs the base branch), so existing files are left alone —
|
|
# needs `fetch-depth: 0` in CI to resolve the merge base.
|
|
check-file-sizes:
|
|
uv run python scripts/check_file_sizes.py
|
|
|
|
# Product naming gate. Public repo text should use EverOS or EverMind Cloud.
|
|
check-deprecated-names:
|
|
uv run python scripts/check_deprecated_names.py
|
|
|
|
# GitHub contributor-doc gate. Public contribution guidance must target the
|
|
# GitHub `main` workflow, not an internal branch model.
|
|
check-github-docs:
|
|
uv run python scripts/check_github_contributor_docs.py
|
|
|
|
# Advisory CJK scan (see .claude/rules/language-policy.md). Deliberately NOT
|
|
# wired into `lint` / `ci`: the policy is enforced by review and the rules
|
|
# doc, not a hard gate. Run on demand when touching potentially-CJK files.
|
|
check-cjk:
|
|
uv run python scripts/check_cjk.py
|
|
|
|
# Datetime two-zone discipline scanner (see .claude/rules/datetime-handling.md).
|
|
# Wired into `lint` (and therefore `ci`) as a HARD gate — any code that
|
|
# bypasses ``component/utils/datetime`` (raw ``datetime.now()``,
|
|
# ``time.time()``, naked ``datetime(...)`` constructor, etc.) fails the build.
|
|
check-datetime:
|
|
uv run python scripts/check_datetime_discipline.py
|
|
|
|
# OpenAPI schema export — produce docs/openapi.json from the FastAPI app.
|
|
# Run this after touching any HTTP route / DTO; commit the result.
|
|
openapi:
|
|
uv run python scripts/dump_openapi.py
|
|
|
|
# OpenAPI drift gate (wired into `lint`). Re-renders the schema in memory
|
|
# and diffs it against the committed ``docs/openapi.json``; any drift
|
|
# fails the build with a unified diff. Forces the contract doc to track
|
|
# the code on every PR that touches the API surface.
|
|
check-openapi:
|
|
uv run python scripts/dump_openapi.py --check
|
|
|
|
format:
|
|
uv run ruff check --fix src tests
|
|
uv run ruff format src tests
|
|
|
|
test:
|
|
uv run pytest tests/unit -v
|
|
|
|
integration:
|
|
uv run pytest tests/integration -v
|
|
|
|
package:
|
|
rm -rf dist .package-smoke
|
|
uv build --sdist --wheel
|
|
uv venv --python 3.12 --seed .package-smoke
|
|
uv pip install --python .package-smoke/bin/python --no-deps dist/*.whl
|
|
.package-smoke/bin/python -c "import everos; print(everos.__version__)"
|
|
rm -rf .package-smoke
|
|
|
|
# Coverage runs unit + integration so the number matches what CI's `test` and
|
|
# `integration` jobs actually exercise. Threshold starts at 80% (unit-only is
|
|
# currently 87%, unit+integration 91% — 80% leaves ~10pp headroom for normal
|
|
# churn). Bump as the suite stabilises.
|
|
cov:
|
|
uv run pytest tests/unit tests/integration --cov=src/everos --cov-report=term-missing --cov-branch --cov-fail-under=80
|
|
|
|
ci: lint test integration package
|
|
|
|
clean:
|
|
rm -rf .pytest_cache .ruff_cache .uv-cache .mypy_cache .coverage htmlcov .package-smoke
|
|
find . -type d -name __pycache__ -exec rm -rf {} +
|
|
find . -type f -name '*.pyc' -delete
|