From 589f5ab0e2fa62ad15008da97a63eeadcf0d5280 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Sun, 8 Mar 2026 23:37:35 +0200 Subject: [PATCH] feat: add validation tooling and expand path review instructions Add pre-commit hooks (YAML lint, schema validation, editorconfig), CI workflow, and new path instructions for test files, Dockerfiles, config files, and archival docs. --- .editorconfig | 15 +++++++++++++++ .github/workflows/validate.yml | 21 ++++++++++++++++++++ .gitignore | 6 ++++++ .pre-commit-config.yaml | 35 ++++++++++++++++++++++++++++++++++ .yamllint.yaml | 13 +++++++++++++ README.md | 1 - coderabbit.yaml | 31 +++++++++++++++++++++++++----- 7 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/validate.yml create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 .yamllint.yaml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..00f2c60 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..9b1279c --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,21 @@ +--- +name: Validate Configuration + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: pre-commit/action@v3.0.1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..514517e --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Python +__pycache__/ +*.py[cod] + +# Pre-commit +.pre-commit-cache/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..dac7556 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +--- +repos: + # Standard hooks: basic file hygiene + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-yaml + args: ['--allow-multiple-documents'] + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-merge-conflict + + # YAML linting + - repo: https://github.com/adrienverge/yamllint + rev: v1.38.0 + hooks: + - id: yamllint + args: [--strict] + + # JSON Schema validation against CodeRabbit's official schema + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.37.0 + hooks: + - id: check-jsonschema + name: Validate coderabbit.yaml against schema + files: ^coderabbit\.yaml$ + args: + - '--schemafile' + - 'https://storage.googleapis.com/coderabbit_public_assets/schema.v2.json' + + # EditorConfig compliance + - repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: '3.6.1' + hooks: + - id: editorconfig-checker diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..513b8bd --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,13 @@ +--- +extends: default +rules: + line-length: + max: 120 + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: true + truthy: + check-keys: false + allowed-values: ['true', 'false', 'on', 'off'] + comments: + min-spaces-from-content: 1 + document-start: enable diff --git a/README.md b/README.md index 0163e62..5e9a10b 100644 --- a/README.md +++ b/README.md @@ -21,4 +21,3 @@ This way the repository is always using the latest configuration. - [YouTube Channel](https://www.youtube.com/@CodeRabbitAI) - Official YouTube channel with tutorials and updates. - [AI Code Reviewer Examples](https://www.coderabbit.ai/blog/how-to-use-an-ai-code-reviewer-on-github-in-4-examples) - Four practical examples of using CodeRabbit. - [OpenAPI Documentation](https://api.coderabbit.ai/api/swagger/) - Complete Swagger documentation for CodeRabbit's REST API endpoints. - diff --git a/coderabbit.yaml b/coderabbit.yaml index 0dbf1dc..ee6e0fc 100644 --- a/coderabbit.yaml +++ b/coderabbit.yaml @@ -68,15 +68,37 @@ reviews: instructions: >- When a project contains a `docs/` directory: 1. Consider the files in the `docs/` directory tree the core/main/in-depth - documentation of the project. Also consider the 'docs/**.md' files the - second place to look for project documentation after the 'README.md' file. + documentation of the project. Also consider the 'docs/**.md' files the + second place to look for project documentation after the 'README.md' file. 2. When reviewing the documentation files (e.g. `docs/**.md`), - they should additionally be linted with help from the tool `markdownlint`, pointing out any issues. + they should additionally be linted with help from the tool `markdownlint`, pointing out any issues. 3. When reviewing the documentation files in `docs/` directory, they should - additionally be linted with help from the tool `languagetool`, pointing out any issues. + additionally be linted with help from the tool `languagetool`, pointing out any issues. 4. Focus on grammar, spelling, and punctuation. 5. Also consider readability and clarity of contents. 6. Avoid gender-specific language and use the imperative form. + - path: "docs/plans/**" + instructions: >- + These are historical design and planning documents. They may contain + outdated information and do not reflect current implementation. + Do not enforce current coding standards or suggest updates to align + with current practices. Focus only on grammar, spelling, and + readability if changes are being reviewed. + - path: "**/*.{test,spec}.*" + instructions: >- + These are test files. Focus on test coverage completeness, + assertion quality, and avoiding flaky test patterns. + Some duplication in tests is acceptable for readability — + do not enforce DRY as aggressively as in production code. + - path: "**/Dockerfile*" + instructions: >- + Review Dockerfiles for security best practices (non-root user, + minimal base images, no secrets baked into layers), multi-stage + build opportunities, and layer caching efficiency. + - path: "**/*.{json,yaml,yml,toml}" + instructions: >- + Configuration files: verify valid structure, ensure no hardcoded + secrets or credentials, and check consistency with project conventions. abort_on_close: true disable_cache: false auto_review: @@ -222,4 +244,3 @@ code_generation: path_instructions: [] unit_tests: path_instructions: [] -