Skip to content

Commit 4cbf0fb

Browse files
feat: initial DevRail implementation
Pre-commit hook for conventional commit message validation with development standards, beta notice, and STABILITY.md. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0 parents  commit 4cbf0fb

25 files changed

+1524
-0
lines changed

.cursorrules

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
This project follows DevRail development standards.
2+
See DEVELOPMENT.md for the complete reference.
3+
4+
Critical Rules:
5+
6+
1. Run `make check` before completing any story or task. Never mark work done
7+
without passing checks. This is the single gate for all linting, formatting,
8+
security, and test validation.
9+
2. Use conventional commits. Every commit message follows the
10+
`type(scope): description` format. No exceptions.
11+
3. Never install tools outside the container. All linters, formatters, scanners,
12+
and test runners live inside `ghcr.io/devrail-dev/dev-toolchain:v1`. The
13+
Makefile delegates to Docker. Do not install tools on the host.
14+
4. Respect `.editorconfig`. Never override formatting rules (indent style, line
15+
endings, trailing whitespace) without explicit instruction.
16+
5. Write idempotent scripts. Every script must be safe to re-run. Check before
17+
acting: `command -v tool || install_tool`, `mkdir -p`, guard file writes with
18+
existence checks.
19+
6. Use the shared logging library. No raw `echo` for status messages. Use
20+
`log_info`, `log_warn`, `log_error`, `log_debug`, and `die` from
21+
`lib/log.sh`.
22+
23+
Quick Reference:
24+
25+
- Run `make check` to validate all standards
26+
- Run `make help` to see available targets
27+
- All tools run inside the dev-toolchain container

.devrail.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# .devrail.yml — DevRail project configuration
2+
# Pre-commit conventional commits hook (Python)
3+
languages:
4+
- python
5+
6+
fail_fast: false
7+
log_format: json

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 2
10+
11+
[Makefile]
12+
indent_style = tab
13+
14+
[*.py]
15+
indent_size = 4
16+
17+
[*.sh]
18+
indent_size = 2

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
check:
14+
name: make check
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Run make check
21+
run: |
22+
docker run --rm \
23+
-v "$(pwd):/workspace" \
24+
-w /workspace \
25+
ghcr.io/devrail-dev/dev-toolchain:v1 \
26+
make _check
27+
28+
gitleaks:
29+
name: gitleaks
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
- name: Run gitleaks
36+
run: |
37+
docker run --rm \
38+
-v "$(pwd):/workspace" \
39+
-w /workspace \
40+
ghcr.io/devrail-dev/dev-toolchain:v1 \
41+
gitleaks detect --source /workspace --verbose

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# OS files
2+
.DS_Store
3+
Thumbs.db
4+
Desktop.ini
5+
._*
6+
7+
# Editor files
8+
*.swp
9+
*.swo
10+
*~
11+
.vscode/
12+
.idea/
13+
*.sublime-project
14+
*.sublime-workspace
15+
16+
# Environment and secrets
17+
.env
18+
.env.*
19+
*.pem
20+
*.key
21+
22+
# Build artifacts
23+
*.log
24+
tmp/
25+
dist/
26+
build/
27+
28+
# Python
29+
__pycache__/
30+
*.py[cod]
31+
*.egg-info/
32+
.eggs/
33+
.venv/
34+
venv/
35+
.mypy_cache/
36+
.pytest_cache/
37+
.ruff_cache/

.gitleaksignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# .gitleaksignore — Gitleaks false positive allowlist
2+
#
3+
# Add SHA hashes of allowed findings to suppress false positives.
4+
# Each line is a finding fingerprint (SHA hash) from gitleaks output.
5+
#
6+
# To get the fingerprint of a finding, run:
7+
# gitleaks detect --report-format json --report-path /dev/stdout
8+
#
9+
# Then copy the "Fingerprint" value for the finding you want to allow.
10+
#
11+
# Alternatively, use inline comments in the source file:
12+
# some_value = "not-a-secret" # gitleaks:allow
13+
#
14+
# See: https://github.com/gitleaks/gitleaks#configuration

.opencode/agents.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
agents:
2+
- name: devrail
3+
description: DevRail development standards
4+
instructions: |
5+
This project follows DevRail development standards.
6+
See DEVELOPMENT.md for the complete reference.
7+
8+
Critical Rules:
9+
10+
1. Run `make check` before completing any story or task. Never mark work
11+
done without passing checks. This is the single gate for all linting,
12+
formatting, security, and test validation.
13+
2. Use conventional commits. Every commit message follows the
14+
`type(scope): description` format. No exceptions.
15+
3. Never install tools outside the container. All linters, formatters,
16+
scanners, and test runners live inside
17+
`ghcr.io/devrail-dev/dev-toolchain:v1`. The Makefile delegates to
18+
Docker. Do not install tools on the host.
19+
4. Respect `.editorconfig`. Never override formatting rules (indent style,
20+
line endings, trailing whitespace) without explicit instruction.
21+
5. Write idempotent scripts. Every script must be safe to re-run. Check
22+
before acting: `command -v tool || install_tool`, `mkdir -p`, guard
23+
file writes with existence checks.
24+
6. Use the shared logging library. No raw `echo` for status messages. Use
25+
`log_info`, `log_warn`, `log_error`, `log_debug`, and `die` from
26+
`lib/log.sh`.
27+
28+
Quick Reference:
29+
30+
- Run `make check` to validate all standards
31+
- Run `make help` to see available targets
32+
- All tools run inside the dev-toolchain container

.pre-commit-config.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# .pre-commit-config.yaml — DevRail pre-commit hooks
2+
#
3+
# Fast-local hooks only. Full scanning runs in CI via `make check`.
4+
#
5+
# Hook strategy: All language hooks are included. Hooks that match no staged
6+
# files have zero runtime cost. This eliminates the need for a config-generation
7+
# step based on .devrail.yml — hooks naturally only fire for matching file types.
8+
#
9+
# Performance budget: All hooks must complete within 30 seconds total on a
10+
# typical changeset (< 50 files).
11+
#
12+
# Fast-local vs slow-CI split:
13+
# LOCAL (this file): ruff, shellcheck, shfmt, terraform fmt, tflint,
14+
# ansible-lint, conventional-commits, gitleaks, terraform-docs
15+
# CI ONLY (make check): bandit, semgrep, tfsec, checkov, pytest, bats,
16+
# terratest, trivy, molecule
17+
18+
repos:
19+
# --- Conventional Commits (Story 4.1) ---
20+
# Validates commit message format: type(scope): description
21+
# Runs on commit-msg stage, not pre-commit stage
22+
- repo: https://github.com/devrail-dev/pre-commit-conventional-commits
23+
rev: v1.0.0
24+
hooks:
25+
- id: conventional-commits
26+
27+
# --- Python: ruff lint + format (Story 4.2) ---
28+
# Ruff replaces flake8, isort, and black in a single tool.
29+
# Typically < 1 second for staged files.
30+
# Triggers on: .py files (declared via types_or: [python])
31+
# .devrail.yml language: python
32+
- repo: https://github.com/astral-sh/ruff-pre-commit
33+
rev: v0.8.6
34+
hooks:
35+
- id: ruff
36+
name: ruff check
37+
- id: ruff-format
38+
name: ruff format check
39+
args: [--check]
40+
41+
# --- Bash: shellcheck (Story 4.2) ---
42+
# Static analysis for shell scripts.
43+
# Triggers on: shell scripts (types: [shell])
44+
# .devrail.yml language: bash
45+
- repo: https://github.com/shellcheck-py/shellcheck-py
46+
rev: v0.10.0.1
47+
hooks:
48+
- id: shellcheck
49+
50+
# --- Bash: shfmt (Story 4.2) ---
51+
# Consistent formatting for shell scripts.
52+
# Triggers on: shell scripts (types: [shell])
53+
# .devrail.yml language: bash
54+
- repo: https://github.com/scop/pre-commit-shfmt
55+
rev: v3.10.0-1
56+
hooks:
57+
- id: shfmt
58+
args: [--diff]
59+
60+
# --- Terraform: fmt + tflint + docs (Stories 4.2, 4.3) ---
61+
# terraform_fmt: Canonical formatting for .tf files
62+
# terraform_tflint: Terraform-specific linting rules
63+
# terraform_docs: Auto-generates README with inputs/outputs/resources
64+
# Triggers on: .tf files
65+
# .devrail.yml language: terraform
66+
- repo: https://github.com/antonbabenko/pre-commit-terraform
67+
rev: v1.96.3
68+
hooks:
69+
- id: terraform_fmt
70+
- id: terraform_tflint
71+
- id: terraform_docs
72+
args:
73+
- --hook-config=--path-to-file=README.md
74+
- --hook-config=--add-to-existing-file=true
75+
76+
# --- Ansible: lint (Story 4.2) ---
77+
# Playbook and role linting.
78+
# Triggers on: Ansible YAML files (playbooks, roles, tasks)
79+
# .devrail.yml language: ansible
80+
- repo: https://github.com/ansible/ansible-lint
81+
rev: v24.12.2
82+
hooks:
83+
- id: ansible-lint
84+
85+
# --- Secrets: gitleaks (Story 4.3) ---
86+
# Scans staged files for secrets, API keys, and credentials.
87+
# Runs on EVERY commit regardless of language — secrets can appear in any file.
88+
# This is on the local side of the fast-local / slow-CI split because once a
89+
# secret is pushed, the damage is done.
90+
#
91+
# False positive handling:
92+
# - Create .gitleaksignore in repo root with SHA hashes of allowed findings
93+
# - Or use inline `# gitleaks:allow` comment on the line with the false positive
94+
- repo: https://github.com/gitleaks/gitleaks
95+
rev: v8.21.2
96+
hooks:
97+
- id: gitleaks

.pre-commit-hooks.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- id: conventional-commits
2+
name: Conventional Commits
3+
description: Enforce conventional commit message format with DevRail types and scopes
4+
entry: conventional-commits-check
5+
language: python
6+
stages: [commit-msg]
7+
always_run: true
8+
minimum_pre_commit_version: "3.0.0"

AGENTS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Agent Instructions
2+
3+
This project follows [DevRail](https://devrail.dev) development standards.
4+
See DEVELOPMENT.md for the complete reference.
5+
6+
## Critical Rules
7+
8+
1. **Run `make check` before completing any story or task.** Never mark work done without passing checks. This is the single gate for all linting, formatting, security, and test validation.
9+
2. **Use conventional commits.** Every commit message follows the `type(scope): description` format. No exceptions.
10+
3. **Never install tools outside the container.** All linters, formatters, scanners, and test runners live inside `ghcr.io/devrail-dev/dev-toolchain:v1`. The Makefile delegates to Docker. Do not install tools on the host.
11+
4. **Respect `.editorconfig`.** Never override formatting rules (indent style, line endings, trailing whitespace) without explicit instruction.
12+
5. **Write idempotent scripts.** Every script must be safe to re-run. Check before acting: `command -v tool || install_tool`, `mkdir -p`, guard file writes with existence checks.
13+
6. **Use the shared logging library.** No raw `echo` for status messages. Use `log_info`, `log_warn`, `log_error`, `log_debug`, and `die` from `lib/log.sh`.
14+
15+
## Quick Reference
16+
17+
- Run `make check` to validate all standards
18+
- Run `make help` to see available targets
19+
- All tools run inside the dev-toolchain container

0 commit comments

Comments
 (0)