diff --git a/.agents/README.en.md b/.agents/README.en.md new file mode 100644 index 0000000..2fde6aa --- /dev/null +++ b/.agents/README.en.md @@ -0,0 +1,12 @@ +# Agent rules + +[Русский](README.md) | English + +This directory contains rules for development, validation, and sharing work between agents. The common entry point is [AGENTS.md](../AGENTS.md); [AGENTS_ROUTING.md](../AGENTS_ROUTING.md) selects the relevant rules. + +- `standards/` defines requirements for code, contracts, infrastructure, and tests. +- `workflows/` describes development, validation, release, and collaboration. +- `templates/` contains task and handoff templates. +- `sources-of-truth.md` and `ownership.md` define decision sources and file ownership. + +Operational instructions are maintained in English. This README is a short directory guide for the team. diff --git a/.agents/README.md b/.agents/README.md new file mode 100644 index 0000000..94abd0a --- /dev/null +++ b/.agents/README.md @@ -0,0 +1,12 @@ +# Правила работы агентов + +Русский | [English](README.en.md) + +Здесь хранятся правила разработки, проверки изменений и распределения работы между агентами. Общая точка входа - [AGENTS.md](../AGENTS.md), выбор нужных правил описан в [AGENTS_ROUTING.md](../AGENTS_ROUTING.md). + +- `standards/` - требования к коду, контрактам, инфраструктуре и тестам. +- `workflows/` - порядок разработки, проверки, выпуска и совместной работы. +- `templates/` - шаблоны задания и отчета о выполнении. +- `sources-of-truth.md` и `ownership.md` - источники решений и границы владения файлами. + +Рабочие инструкции ведутся на английском. Этот README кратко описывает каталог для участников команды. diff --git a/Makefile b/Makefile index 82d1884..54897ad 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,7 @@ check-generated: ## Fail when generated files differ from committed output @python3 scripts/check-generated.py docs-check: ## Check documentation structure and local links + @PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts -p 'test_docs_check.py' @python3 scripts/docs-check.py security: ## Run dependency, source, and secret checks diff --git a/README.en.md b/README.en.md index 6b267b0..7d8f93e 100644 --- a/README.en.md +++ b/README.en.md @@ -25,6 +25,23 @@ The root Makefile provides install, generate, fmt, fmt-check, lint, test, check, ## Documentation +Short directory guides: + +| Directory | Purpose | +| --- | --- | +| [api/](api/README.en.md) | Shared OpenAPI contracts | +| [backend/](backend/README.en.md) | Main Go service | +| [frontend/](frontend/README.en.md) | React and TypeScript interface | +| [ml/](ml/README.en.md) | Separate Python service for ML | +| [deploy/](deploy/README.en.md) | Docker Compose, Nginx, and service startup | +| [observability/](observability/README.en.md) | Metrics, logs, and dashboards | +| [security/](security/README.en.md) | Security scanners and rules | +| [docs/](docs/README.en.md) | Detailed Russian and English guides | +| [requirements/](requirements/README.en.md) | Original specification and brand assets | +| [scripts/](scripts/README.en.md) | Shared code generation and validation scripts | +| [.github/](.github/workflows/) | GitHub Actions workflows | +| [.agents/](.agents/README.en.md) | Agent rules | + - Source materials: [specification](requirements/specification.pdf), [brandbook](requirements/brandbook/). - Russian: [architecture](docs/ru/ARCHITECTURE.md), [development](docs/ru/DEVELOPMENT.md), [deployment](docs/ru/DEPLOY.md), [testing](docs/ru/TESTING.md), [security](docs/ru/SECURITY.md) - English: [architecture](docs/en/ARCHITECTURE.md), [development](docs/en/DEVELOPMENT.md), [deployment](docs/en/DEPLOY.md), [testing](docs/en/TESTING.md), [security](docs/en/SECURITY.md) diff --git a/README.md b/README.md index 5c54bf1..8c2c6cb 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,23 @@ Grafana доступна на локальной машине по адресу ## Документация +Краткие описания каталогов: + +| Каталог | Назначение | +| --- | --- | +| [api/](api/README.md) | Общие OpenAPI-контракты | +| [backend/](backend/README.md) | Основной сервис на Go | +| [frontend/](frontend/README.md) | Интерфейс на React и TypeScript | +| [ml/](ml/README.md) | Отдельный Python-сервис для ML | +| [deploy/](deploy/README.md) | Docker Compose, Nginx и запуск сервисов | +| [observability/](observability/README.md) | Метрики, логи и дашборды | +| [security/](security/README.md) | Сканеры и правила безопасности | +| [docs/](docs/README.md) | Подробные руководства на русском и английском | +| [requirements/](requirements/README.md) | Исходное ТЗ и брендбук | +| [scripts/](scripts/README.md) | Общие скрипты кодогенерации и проверок | +| [.github/](.github/workflows/) | Workflow GitHub Actions | +| [.agents/](.agents/README.md) | Правила работы агентов | + - Исходные материалы: [ТЗ](requirements/specification.pdf), [брендбук](requirements/brandbook/). - На русском: [архитектура](docs/ru/ARCHITECTURE.md), [разработка](docs/ru/DEVELOPMENT.md), [развертывание](docs/ru/DEPLOY.md), [тестирование](docs/ru/TESTING.md), [безопасность](docs/ru/SECURITY.md). - На английском: [архитектура](docs/en/ARCHITECTURE.md), [разработка](docs/en/DEVELOPMENT.md), [развертывание](docs/en/DEPLOY.md), [тестирование](docs/en/TESTING.md), [безопасность](docs/en/SECURITY.md). diff --git a/api/README.en.md b/api/README.en.md new file mode 100644 index 0000000..a738156 --- /dev/null +++ b/api/README.en.md @@ -0,0 +1,15 @@ +# API contracts + +[Русский](README.md) | English + +Shared OpenAPI contracts for Go, the frontend, and ML. Contract changes come first; consumers then generate their types, server code, and clients from them. + +- `core/` defines the main backend's public API. +- `ml/` defines the ML service's internal HTTP API. +- `testdata/` contains a specification for checking tool compatibility with OpenAPI 3.2.0. + +Routes live in `routes/` and schemas in `components/`. The `openapi.bundle.yml` files are built automatically. Generator configuration lives in `backend/codegen/`, `frontend/codegen/`, and `ml/codegen/`. + +From the repository root, `make -C api check` checks contracts and `make generate` updates all generated code. + +See the [development guide](../docs/en/DEVELOPMENT.md). diff --git a/api/README.md b/api/README.md new file mode 100644 index 0000000..d17bea6 --- /dev/null +++ b/api/README.md @@ -0,0 +1,15 @@ +# Контракты API + +Русский | [English](README.en.md) + +Общие OpenAPI-контракты для Go, frontend и ML. Сначала изменяется контракт, затем из него генерируются типы, серверный код и клиенты нужных сервисов. + +- `core/` - публичный API основного backend. +- `ml/` - внутренний HTTP API ML-сервиса. +- `testdata/` - спецификация для проверки совместимости инструментов с OpenAPI 3.2.0. + +Маршруты лежат в `routes/`, схемы - в `components/`. Файлы `openapi.bundle.yml` собираются автоматически. Конфигурации генераторов находятся в `backend/codegen/`, `frontend/codegen/` и `ml/codegen/`. + +Из корня: `make -C api check` проверяет контракты, `make generate` обновляет весь сгенерированный код. + +Подробнее: [разработка](../docs/ru/DEVELOPMENT.md). diff --git a/backend/README.en.md b/backend/README.en.md new file mode 100644 index 0000000..2a1a87d --- /dev/null +++ b/backend/README.en.md @@ -0,0 +1,15 @@ +# Go backend + +[Русский](README.md) | English + +The main service uses Go, chi, and Clean Architecture. It currently provides health checks and PostgreSQL, Redis, and SeaweedFS adapters; hiring workflows are still to be implemented. + +- `cmd/app/` is the entry point; `internal/bootstrap/` wires dependencies and manages startup. +- `internal/` contains domain types, use cases, ports, and primary/secondary adapters. +- `config/` holds application settings; `pkg/` is for shared helper packages. +- `db/` and `codegen/` hold SQL queries, migrations, and generator configuration. +- `integration_test/` checks real dependencies through Testcontainers. + +From the repository root, `make -C backend check` runs the main checks and `make -C backend test-int` runs integration tests with Docker. Use `make -C backend help` for all commands. + +See [architecture](../docs/en/ARCHITECTURE.md) and [development](../docs/en/DEVELOPMENT.md). diff --git a/backend/README.md b/backend/README.md new file mode 100644 index 0000000..96a0592 --- /dev/null +++ b/backend/README.md @@ -0,0 +1,15 @@ +# Go backend + +Русский | [English](README.en.md) + +Основной сервис на Go и chi с Clean Architecture. Сейчас реализованы проверки состояния, адаптеры PostgreSQL, Redis и SeaweedFS; продуктовые сценарии найма еще предстоит добавить. + +- `cmd/app/` - точка входа; `internal/bootstrap/` собирает зависимости и управляет запуском. +- `internal/` - доменные типы, use case, порты и primary/secondary адаптеры. +- `config/` - настройки приложения; `pkg/` - общие вспомогательные пакеты. +- `db/` и `codegen/` - SQL-запросы, миграции и настройки генераторов. +- `integration_test/` - проверки с настоящими зависимостями через Testcontainers. + +Из корня: `make -C backend check` запускает основные проверки, `make -C backend test-int` - интеграционные тесты с Docker. Все команды доступны через `make -C backend help`. + +Подробнее: [архитектура](../docs/ru/ARCHITECTURE.md) и [разработка](../docs/ru/DEVELOPMENT.md). diff --git a/deploy/README.en.md b/deploy/README.en.md new file mode 100644 index 0000000..25dd290 --- /dev/null +++ b/deploy/README.en.md @@ -0,0 +1,14 @@ +# Deployment + +[Русский](README.md) | English + +Configuration for running the application with Docker Compose and Nginx. + +- `docker/docker-compose.yml` starts the core stack with PostgreSQL, Redis, and SeaweedFS. +- `docker/docker-compose.ml.yml` and `docker/docker-compose.monitoring.yml` run ML and monitoring as separate projects. +- `nginx/` configures frontend serving and API proxying. +- `scripts/` contains the isolated stack smoke check. + +Dockerfiles live in service directories and `.env.example` at the repository root. From the root, `make -C deploy config` checks Compose and `make -C deploy up` starts the core stack after `.env` is prepared. Start monitoring separately with `make -C deploy monitoring-up`. + +See the [deployment guide](../docs/en/DEPLOY.md). diff --git a/deploy/README.md b/deploy/README.md new file mode 100644 index 0000000..0f6316e --- /dev/null +++ b/deploy/README.md @@ -0,0 +1,14 @@ +# Развертывание + +Русский | [English](README.en.md) + +Конфигурация запуска через Docker Compose и Nginx. + +- `docker/docker-compose.yml` поднимает основной стек с PostgreSQL, Redis и SeaweedFS. +- `docker/docker-compose.ml.yml` и `docker/docker-compose.monitoring.yml` запускают ML и мониторинг отдельными проектами. +- `nginx/` содержит конфигурацию раздачи frontend и проксирования API. +- `scripts/` содержит smoke-проверку изолированного стека. + +Dockerfile лежат в каталогах сервисов, `.env.example` - в корне репозитория. Из корня: `make -C deploy config` проверяет Compose, `make -C deploy up` запускает основной стек после подготовки `.env`. Мониторинг включается отдельно через `make -C deploy monitoring-up`. + +Подробнее: [развертывание](../docs/ru/DEPLOY.md). diff --git a/docs/README.en.md b/docs/README.en.md new file mode 100644 index 0000000..386e36b --- /dev/null +++ b/docs/README.en.md @@ -0,0 +1,13 @@ +# Documentation + +[Русский](README.md) | English + +Guides to the project's structure and development workflow. Russian documents live in `ru/`, with English translations in `en/`. + +- [ARCHITECTURE](en/ARCHITECTURE.md) covers service boundaries, layers, and planned product workflows. +- [DEVELOPMENT](en/DEVELOPMENT.md) covers project structure, code generation, and development rules. +- [DEPLOY](en/DEPLOY.md) covers startup, environment settings, and monitoring. +- [TESTING](en/TESTING.md) describes test types, commands, and check boundaries. +- [SECURITY](en/SECURITY.md) describes scanners, reports, and security exceptions. + +Update both language versions together. From the repository root, `make docs-check` checks documentation structure and local links. Source requirements and brand assets live in [requirements/](../requirements/README.en.md). diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..33300ff --- /dev/null +++ b/docs/README.md @@ -0,0 +1,13 @@ +# Документация + +Русский | [English](README.en.md) + +Руководства по устройству проекта и работе с ним. Русские документы находятся в `ru/`, английские переводы - в `en/`. + +- [ARCHITECTURE](ru/ARCHITECTURE.md) - границы сервисов, слои и запланированные продуктовые сценарии. +- [DEVELOPMENT](ru/DEVELOPMENT.md) - структура проекта, кодогенерация и правила разработки. +- [DEPLOY](ru/DEPLOY.md) - запуск, настройки окружения и мониторинг. +- [TESTING](ru/TESTING.md) - виды тестов, команды и границы проверок. +- [SECURITY](ru/SECURITY.md) - сканеры, отчеты и исключения безопасности. + +Обе языковые версии обновляются вместе. Из корня репозитория: `make docs-check` проверяет структуру документации и локальные ссылки. Исходные ТЗ и брендбук находятся в [requirements/](../requirements/README.md). diff --git a/docs/en/DEVELOPMENT.md b/docs/en/DEVELOPMENT.md index 8ecaf29..4faf082 100644 --- a/docs/en/DEVELOPMENT.md +++ b/docs/en/DEVELOPMENT.md @@ -40,6 +40,8 @@ Security tools have a separate install and work loop: `make -C security install` ## Layout +Each top-level directory except `.github/` has a short Russian `README.md` and an English `README.en.md`. A README and its translation are optional in `.github/`. Detailed guides live in `docs/ru/` and `docs/en/`; READMEs are not added below the first directory level. `make docs-check` validates language pairs and links and runs the checker's own tests. + | Directory | Purpose | | --- | --- | | api/core/ | Public browser-to-Go OpenAPI contract | diff --git a/docs/ru/DEVELOPMENT.md b/docs/ru/DEVELOPMENT.md index 5fc01cb..fc210be 100644 --- a/docs/ru/DEVELOPMENT.md +++ b/docs/ru/DEVELOPMENT.md @@ -40,6 +40,8 @@ make check не является бизнес-E2E проверкой. make verif ## Структура +В каждом каталоге первого уровня, кроме `.github/`, есть краткий `README.md` на русском и его перевод `README.en.md`. В `.github/` README и его перевод необязательны. Подробные руководства находятся в `docs/ru/` и `docs/en/`; README глубже первого уровня не добавляются. `make docs-check` проверяет языковые пары, ссылки и запускает тесты самого проверяющего скрипта. + | Каталог | Назначение | | --- | --- | | api/core/ | Публичный OpenAPI контракт браузер-Go | diff --git a/frontend/README.en.md b/frontend/README.en.md new file mode 100644 index 0000000..551e62e --- /dev/null +++ b/frontend/README.en.md @@ -0,0 +1,14 @@ +# Frontend + +[Русский](README.md) | English + +A React and TypeScript SPA built with Vite and organized using FSD. The current page shows backend status; candidate and employer dashboards are not implemented yet. + +- `src/app/` starts the application; `pages/`, `widgets/`, `features/`, and `entities/` are the interface layers. +- `src/shared/` contains shared components and the API client, including generated endpoints, Zod schemas, and MSW mocks. +- `codegen/orval.config.ts` configures generation from the shared OpenAPI contract. +- `scripts/` checks FSD boundaries. + +From the repository root, `make -C frontend dev` starts development and `make -C frontend check` runs checks and builds the app. In Docker, Nginx serves the built files using configuration from `deploy/nginx/`. + +See the [development guide](../docs/en/DEVELOPMENT.md). diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 0000000..06c5cf3 --- /dev/null +++ b/frontend/README.md @@ -0,0 +1,14 @@ +# Frontend + +Русский | [English](README.en.md) + +SPA на React и TypeScript со сборкой Vite и структурой FSD. Сейчас интерфейс показывает состояние backend; кабинеты кандидата и работодателя пока не реализованы. + +- `src/app/` - запуск приложения; `pages/`, `widgets/`, `features/`, `entities/` - слои интерфейса. +- `src/shared/` - общие компоненты и API-клиент, включая сгенерированные endpoints, схемы Zod и MSW-моки. +- `codegen/orval.config.ts` - генерация из общего OpenAPI-контракта. +- `scripts/` - проверки границ FSD. + +Из корня: `make -C frontend dev` запускает разработку, `make -C frontend check` - проверки и сборку. В Docker собранные файлы раздает Nginx с конфигурацией из `deploy/nginx/`. + +Подробнее: [разработка](../docs/ru/DEVELOPMENT.md). diff --git a/ml/README.en.md b/ml/README.en.md new file mode 100644 index 0000000..8291775 --- /dev/null +++ b/ml/README.en.md @@ -0,0 +1,14 @@ +# ML service + +[Русский](README.md) | English + +A separate Python service using FastAPI for future resume analysis and candidate matching. It currently provides an HTTP scaffold with `/healthz`, `/readyz`, and metrics. No model is connected yet, so `/readyz` returns 503. + +- `src/lincodex_ml/` contains the application, HTTP routes, and infrastructure code. +- `codegen/` configures Pydantic model generation from `api/ml/`. +- `tests/` checks service health and contract conformance. +- `pyproject.toml` and `uv.lock` define dependencies and Python tool settings. + +From the repository root, `make -C ml check` runs checks and `make -C ml run` starts the service locally. To use its separate Compose project, run `make -C deploy ml-up` after preparing `.env`. + +See [development](../docs/en/DEVELOPMENT.md) and [deployment](../docs/en/DEPLOY.md). diff --git a/ml/README.md b/ml/README.md new file mode 100644 index 0000000..48bf8eb --- /dev/null +++ b/ml/README.md @@ -0,0 +1,14 @@ +# ML-сервис + +Русский | [English](README.en.md) + +Отдельный Python-сервис на FastAPI для будущего анализа резюме и подбора кандидатов. Сейчас работает HTTP-каркас: `/healthz`, `/readyz` и метрики. Модель еще не подключена, поэтому `/readyz` возвращает 503. + +- `src/lincodex_ml/` - приложение, HTTP-маршруты и инфраструктурный код. +- `codegen/` - настройки генерации моделей Pydantic из `api/ml/`. +- `tests/` - проверки состояния сервиса и соответствия контракту. +- `pyproject.toml` и `uv.lock` - зависимости и настройки Python-инструментов. + +Из корня: `make -C ml check` запускает проверки, `make -C ml run` - сервис локально. Для запуска через отдельный Compose используйте `make -C deploy ml-up` после подготовки `.env`. + +Подробнее: [разработка](../docs/ru/DEVELOPMENT.md) и [развертывание](../docs/ru/DEPLOY.md). diff --git a/observability/README.en.md b/observability/README.en.md new file mode 100644 index 0000000..d601c40 --- /dev/null +++ b/observability/README.en.md @@ -0,0 +1,13 @@ +# Monitoring + +[Русский](README.md) | English + +Configuration for collecting metrics and logs, with dashboards for service health. + +- `prometheus/` configures metric collection and ML targets. +- `loki/` configures log storage; `alloy/` handles log collection and forwarding. +- `grafana/` contains data sources and dashboards for Go, PostgreSQL, Redis, SeaweedFS, and the host. + +From the repository root, `make -C observability check` validates configuration using Docker. Start monitoring separately after the core services with `make -C deploy monitoring-up`; its Compose file lives in `deploy/docker/`. + +See the [deployment guide](../docs/en/DEPLOY.md). diff --git a/observability/README.md b/observability/README.md new file mode 100644 index 0000000..6dd5593 --- /dev/null +++ b/observability/README.md @@ -0,0 +1,13 @@ +# Мониторинг + +Русский | [English](README.en.md) + +Настройки сбора метрик и логов, а также готовые дашборды для технического состояния сервисов. + +- `prometheus/` - сбор метрик и список ML-targets. +- `loki/` - хранение логов; `alloy/` - их сбор и отправка. +- `grafana/` - источники данных и дашборды Go, PostgreSQL, Redis, SeaweedFS и хоста. + +Из корня: `make -C observability check` проверяет конфигурации через Docker. Сам стек запускается отдельно после основных сервисов командой `make -C deploy monitoring-up`; его Compose-файл находится в `deploy/docker/`. + +Подробнее: [развертывание](../docs/ru/DEPLOY.md). diff --git a/requirements/README.en.md b/requirements/README.en.md new file mode 100644 index 0000000..b2a99f4 --- /dev/null +++ b/requirements/README.en.md @@ -0,0 +1,10 @@ +# Source materials + +[Русский](README.md) | English + +Materials supplied by the hackathon organizers that define the project's requirements and visual identity. + +- [specification.pdf](specification.pdf) is the original specification for the FSP special track. +- [brandbook/](brandbook/) contains the extracted brand assets: logos, images, and a font archive. + +Architecture decisions and development rules are documented separately in [docs/](../docs/README.en.md). This directory preserves the source materials for reference when clarifying requirements. diff --git a/requirements/README.md b/requirements/README.md new file mode 100644 index 0000000..e076cc9 --- /dev/null +++ b/requirements/README.md @@ -0,0 +1,10 @@ +# Исходные материалы + +Русский | [English](README.en.md) + +Материалы организаторов хакатона, на которых основаны требования и оформление проекта. + +- [specification.pdf](specification.pdf) - исходное ТЗ специального трека ФСП. +- [brandbook/](brandbook/) - распакованные материалы брендбука: логотипы, изображения и архив шрифта. + +Архитектурные решения и правила разработки описаны отдельно в [docs/](../docs/README.md). Этот каталог хранит исходные материалы, к которым можно обратиться при уточнении требований. diff --git a/scripts/README.en.md b/scripts/README.en.md new file mode 100644 index 0000000..c90846b --- /dev/null +++ b/scripts/README.en.md @@ -0,0 +1,15 @@ +# Shared scripts + +[Русский](README.md) | English + +Helper tools that work across multiple parts of the repository. + +- `merge-schemas.py` merges OpenAPI schemas; `requirements-codegen.txt` lists its dependencies. +- `check-api-compat.sh` checks public API compatibility against a selected Git ref. +- `check-generated.py` detects generated files that differ from Git. +- `docs-check.py` checks documentation, README language pairs, and local links. +- `test_docs_check.py` and `test_merge_schemas.py` test documentation validation and schema merging. + +Run them through Make from the repository root: `make -C api check`, `make -C api check-compat API_BASE_REF=`, `make check-generated`, and `make docs-check`. Service-specific scripts live in their service directories. + +See the [development guide](../docs/en/DEVELOPMENT.md). diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..e217b8b --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,15 @@ +# Общие скрипты + +Русский | [English](README.en.md) + +Вспомогательные инструменты, которые работают с несколькими частями репозитория. + +- `merge-schemas.py` объединяет OpenAPI-схемы; зависимости для него перечислены в `requirements-codegen.txt`. +- `check-api-compat.sh` проверяет совместимость публичного API с выбранной Git-ссылкой. +- `check-generated.py` обнаруживает расхождения сгенерированных файлов с Git. +- `docs-check.py` проверяет документацию, языковые пары README и локальные ссылки. +- `test_docs_check.py` и `test_merge_schemas.py` проверяют валидацию документации и объединение схем. + +Запускайте их через Make из корня: `make -C api check`, `make -C api check-compat API_BASE_REF=`, `make check-generated` и `make docs-check`. Скрипты конкретного сервиса находятся в его каталоге. + +Подробнее: [разработка](../docs/ru/DEVELOPMENT.md). diff --git a/scripts/docs-check.py b/scripts/docs-check.py index 8d1aba1..ac384b2 100644 --- a/scripts/docs-check.py +++ b/scripts/docs-check.py @@ -33,6 +33,7 @@ IGNORED_DIRS = { "venv", } LANGUAGE_DOCS = {"ARCHITECTURE.md", "DEPLOY.md", "DEVELOPMENT.md", "TESTING.md"} +README_NAMES = ("README.md", "README.en.md") INLINE_LINK = re.compile( r"!?\[[^\]]*\]\(\s*(<[^>]+>|(?:\\.|[^\s)])+)(?:\s+[^)]*)?\)" ) @@ -187,13 +188,24 @@ def check_language_docs(root: Path, errors: list[str]) -> None: errors.append("docs/ru and docs/en filenames do not match: " + "; ".join(details)) -def check_root_readme(files: list[Path], root: Path, errors: list[str]) -> None: - expected = (root / "README.md").resolve() - if not expected.is_file(): - errors.append("missing root README.md") - nested = [path for path in files if path.name.lower() == "readme.md" and path != expected] - for path in nested: - errors.append(f"nested README is not allowed: {path.relative_to(root)}") +def check_readmes(files: list[Path], root: Path, errors: list[str]) -> None: + directories = {root} + for path in files: + if path.name not in README_NAMES: + continue + relative = path.relative_to(root) + if relative.parts[0] == ".github": + continue + if len(relative.parts) > 2: + errors.append(f"README is below a top-level directory: {relative}") + continue + directories.add(path.parent) + file_set = set(files) + for directory in sorted(directories): + for name in README_NAMES: + path = directory / name + if path not in file_set: + errors.append(f"missing README translation: {path.relative_to(root)}") for name in ("AGENTS.md", "CLAUDE.md", "AGENTS_ROUTING.md"): if not (root / name).is_file(): errors.append(f"missing root {name}") @@ -255,7 +267,7 @@ def validate_repository(root: Path) -> list[str]: root = root.resolve() errors: list[str] = [] files = markdown_files(root) - check_root_readme(files, root, errors) + check_readmes(files, root, errors) check_language_docs(root, errors) routing = root / "AGENTS_ROUTING.md" diff --git a/scripts/test_docs_check.py b/scripts/test_docs_check.py index d6066be..aa8ecf4 100644 --- a/scripts/test_docs_check.py +++ b/scripts/test_docs_check.py @@ -18,6 +18,7 @@ class DocsCheckTests(unittest.TestCase): self.temporary = tempfile.TemporaryDirectory() self.root = Path(self.temporary.name) self.write("README.md", "# Root\n\n[Guide](docs/en/DEVELOPMENT.md)\n") + self.write("README.en.md", "# Root\n") self.write("AGENTS.md", "Project rules.\n") self.write("CLAUDE.md", "@AGENTS.md\n") self.write( @@ -49,6 +50,49 @@ class DocsCheckTests(unittest.TestCase): self.write("docs/en/FAQ.md", "# FAQ\n") self.assertEqual([], DOCS_CHECK.validate_repository(self.root)) + def test_accepts_top_level_readme_pairs(self) -> None: + for directory in ("backend", ".github", ".agents", "docs"): + self.write(f"{directory}/README.md", "[English](README.en.md)\n") + self.write(f"{directory}/README.en.md", "[Русский](README.md)\n") + self.assertEqual([], DOCS_CHECK.validate_repository(self.root)) + + def test_requires_both_readme_languages(self) -> None: + for missing in ("README.md", "README.en.md"): + with self.subTest(missing=missing): + self.write("backend/README.md", "# Backend\n") + self.write("backend/README.en.md", "# Backend\n") + (self.root / "backend" / missing).unlink() + errors = DOCS_CHECK.validate_repository(self.root) + self.assertIn(f"missing README translation: backend/{missing}", errors) + + def test_accepts_github_without_readmes(self) -> None: + self.write(".github/workflows/ci.yml", "name: CI\n") + self.assertEqual([], DOCS_CHECK.validate_repository(self.root)) + + def test_does_not_require_github_readme_translation(self) -> None: + for name in ("README.md", "README.en.md"): + with self.subTest(name=name): + path = self.write(f".github/{name}", "# GitHub Actions\n") + errors = DOCS_CHECK.validate_repository(self.root) + path.unlink() + self.assertEqual([], errors) + + def test_still_checks_links_in_github(self) -> None: + self.write(".github/CONTRIBUTING.md", "[Missing](missing.md)\n") + errors = DOCS_CHECK.validate_repository(self.root) + self.assertTrue(any("broken local link" in error for error in errors), errors) + + def test_requires_root_readme_translation(self) -> None: + (self.root / "README.en.md").unlink() + errors = DOCS_CHECK.validate_repository(self.root) + self.assertIn("missing README translation: README.en.md", errors) + + def test_rejects_deeply_nested_readmes(self) -> None: + self.write("backend/internal/README.md", "# Internal\n") + self.write("backend/internal/README.en.md", "# Internal\n") + errors = DOCS_CHECK.validate_repository(self.root) + self.assertTrue(any("README is below a top-level directory" in error for error in errors), errors) + def test_ignores_scanner_dependency_documentation(self) -> None: for directory in (".cache", ".bin", ".tools"): self.write(f"security/{directory}/dependency/README.md", "[Upstream](missing.md)\n") diff --git a/security/README.en.md b/security/README.en.md new file mode 100644 index 0000000..984bdb8 --- /dev/null +++ b/security/README.en.md @@ -0,0 +1,14 @@ +# Security checks + +[Русский](README.md) | English + +Tools and rules that CI runs against source code, dependencies, and container images. + +- `trivy/` configures dependency, configuration, and image scans, including scoped exceptions. +- `gitleaks/` configures secret detection in files and Git history. +- `semgrep/` contains local TypeScript and Python rules with test fixtures. +- `install.py` and `tests/` handle tool installation and execution checks. govulncheck separately scans Go code. + +From the repository root, `make -C security install` installs tools locally, `make -C security test check` checks rules and source code, and `make -C security images` builds and scans images using Docker. Reports are saved in the ignored `reports/` directory. + +See the [security guide](../docs/en/SECURITY.md). diff --git a/security/README.md b/security/README.md new file mode 100644 index 0000000..d5e179b --- /dev/null +++ b/security/README.md @@ -0,0 +1,14 @@ +# Проверки безопасности + +Русский | [English](README.en.md) + +Инструменты и правила проверок, которые CI запускает для исходников, зависимостей и контейнерных образов. + +- `trivy/` - зависимости, конфигурация, образы и адресные исключения. +- `gitleaks/` - поиск секретов в файлах и истории Git. +- `semgrep/` - локальные правила для TypeScript и Python с тестовыми примерами. +- `install.py` и `tests/` - установка инструментов и проверки их запуска. Go-код отдельно проверяет govulncheck. + +Из корня: `make -C security install` устанавливает инструменты локально, `make -C security test check` проверяет правила и исходники, `make -C security images` собирает и сканирует образы через Docker. Отчеты сохраняются в игнорируемом `reports/`. + +Подробнее: [безопасность](../docs/ru/SECURITY.md).